Skip to content
Merged
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
26 changes: 25 additions & 1 deletion cla-backend-go/github/github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,31 @@ func EditIssueCommentIfChanged(ctx context.Context, client *github.Client, owner
func GetPRHeadSHA(ctx context.Context, gh *github.Client, owner, repo string, prNumber int) (string, error) {
pr, _, err := gh.PullRequests.Get(ctx, owner, repo, prNumber)
if err != nil {
return "", err
f := logrus.Fields{
"functionName": "github.github_repository.GetPRHeadSHA",
"owner": owner,
"repo": repo,
"pullRequestID": prNumber,
}
log.WithFields(f).WithError(err).Warn("cannot get PR head SHA using PullRequests.Get, trying PullRequests.ListCommits")
opts := &github.ListOptions{PerPage: 1}
commits, resp, comErr := gh.PullRequests.ListCommits(ctx, owner, repo, prNumber, opts)
if comErr != nil {
log.WithFields(f).WithError(comErr).Warnf("problem listing commits for repo: %s/%s pull request: %d", owner, repo, prNumber)
return "", comErr
}
if resp != nil && resp.LastPage > 1 {
opts.Page = resp.LastPage
commits, _, comErr = gh.PullRequests.ListCommits(ctx, owner, repo, prNumber, opts)
if comErr != nil {
log.WithFields(f).WithError(comErr).Warnf("problem listing commits for repo: %s/%s pull request: %d (last page)", owner, repo, prNumber)
return "", comErr
}
}
if len(commits) == 0 || commits[0].SHA == nil {
return "", fmt.Errorf("missing head SHA for %s/%s PR #%d (via ListCommits)", owner, repo, prNumber)
}
return *commits[0].SHA, nil
}
sha := ""
if pr.Head != nil && pr.Head.SHA != nil {
Expand Down
19 changes: 16 additions & 3 deletions cla-backend/cla/models/github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2641,11 +2641,24 @@ def update_pull_request(
fn = "cla.models.github_models.update_pull_request"
notification = cla.conf["GITHUB_PR_NOTIFICATION"]
both = notification == "status+comment" or notification == "comment+status"
last_commit_sha = getattr(getattr(pull_request, "head", None), "sha", None)
cla.log.debug(f"{fn} - Updating PR {pull_request.number} with notification={notification}, both={both}")
try:
last_commit_sha = getattr(getattr(pull_request, "head", None), "sha", None)
repo = getattr(getattr(pull_request, "head", None), "repo", None)
if repo is None:
repo = getattr(getattr(pull_request, "base", None), "repo", None)
commit_obj = repo.get_commit(last_commit_sha)
except (GithubException, AttributeError, TypeError) as exc:
cla.log.error(f"{fn} - PR {pull_request.number}: exception getting head.sha: {exc}")
try:
commit_obj = pull_request.get_commits().reversed[0]
last_commit_sha = commit_obj.sha
except Exception as exc2:
cla.log.error(f"{fn} - PR {pull_request.number}: exception getting last commit from PR commits: {exc2}")
last_commit_sha = None
if not last_commit_sha:
cla.log.error(f"{fn} - PR {pull_request.number}: missing head.sha; cannot create statuses")
return
commit_obj = pull_request.base.repo.get_commit(last_commit_sha)

# Here we update the PR status by adding/updating the PR body - this is the way the EasyCLA app
# knows if it is pass/fail.
Expand Down Expand Up @@ -2814,7 +2827,7 @@ def create_commit_status(commit_obj, state, sign_url, body, context):
resp = commit_obj.create_status(state, sign_url, body, context)
cla.log.info(
f"Successfully posted status '{state}': Commit {sha} "
f"with SignUrl : {sign_url} with response: {resp}"
f"with SignUrl: {sign_url} with response: {resp}"
)
except GithubException as exc:
sha = getattr(commit_obj, "sha", "(unknown)")
Expand Down
1 change: 1 addition & 0 deletions utils/search_aws_log_group.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# STAGE=dev DEBUG=1 DTFROM='3 days ago' DTTO='2 days ago' ./utils/search_aws_log_group.sh 'cla-backend-dev-githubactivity' 'error'
# STAGE=dev DEBUG=1 DTFROM='3 days ago' DTTO='2 days ago' ./utils/search_aws_log_group.sh 'cla-backend-dev-githubactivity' 'Runtime exited with'
# STAGE=dev DEBUG=1 DTFROM='3 days ago' DTTO='2 days ago' ./utils/search_aws_log_group.sh 'cla-backend-dev-githubactivity' 'Traceback'
# STAGE=dev DEBUG=1 DTFROM='3 days ago' DTTO='2 days ago' ./utils/search_aws_log_group.sh 'cla-backend-dev-githubactivity' '---' # all
# REGION=us-east-2 STAGE=prod DEBUG=1 DTFROM='15 minutes ago' DTTO='1 second ago' ./utils/search_aws_log_group.sh 'cla-backend-go-api-v4-lambda' 'LG:api-request-path'
# REGION=us-east-1 STAGE=prod DEBUG=1 DTFROM='15 minutes ago' DTTO='1 second ago' ./utils/search_aws_log_group.sh 'cla-backend-prod-api-v3-lambda' 'LG:api-request-path'
Expand Down
Loading