Message ID | 20241219-b4-pks-git-version-via-environment-v1-2-9393af058240@pks.im (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | GIT-VERSION-GEN: fix overriding values | expand |
On Thu, Dec 19, 2024 at 7:55 AM Patrick Steinhardt <ps@pks.im> wrote: > > Same as with the preceding commit, neither GIT_BUILT_FROM_COMMIT nor > GIT_DATE can be overridden via the environment. Especially the latter is > of importance given that we set it in our own "Documentation/doc-diff" > script. > > Make the values of both variables overridable. > > Signed-off-by: Patrick Steinhardt <ps@pks.im> > --- > GIT-VERSION-GEN | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) Looks good, thanks for fixing this and for all the work done on the cleanups for the build system changes. > > diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN > index 787c6cfd04f0a43d0c1c8a6690185d26ccf2fc2f..f8367f6d09ff2ada8868e575d6ec8f1f9b27534d 100755 > --- a/GIT-VERSION-GEN > +++ b/GIT-VERSION-GEN > @@ -53,10 +53,18 @@ then > else > VN="$DEF_VER" > fi > - > GIT_VERSION=$(expr "$VN" : v*'\(.*\)') > -GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) > -GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) > + > +if test -z "$GIT_BUILT_FROM_COMMIT" > +then > + GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) > +fi > + > +if test -z "$GIT_DATE" > +then > + GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) > +fi > + > if test -z "$GIT_USER_AGENT" > then > GIT_USER_AGENT="git/$GIT_VERSION" > > -- > 2.47.0 >
Kyle Lippincott <spectral@google.com> writes: > On Thu, Dec 19, 2024 at 7:55 AM Patrick Steinhardt <ps@pks.im> wrote: >> >> Same as with the preceding commit, neither GIT_BUILT_FROM_COMMIT nor >> GIT_DATE can be overridden via the environment. Especially the latter is >> of importance given that we set it in our own "Documentation/doc-diff" >> script. >> >> Make the values of both variables overridable. >> >> Signed-off-by: Patrick Steinhardt <ps@pks.im> >> --- >> GIT-VERSION-GEN | 14 +++++++++++--- >> 1 file changed, 11 insertions(+), 3 deletions(-) > > Looks good, thanks for fixing this and for all the work done on the > cleanups for the build system changes. Thanks, all.
On Thu, Dec 19, 2024 at 04:53:37PM +0100, Patrick Steinhardt wrote: > GIT_VERSION=$(expr "$VN" : v*'\(.*\)') > -GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) > -GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) > + > +if test -z "$GIT_BUILT_FROM_COMMIT" > +then > + GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) > +fi > + > +if test -z "$GIT_DATE" > +then > + GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) > +fi Looks good. I doubt anybody would want to override BUILT_FROM_COMMIT (and it was never possible to do so, even before your recent patches), but it's reasonable to include it as well. -Peff
Jeff King <peff@peff.net> writes: > On Thu, Dec 19, 2024 at 04:53:37PM +0100, Patrick Steinhardt wrote: > >> GIT_VERSION=$(expr "$VN" : v*'\(.*\)') >> -GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) >> -GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) >> + >> +if test -z "$GIT_BUILT_FROM_COMMIT" >> +then >> + GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) >> +fi >> + >> +if test -z "$GIT_DATE" >> +then >> + GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) >> +fi > > Looks good. I doubt anybody would want to override BUILT_FROM_COMMIT > (and it was never possible to do so, even before your recent patches), > but it's reasonable to include it as well. Thanks, both.
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 787c6cfd04f0a43d0c1c8a6690185d26ccf2fc2f..f8367f6d09ff2ada8868e575d6ec8f1f9b27534d 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -53,10 +53,18 @@ then else VN="$DEF_VER" fi - GIT_VERSION=$(expr "$VN" : v*'\(.*\)') -GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) -GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) + +if test -z "$GIT_BUILT_FROM_COMMIT" +then + GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) +fi + +if test -z "$GIT_DATE" +then + GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) +fi + if test -z "$GIT_USER_AGENT" then GIT_USER_AGENT="git/$GIT_VERSION"
Same as with the preceding commit, neither GIT_BUILT_FROM_COMMIT nor GIT_DATE can be overridden via the environment. Especially the latter is of importance given that we set it in our own "Documentation/doc-diff" script. Make the values of both variables overridable. Signed-off-by: Patrick Steinhardt <ps@pks.im> --- GIT-VERSION-GEN | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)