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

Improve logging of commit information #58

Merged
merged 1 commit into from
Apr 5, 2019
Merged

Conversation

bluekeyes
Copy link
Member

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.

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()
Copy link
Member Author

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,
Copy link
Contributor

@jamestoyer jamestoyer Apr 5, 2019

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

Copy link
Member Author

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.

Copy link
Contributor

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

@bluekeyes bluekeyes merged commit f3ea4a3 into develop Apr 5, 2019
@bluekeyes bluekeyes deleted the bkeyes/commit-logging branch April 5, 2019 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants