- Notifications
You must be signed in to change notification settings - Fork2.5k
Use environment variables when creating signatures#6706
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 itper se - at least not yet - typically, we would compile that out of builds whenDEPRECATE_HARD
is defined. It's usually the thing that we do before its eventual removal. Instead, let's adjust the documentation to suggest thatgit_signature_default_author
are probably what peopleactually 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 andcommitter) read the following environment variables that can overridethe 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 EnvironmentVariables":https://git-scm.com/book/en/v2/Git-Internals-Environment-VariablesThis PR adds support for reading these environment variables by addingtwo new functions `git_signature_default_author` and`git_signature_default_committer` and deprecates the`git_signature_default` function.Fixes:libgit2#3751Prior work: *libgit2#4409 *libgit2#5479 *libgit2#6290
Also fix some comment formatting.
42ae9fc
to0802483
CompareThanks of the review@ethomson! |
The usage of environment variables should always be opt-in in libgit2 |
Making the various pieces that create commits automatically (eg, rebase)start paying attention to the environment variables is a Big Change.For now, this is a big change in defaults; we should treat it asbreaking. We don't move to this by default; we may add `from_env` or`honor_env` type of API surface in the future.
People who are doing a commit expect a unified timestamp betweenauthor and committer information when we're using the current timestamp.Provide a single function that returns both author and committerinformation so that they can have an identical timestamp when none isspecified in the environment.
Sorry, I've been slow to look at this. One of the things that I've found is that if you want to emulate Per@csware 's comment, I also think that switching all the behavior of the things that produce commits internally to look at the environment variables is a Big Change that would be unexpected in a small release. I would suggest that we keep the current behavior (wherein it does not honor the I'm going to push up a commit to this based on this to adjust... |
Thanks for looking at this@ethomson, I've also been busy and didn't chase this. I understand your points and they make sense! Both changes LGTM. I will have a closer look later this week and we should be able to merge this. |
Thanks - sorry to bring the chaotic energy and just push a commit on top of your branch. I appreciate you opening this PR and apologize again for the delay. |
Thanks again for the PR! |
f3518ee
intolibgit2:mainUh oh!
There was an error while loading.Please reload this page.
Withlibgit2/libgit2#6706 merged in we can nowuse libgit2 from master. Small changes were needed.This is needed in order to have stable hashes for e2e tests.Previously we needed to use a patched version from:https://github.com/u-quark/libgit2/commits/gg
I just had some time to look into this. This is great! Works for me like a charm! Thanks for merging this and sorry again for the late response. |
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: