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

porcelain: 'abbrev' parameter is ignored when describing tagless repositories #1477

Open
jayaddison opened this issue Jan 12, 2025 · 0 comments · May be fixed by #1482
Open

porcelain: 'abbrev' parameter is ignored when describing tagless repositories #1477

jayaddison opened this issue Jan 12, 2025 · 0 comments · May be fixed by #1482

Comments

@jayaddison
Copy link

Hello,

This may be a known/expected behaviour, based on the logic and todo comment, but I thought it'd be worth reporting since it has surprised me once or twice, and I don't find existing bugreports about it.

When running porcelain.describe on a repository that contains no annotated git tags, the abbrev argument (prefix-length to return from the git commit ID) appears to be ignored and the output includes a commit prefix length of 7 (the default).

For example, to replicate this:

$ git clone https://github.com/jelmer/dulwich/ && cd dulwich
$ for tag in $(git tag -l); do git tag --delete ${tag}; done;
$ PYTHONPATH=. python3
Python 3.12.8 (main, Dec 13 2024, 13:19:48) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dulwich import porcelain
>>> porcelain.describe(".", abbrev=10)
'g77c2d8d'

When an annotated tag exists in the history, a correctly-abbreviated commit prefix is produced (along with the expected contextual formatting describing the tag it relates to).

$ git tag testing a029d7b2cc83c26a53d8b2a24fa12c340fcfac59 --annotate --message "Archaeology Today"
$ PYTHONPATH=. python3
Python 3.12.8 (main, Dec 13 2024, 13:19:48) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dulwich import porcelain
>>> porcelain.describe(".", abbrev=10)
'testing-4746-g77c2d8d106'

Would it be acceptable to offer a patch to pass the abbrev parameter to the find_unique_abbrev method, even if the todo task isn't completed as part of that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant