Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: CommitContextClient methods accept repository instance #87312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sentry/integrations/github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ def get_commit(self, repo: str, sha: str) -> Any:
"""
return self.get_cached(f"/repos/{repo}/commits/{sha}")

def get_merge_commit_sha_from_commit(self, repo: str, sha: str) -> str | None:
def get_merge_commit_sha_from_commit(self, repo: Repository, sha: str) -> str | None:
"""
Get the merge commit sha from a commit sha.
"""
response = self.get_pullrequest_from_commit(repo, sha)
response = self.get_pullrequest_from_commit(repo.name, sha)
if not response or (isinstance(response, list) and len(response) != 1):
# the response should return a single merged PR, return if multiple
return None
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/integrations/gitlab/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def get_commit(self, project_id, sha):
"""
return self.get_cached(GitLabApiClientPath.commit.format(project=project_id, sha=sha))

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

def compare_commits(self, project_id, start_sha, end_sha):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def queue_comment_task_if_needed(
try:
client = self.get_client()
merge_commit_sha = client.get_merge_commit_sha_from_commit(
repo=repo.name, sha=commit.key
repo=repo, sha=commit.key
)
except Exception as e:
sentry_sdk.capture_exception(e)
Expand Down Expand Up @@ -385,5 +385,5 @@ def update_comment(
raise NotImplementedError

@abstractmethod
def get_merge_commit_sha_from_commit(self, repo: str, sha: str) -> str | None:
def get_merge_commit_sha_from_commit(self, repo: Repository, sha: str) -> str | None:
raise NotImplementedError
8 changes: 2 additions & 6 deletions tests/sentry/integrations/github/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ def test_get_merge_commit_sha_from_commit(self, get_jwt):
json=pull_requests,
)

sha = self.github_client.get_merge_commit_sha_from_commit(
repo=self.repo.name, sha=commit_sha
)
sha = self.github_client.get_merge_commit_sha_from_commit(repo=self.repo, sha=commit_sha)
assert sha == merge_commit_sha

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

sha = self.github_client.get_merge_commit_sha_from_commit(
repo=self.repo.name, sha=commit_sha
)
sha = self.github_client.get_merge_commit_sha_from_commit(repo=self.repo, sha=commit_sha)
assert sha is None

@responses.activate
Expand Down
Loading