Skip to content

setup: keep gpg output out of the version string - #2356

Merged
gabrielg5 merged 1 commit into
fortra:masterfrom
qianeric-backup:fix/setup-git-version
Nov 23, 2026
Merged

gabrielg5 merged 1 commit into
fortra:masterfrom
qianeric-backup:fix/setup-git-version

Conversation

@qianeric-backup

Copy link
Copy Markdown
Contributor

What this fixes

The version suffix is built from a single git call:

p = Popen("git log -1 --format=%cd --date=format:%Y%m%d.%H%M%S", shell=True, ...)
(outstr, __) = p.communicate()
(VER_CDATE, VER_CTIME) = outstr.strip().decode("utf-8").split('.')

With log.showSignature=true in the user's git config — a setting impacket's own signed commits
invite — git writes the signature verification to stdout before the date:

gpg: Signature made 2026年11月03日 星期二 14时09分04秒 CST
gpg:                using EDDSA key 8B57947731BADB40E0E23CE537094C4532135524
gpg: Good signature from "ImpTest <imptest@example.com>"

The value no longer splits into two parts, the unpack raises, and the surrounding except
swallows it. VER_LOCAL stays empty and the package is built as 0.14.0.dev0 — no commit date, no
hash.

Fixes #1756.

The change

p = Popen("git log -1 --no-show-signature --format=%cd --date=format:%Y%m%d.%H%M%S", ...)

One flag. --no-show-signature takes precedence over log.showSignature, so the output is the
date and nothing else regardless of what the user has configured, and no other git invocation in
setup.py is affected.

Verification

I generated a throwaway GPG key, signed a commit, and set log.showSignature=true, then ran
python3 setup.py --version on the same commit:

log.showSignature before after
true 0.14.0.dev0 0.14.0.dev0+20261103.140904.ca67ba7
false 0.14.0.dev0+20261103.140904.ca67ba7 0.14.0.dev0+20261103.140904.ca67ba7
unset 0.14.0.dev0+20261103.140904.ca67ba7 0.14.0.dev0+20261103.140904.ca67ba7

Only the broken combination changes. The intermediate value, confirming the diagnosis:

>>> out.strip().decode().split('.')
3 parts          # gpg lines + date, instead of the expected 2

The test key and the signed commit were removed afterwards; nothing in the branch depends on them.

Note

This is my second PR here — #2355 (SMB2 share types) is unrelated and still open. Both are
one-bug fixes with a reproduction in the description; say the word if you would rather I space them
out.

The version suffix is built from a single git call:

    p = Popen("git log -1 --format=%cd --date=format:%Y%m%d.%H%M%S", ...)
    (VER_CDATE, VER_CTIME) = outstr.strip().decode("utf-8").split('.')

With `log.showSignature=true` in the user's git config -- the setting
impacket's own signed commits invite -- git prepends the signature
verification to stdout, so the value no longer splits into two parts and
the unpack raises. The exception is swallowed by the surrounding `except`,
leaving VER_LOCAL empty, and the package is built as `0.14.0.dev0` with no
commit information at all.

Ask git not to show the signature for this call. The dates are unaffected
and `--no-show-signature` wins over the config setting, so the suffix comes
out the same whatever the user has configured.

Verified against a signed commit with `log.showSignature=true`:

    before:  0.14.0.dev0
    after:   0.14.0.dev0+20261103.140904.ca67ba7

With the setting false or absent the value is unchanged:
`0.14.0.dev0+20261103.140904.ca67ba7` both before and after.

Fixes fortra#1756
@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Nov 4, 2026
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 22, 2026
@gabrielg5 gabrielg5 added low Low priority item and removed in review This issue or pull request is being analyzed labels Nov 23, 2026
@gabrielg5
gabrielg5 merged commit 96f92ea into fortra:master Nov 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

low Low priority item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signed commits break building and installing from git repo if log.showSignature=true in git

3 participants