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
Use environment variables when creating signatures #6706
base: main
Are you sure you want to change the base?
Conversation
Thank you for the PR - I agree that we need this functionality. I took a quick first pass on the changes and overall, this is an excellent PR. I will take a closer look 🔜 — thanks again. |
Hi, thanks for looking into this! I am also keen on getting this functionality merged! Please let me know if you want a different approach of some specific implementation on this PR, I don't mind changing it. I am not sure I recreated 100% the CI build environment but I managed to compile with clang with similar features enabled on cmake so hopefully this time CI will pass. Cheers. |
include/git2/signature.h
Outdated
@@ -56,11 +102,13 @@ GIT_EXTERN(int) git_signature_now(git_signature **out, const char *name, const c | |||
* based on that information. It will return GIT_ENOTFOUND if either the | |||
* user.name or user.email are not set. | |||
* | |||
* @deprecated use git_signature_default_author or git_signature_default_committer instead |
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.
Let's not deprecate it per se - at least not yet - typically, we would compile that out of builds when DEPRECATE_HARD
is defined. It's usually the thing that we do before its eventual removal. Instead, let's adjust the documentation to suggest that git_signature_default_author
are probably what people actually want. We can deprecate in a future release if we think that's wise.
And it may be - but I think that there are likely a lot of people who are using this API at the moment. So let's give them some time to adjust.
A few minor tweaks requested - thanks for putting this together, I think that this is a really useful improvement. 🙏 |
When creating an action signature (e.g. for a commit author and committer) read the following environment variables that can override the configuration options: * `GIT_AUTHOR_NAME` is the human-readable name in the "author" field. * `GIT_AUTHOR_EMAIL` is the email for the "author" field. * `GIT_AUTHOR_DATE` is the timestamp used for the "author" field. * `GIT_COMMITTER_NAME` sets the human name for the "committer" field. * `GIT_COMMITTER_EMAIL` is the email address for the "committer" field. * `GIT_COMMITTER_DATE` is used for the timestamp in the "committer" field. * `EMAIL` is the fallback email address in case the user.email configuration value isn't set. If this isn't set, Git falls back to the system user and host names. This is taken from the git documentation chapter "10.8 Environment Variables": https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables This PR adds support for reading these environment variables by adding two new functions `git_signature_default_author` and `git_signature_default_committer` and deprecates the `git_signature_default` function. Fixes: libgit2#3751 Prior work: * libgit2#4409 * libgit2#5479 * libgit2#6290
Also fix some comment formatting.
42ae9fc
to
0802483
Compare
Thanks of the review @ethomson! |
The usage of environment variables should always be opt-in in libgit2 |
When creating an action signature (e.g. for a commit author and committer) read the following environment variables that can override the configuration options:
GIT_AUTHOR_NAME
is the human-readable name in the "author" field.GIT_AUTHOR_EMAIL
is the email for the "author" field.GIT_AUTHOR_DATE
is the timestamp used for the "author" field.GIT_COMMITTER_NAME
sets the human name for the "committer" field.GIT_COMMITTER_EMAIL
is the email address for the "committer" field.GIT_COMMITTER_DATE
is used for the timestamp in the "committer" field.EMAIL
is the fallback email address in case the user.email configuration value isn't set. If this isn't set, Git falls back to the system user and host names.This is taken from the git documentation chapter "10.8 Environment Variables":
https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables
This PR adds support for reading these environment variables by adding two new functions
git_signature_default_author
andgit_signature_default_committer
and deprecates thegit_signature_default
function.Fixes: #3751
Prior work: