superset-showtime 0.5.10__py3-none-any.whl → 0.5.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of superset-showtime might be problematic. Click here for more details.

showtime/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
  Circus tent emoji state tracking for Apache Superset ephemeral environments.
5
5
  """
6
6
 
7
- __version__ = "0.5.10"
7
+ __version__ = "0.5.11"
8
8
  __author__ = "Maxime Beauchemin"
9
9
  __email__ = "maximebeauchemin@gmail.com"
10
10
 
@@ -50,7 +50,7 @@ def is_git_repository(path: str = ".") -> bool:
50
50
  def validate_required_sha(required_sha: Optional[str] = None) -> Tuple[bool, Optional[str]]:
51
51
  """
52
52
  Validate that the required SHA exists in the current Git repository.
53
- Tries to fetch the SHA from origin if validation fails in a shallow clone.
53
+ Uses GitHub API for reliable validation in shallow clone environments.
54
54
 
55
55
  Args:
56
56
  required_sha: SHA to validate (default: REQUIRED_SHA constant)
@@ -60,55 +60,90 @@ def validate_required_sha(required_sha: Optional[str] = None) -> Tuple[bool, Opt
60
60
  - (True, None) if validation passes
61
61
  - (False, error_message) if validation fails
62
62
  """
63
- if Repo is None:
64
- return False, "GitPython not available for SHA validation"
65
-
66
63
  sha_to_check = required_sha or REQUIRED_SHA
67
64
  if not sha_to_check:
68
65
  return True, None # No requirement set
69
66
 
67
+ # Try GitHub API validation first (works in shallow clones)
70
68
  try:
71
- repo = Repo(".")
69
+ return _validate_sha_via_github_api(sha_to_check)
70
+ except Exception as e:
71
+ print(f"⚠️ GitHub API validation failed: {e}")
72
+
73
+ # Fallback to Git validation for non-GitHub origins
74
+ if Repo is None:
75
+ print("⚠️ GitPython not available, skipping SHA validation")
76
+ return True, None
72
77
 
73
- # First attempt: Search for SHA in git log (has to work in shallow clones where merge_base fails)
78
+ try:
79
+ repo = Repo(".")
74
80
  is_valid, error = _validate_sha_in_log(repo, sha_to_check)
75
81
  if is_valid:
76
82
  return True, None
83
+ else:
84
+ print(f"⚠️ Git validation failed: {error}")
85
+ return True, None # Allow operation to continue
77
86
 
78
- # If validation failed, check if we're in a shallow clone and try fetching
79
- try:
80
- is_shallow = repo.git.rev_parse("--is-shallow-repository") == "true"
81
- if is_shallow:
82
- try:
83
- print(f"🌊 Shallow clone detected, attempting to fetch {sha_to_check[:7]}...")
84
- repo.git.fetch("origin", sha_to_check)
85
-
86
- # Retry validation after fetch
87
- is_valid_after_fetch, error_after_fetch = _validate_sha_in_log(
88
- repo, sha_to_check
89
- )
90
- if is_valid_after_fetch:
91
- print(f"✅ Successfully fetched and validated {sha_to_check[:7]}")
92
- return True, None
93
- else:
94
- return False, error_after_fetch
95
-
96
- except Exception as fetch_error:
97
- return False, (
98
- f"Required commit {sha_to_check} not found in shallow clone. "
99
- f"Failed to fetch from origin: {fetch_error}"
100
- )
101
- else:
102
- return False, error
87
+ except InvalidGitRepositoryError:
88
+ print("⚠️ Not a Git repository, skipping SHA validation")
89
+ return True, None
90
+ except Exception as e:
91
+ print(f"⚠️ Git validation error: {e}")
92
+ return True, None
103
93
 
104
- except Exception:
105
- # If shallow check fails, return original error
106
- return False, error
107
94
 
108
- except InvalidGitRepositoryError:
109
- return False, "Current directory is not a Git repository"
95
+ def _validate_sha_via_github_api(required_sha: str) -> Tuple[bool, Optional[str]]:
96
+ """Validate SHA using GitHub API - works reliably in shallow clones"""
97
+ try:
98
+ import httpx
99
+ from git import Repo
100
+
101
+ from .github import GitHubInterface
102
+
103
+ # Get current SHA from Git
104
+ repo = Repo(".")
105
+ current_sha = repo.head.commit.hexsha
106
+
107
+ # Use existing GitHubInterface (handles all the setup/token detection)
108
+ github = GitHubInterface()
109
+
110
+ # 1. Check if required SHA exists
111
+ commit_url = f"{github.base_url}/repos/{github.org}/{github.repo}/commits/{required_sha}"
112
+
113
+ with httpx.Client() as client:
114
+ response = client.get(commit_url, headers=github.headers)
115
+ if response.status_code == 404:
116
+ return False, f"Required SHA {required_sha[:7]} not found in repository"
117
+ response.raise_for_status()
118
+
119
+ # 2. Compare SHAs to verify ancestry
120
+ compare_url = f"{github.base_url}/repos/{github.org}/{github.repo}/compare/{required_sha}...{current_sha}"
121
+
122
+ with httpx.Client() as client:
123
+ response = client.get(compare_url, headers=github.headers)
124
+ if response.status_code == 404:
125
+ return (
126
+ False,
127
+ f"Current branch does not include required SHA {required_sha[:7]}. Please rebase onto main.",
128
+ )
129
+ response.raise_for_status()
130
+
131
+ data = response.json()
132
+ status = data.get("status")
133
+
134
+ # If status is 'ahead' or 'identical', required SHA is ancestor (good)
135
+ # If status is 'behind', current is behind required (bad)
136
+ if status in ["ahead", "identical"]:
137
+ return True, None
138
+ else:
139
+ return (
140
+ False,
141
+ f"Current branch does not include required SHA {required_sha[:7]}. Please rebase onto main.",
142
+ )
143
+
110
144
  except Exception as e:
111
- return False, f"Git validation error: {e}"
145
+ # Re-raise to be caught by the caller for proper fallback handling
146
+ raise Exception(f"GitHub API validation error: {e}") from e
112
147
 
113
148
 
114
149
  def _validate_sha_in_log(repo: "Repo", sha_to_check: str) -> Tuple[bool, Optional[str]]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: superset-showtime
3
- Version: 0.5.10
3
+ Version: 0.5.11
4
4
  Summary: 🎪 Apache Superset ephemeral environment management with circus tent emoji state tracking
5
5
  Project-URL: Homepage, https://github.com/apache/superset-showtime
6
6
  Project-URL: Documentation, https://superset-showtime.readthedocs.io/
@@ -1,17 +1,17 @@
1
- showtime/__init__.py,sha256=r5Mw0YBgwzRCe1nzqQk2iWxvfq0ZlUB73ibq-4NfFKk,449
1
+ showtime/__init__.py,sha256=HcxA_d-Wu3K1hL8OL_1I6y3u8cclS3dbUSMbv4RG2GA,449
2
2
  showtime/__main__.py,sha256=EVaDaTX69yIhCzChg99vqvFSCN4ELstEt7Mpb9FMZX8,109
3
3
  showtime/cli.py,sha256=8vIJT5TiqXuHDGxRBg6jV3oNv5nKrmDOs5OgltycPeI,31664
4
4
  showtime/core/__init__.py,sha256=54hbdFNGrzuNMBdraezfjT8Zi6g221pKlJ9mREnKwCw,34
5
5
  showtime/core/aws.py,sha256=uTjJAvEBQMyTccS93WZeNPhfeKQhJgOQQ0BJdnQjvCU,35007
6
6
  showtime/core/emojis.py,sha256=MHEDuPIdfNiop4zbNLuviz3eY05QiftYSHHCVbkfKhw,2129
7
- showtime/core/git_validation.py,sha256=W8I9dOZiai-oDJz8LQCEyQ-94CHjfwhE4th83Vu2nQs,5450
7
+ showtime/core/git_validation.py,sha256=Knr-9IAHXlhhkBeReJPlqzBG_TDWlevIqYaB26OPM04,6686
8
8
  showtime/core/github.py,sha256=uETvKDO2Yhpqg3fxLtrKaCuZR3b-1LVmgnf5aLcqrAQ,9988
9
9
  showtime/core/github_messages.py,sha256=MfgwCukrEsWWesMsuL8saciDgP4nS-gijzu8DXr-Alg,7450
10
10
  showtime/core/label_colors.py,sha256=efhbFnz_3nqEnEqmgyF6_hZbxtCu_fmb68BIIUpSsnk,3895
11
11
  showtime/core/pull_request.py,sha256=vKlPPlIeSNT_WmlZkOekLH_tGYm4pyJUZFHQC9dVCKY,27756
12
12
  showtime/core/show.py,sha256=FpxDm52LASCJvf8UF998AtNiVzfdYIwNEsPAsOAAwL0,9701
13
13
  showtime/data/ecs-task-definition.json,sha256=Y8ZbAAXdIDMnM-8zzfdUTlwp5RpWSyhe1gtfygKkqW8,2343
14
- superset_showtime-0.5.10.dist-info/METADATA,sha256=xLlmWh1tonx0z3rMEEFPlRKDOmf_i8GGS5p-mFacfbc,12053
15
- superset_showtime-0.5.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- superset_showtime-0.5.10.dist-info/entry_points.txt,sha256=rDW7oZ57mqyBUS4N_3_R7bZNGVHB-104jwmY-hHC_ck,85
17
- superset_showtime-0.5.10.dist-info/RECORD,,
14
+ superset_showtime-0.5.11.dist-info/METADATA,sha256=Ekcs0XHNPJC-W8ZfULfh8CqbZTpKehGk1yJWirNOYAE,12053
15
+ superset_showtime-0.5.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ superset_showtime-0.5.11.dist-info/entry_points.txt,sha256=rDW7oZ57mqyBUS4N_3_R7bZNGVHB-104jwmY-hHC_ck,85
17
+ superset_showtime-0.5.11.dist-info/RECORD,,