-
Notifications
You must be signed in to change notification settings - Fork 103
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
Improve logging of commit information #58
Conversation
Attach the head SHA of the pull request being evaluated to log messages, log when candidates are removed due to a pushed commit, and log the target ref when posting a commit status.
func (b *Base) PreparePRContext(ctx context.Context, installationID int64, pr *github.PullRequest) (context.Context, zerolog.Logger) { | ||
ctx, logger := githubapp.PreparePRContext(ctx, installationID, pr.GetBase().GetRepo(), pr.GetNumber()) | ||
|
||
logger = logger.With().Str("github_sha", pr.GetHead().GetSHA()).Logger() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to put this here instead of in githubapp
because there are situations when you might take action in response to a PR event that have nothing to do with the current SHA. It's also unclear if you would always want to log the head SHA.
|
||
log.Debug().Msgf("discarded %d candidates invalidated by push of %s at %s", | ||
len(candidates)-len(allowedCandidates), | ||
lastCommit.SHA, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the full SHA of the commit or just substring of it? If it's the former, do we need to have the full SHA? May places like GitHub use the first 7-8 characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the full SHA: it comes from the API, which I believe only returns full values. Since this is for debugging, I don't mind having the full value, even if it makes the message longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, makes sense in this case
Attach the head SHA of the pull request being evaluated to log messages,
log when candidates are removed due to a pushed commit, and log the
target ref when posting a commit status.