Skip to content

Commit 8bd62c7

Browse files
committed
ref: CommitContextClient.get_merge_commit_sha_from_commit accepts repository instance
1 parent b296710 commit 8bd62c7

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

src/sentry/integrations/github/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ def get_commit(self, repo: str, sha: str) -> Any:
227227
"""
228228
return self.get_cached(f"/repos/{repo}/commits/{sha}")
229229

230-
def get_merge_commit_sha_from_commit(self, repo: str, sha: str) -> str | None:
230+
def get_merge_commit_sha_from_commit(self, repo: Repository, sha: str) -> str | None:
231231
"""
232232
Get the merge commit sha from a commit sha.
233233
"""
234-
response = self.get_pullrequest_from_commit(repo, sha)
234+
response = self.get_pullrequest_from_commit(repo.name, sha)
235235
if not response or (isinstance(response, list) and len(response) != 1):
236236
# the response should return a single merged PR, return if multiple
237237
return None

src/sentry/integrations/gitlab/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def get_commit(self, project_id, sha):
309309
"""
310310
return self.get_cached(GitLabApiClientPath.commit.format(project=project_id, sha=sha))
311311

312-
def get_merge_commit_sha_from_commit(self, repo: str, sha: str) -> str | None:
312+
def get_merge_commit_sha_from_commit(self, repo: Repository, sha: str) -> str | None:
313313
raise IntegrationFeatureNotImplementedError
314314

315315
def compare_commits(self, project_id, start_sha, end_sha):

src/sentry/integrations/source_code_management/commit_context.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def queue_comment_task_if_needed(
190190
try:
191191
client = self.get_client()
192192
merge_commit_sha = client.get_merge_commit_sha_from_commit(
193-
repo=repo.name, sha=commit.key
193+
repo=repo, sha=commit.key
194194
)
195195
except Exception as e:
196196
sentry_sdk.capture_exception(e)
@@ -385,5 +385,5 @@ def update_comment(
385385
raise NotImplementedError
386386

387387
@abstractmethod
388-
def get_merge_commit_sha_from_commit(self, repo: str, sha: str) -> str | None:
388+
def get_merge_commit_sha_from_commit(self, repo: Repository, sha: str) -> str | None:
389389
raise NotImplementedError

tests/sentry/integrations/github/test_client.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,7 @@ def test_get_merge_commit_sha_from_commit(self, get_jwt):
364364
json=pull_requests,
365365
)
366366

367-
sha = self.github_client.get_merge_commit_sha_from_commit(
368-
repo=self.repo.name, sha=commit_sha
369-
)
367+
sha = self.github_client.get_merge_commit_sha_from_commit(repo=self.repo, sha=commit_sha)
370368
assert sha == merge_commit_sha
371369

372370
@mock.patch("sentry.integrations.github.client.get_jwt", return_value="jwt_token_1")
@@ -381,9 +379,7 @@ def test_get_merge_commit_sha_from_commit_open_pr(self, get_jwt):
381379
json=pull_requests,
382380
)
383381

384-
sha = self.github_client.get_merge_commit_sha_from_commit(
385-
repo=self.repo.name, sha=commit_sha
386-
)
382+
sha = self.github_client.get_merge_commit_sha_from_commit(repo=self.repo, sha=commit_sha)
387383
assert sha is None
388384

389385
@responses.activate

0 commit comments

Comments
 (0)