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

Credit "approved-by" on merge commit #116

Open
bertptrs opened this issue Jun 7, 2022 · 2 comments
Open

Credit "approved-by" on merge commit #116

bertptrs opened this issue Jun 7, 2022 · 2 comments
Labels
good first issue Good for newcomers

Comments

@bertptrs
Copy link

bertptrs commented Jun 7, 2022

Right now hoff will "own" the commit it merges a PR with. Bors does this slightly better, by setting the PR's authors as co-authors for the merge commit. I think we can do even better, by setting the approver as the commit author.

Doing so makes more sense, as the approver is either the real author of the PR, or whomever decided this needs to be merged and deployed, and having them as an author would provide some useful metadata.

@bertptrs bertptrs added the good first issue Good for newcomers label Jun 7, 2022
@ruuda
Copy link

ruuda commented Jun 7, 2022

Hoff currently does not know the correct full name and e-mail address to use for such commits. You can get a name from the GitHub profile, but it might not be the name that you want to use (many people leave the name blank or use a pseudonym on GitHub, but use their real name for internal repositories). As far as I am aware, it is not possible to retrieve the e-mail addresses for a user unless you are authenticated as that user. You could use the {user_id}+{username}@user.noreply.github.com mail and then fix it in the .mailmap, but .mailmap is not that widely respected.

@DanielNoord
Copy link

What might work is using the List commits API. You have the approvers login so you can provide author. You could then iterate over the commits and look up the most recently used email address. See for example:
https://api.github.com/repos/channable/hoff/commits?author=ruuda

You could even scan for co-authors and their email in the message field although that might be way too much. See:
https://api.github.com/repos/danielnoord/pydocstringformatter/commits/b824fee406aae219a06fa21a78c8da98c8097d0f
Taken from my own project since I couldn't quickly find a co-authored commit in this project.
However, you would need to iterate over all commits in the repo then as you can't request a list of commits co-authored by a specific Github account. I'm not sure how performant that would be when (for example) a senior who only approves without committing/coding themselves has last made a commit two years ago.

Obviously you would need to handle the case where the approver doesn't have any commits in the repository but it might be better than not doing anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants