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

fix(git): get commit sha of git commit from annotated tags #1948

merged 3 commits into from Feb 21, 2020


Copy link

@jrmlhermitte jrmlhermitte commented Jan 26, 2020


This is an attempt to close #1916. I think all we need to do is make sure that the revision always points to the SHA of the commit in question and not the SHA of the tag object.
There is a question on stackoverflow here about this, where a few solutions are listed.
I chose the command git rev-list TAG --max-count=1

Testing and Documentation

I have tested this on a regular tag and annotated tag at the command line and they both pointed to the right corresponding commit hash. However, I have not tested this by running poetry itself.

For the tests, I am not sure how to test this other than generating a fake git repo and creating commits. Let me know if you would prefer that and I'll try to find out how to do it.
For the documentation, I left a comment by the call to explain the purpose of this command. It's not ideal, but I can't think of where else to put documentation.

@jrmlhermitte jrmlhermitte requested a review from finswimmer Jan 26, 2020
@jrmlhermitte jrmlhermitte changed the title Julien fix gitrevtag fix(git): get commit sha of git commit from annotated tags Jan 26, 2020
Copy link
Contributor Author

@jrmlhermitte jrmlhermitte commented Jan 28, 2020

@bibz could you also maybe weigh in? thanks!

@finswimmer finswimmer added the Bug label Jan 28, 2020
Copy link

@bibz bibz commented Jan 30, 2020

@jrmlhermitte What do you think of using git rev-parse TAG^{commit} instead?
The command does not change but we specifically ask git to provide us the revision to a commit, not any object.

As to how to test, I do not have any other idea to offer.

Copy link
Contributor Author

@jrmlhermitte jrmlhermitte commented Jan 31, 2020

@bibz good idea. My git knowledge is not great. This is a much better change, thanks!

Copy link
Contributor Author

@jrmlhermitte jrmlhermitte commented Feb 14, 2020

Is it okay to keep this as is or should I add more tests? I right now didn't intend on adding any but I can (will take some extra time). Thanks!

Copy link

@sdispater sdispater left a comment

Looks good to me 👍

Thanks for your contribution!

@sdispater sdispater merged commit 8bbf311 into python-poetry:master Feb 21, 2020
16 checks passed
Copy link
Contributor Author

@jrmlhermitte jrmlhermitte commented Feb 22, 2020

Great, and thank you for this great library! I think it's the only one with proper version management! :-)

sdispater added a commit that referenced this issue Mar 20, 2020
* Fix Github actions cache issues (#1908)

* Fix case of `-f` flag

* Make it clearer what options to pass to `--format`

* fix (masonry.api): `get_requires_for_build_wheel` must return additional list of requirements for building a package, not listed in `pyproject.toml` and not dependencies for the package itself (#1875)

fix (tests): adopted tests

* Lazy Keyring intialization for PasswordManager (#1892)

* Fix Github Actions cache issues (#1928)

* Avoid nested quantifiers with overlapping character space on git url parsing (#1902 (#1913)

* fix (git): match for `\w` instead of `.` for getting user

* change (vcs.git): hold pattern of the regex parts in a dictionary to be consistent over all regexs

* new (vcs.git): test for `parse_url` and some fixes for the regex pattern

* new (vcs.git): test for `parse_url` with string that should fail

* fix (test.vcs.git): make flake8 happy

* fix: correct parsing of wheel version with regex. (#1932)

The previous regexp was only taking the first integer of the version number,
this presented problems when the major version number reached double digits.

Poetry would determine that the version of the dependency is '1', rather than,
ie: '14'. This caused failures to solve versions.

* Fix errors when using the --help option (#1910)

* Fix how repository credentials are retrieved from env vars (#1909)

# Conflicts:
#	poetry/utils/

* Fix downloading packages from Simplepypi (#1851)

* fix downloading packages from simplepypi

* unused code removed

* remove unused imports

* Upgrade dependencies for the 1.0.3 release (#1965)

* Bump version to 1.0.3 (#1966)

* Fix non-compliant Git URL matching

RFC 3986 § 2.3 permits more characters in a URL than were matched. This
corrects that, though there may be other deficiencies. This was a
regression from v1.0.2, where at least “.” was matched without error.

* Update "Updating Poetry"

Currently the note in "Updating Poetry" is different from the one below in "Enable tab completion for Bash, Fish, or Zsh". This MR is to make them more consistent.

* init: change dev dependency prompt

* Fix CI issues (#2069)

* fix (setup_reader): check if `func.value` has attr `id` (#2041)

* fix(git): get commit sha of git commit from annotated tags (#1948)

* fix(git): have annotated tags resolve to the commit sha

* fix(git): fix quote

* fix(git): change to rev-parse

* fix: use correct badge on README (#2065)

* Fix #1791: Load repository URL from config (#2061)

* Fix #1791: Load repository URL from config

* Ran black to fix linting errors

* Add test for repo URL env variable

* Changed schema to support url in multi dependencies (#2035)

* Fix handling of forward slashes and url encoding in credentials (#1911)

* Add support for forward slashes and url encoding in credentials

* Remove extra newline

* Remove unquote

* Bump actions/checkout from v1 to v2 (#2075)

* Update release.yml

* Update main.yml

* Fix vendor package as installed package (#1883) (#1981)

* Fix vendor package as installed package (#1883)

* import from

Co-Authored-By: Sébastien Eustace <>

* test vendor package as installed

* refactor

* remove blank line

Co-authored-by: Sébastien Eustace <>

* fix(utils.env): import cli_run from virtualenv (#2096)

* fix(utils.env): import cli_run from virtualenv if create_environment import failes

* fix (utils.env): added accidentally removed code

* list .venv when it exists (#1762)

* list .venv when it exists

* only list when in-project is true

* missing config

* move logic to manager.list

* Add .venv when it exists

* fix: exclude subpackage from `` if `` is excluded (#1009) (#1626)

* fix: exclude subpackage from `` if `` is excluded

Fixes: #1009

* fix: added missing test data

* fix: lint test data

* change (sdist.git): exclude folders with no python file

* fix (sdist.git): make black happy

* get_vcs starts searching git folder from tmp dir instead of project (#1946) (#1947)

* fix (builder): take `self._original_path` if available to find `.git` folder

* change (vcs): use `git rev-parse --show-toplevel` to find git root folder

* fix (vcs): change back to original working dir after finding vcs

* change (builder): introduce self._original_path to keep original path
if(vcs): resolve directory for `get_vcs`

* Normalize author name unicode before matching (#2006)

* Fix accented characters not being matched in author name

Fixes #2004

* Normalized the strings instead of modifying the pattern

* Applied isort & black

* Fix the url used for installation when fallbacking on PyPI (#2099)

* Upgrade dependencies before the 1.0.4 release (#2100)

* Upgrade dependencies before the 1.0.4 release (#2103)

* Release 1.0.4 (#2101)

* Update release script

* Bump version to 1.0.4

* Fix release script (#2104)

* Fix VCS when git is not in PATH

* Upgrade dependencies before the 1.0.5 release (#2111)

* Bump version to 1.0.5 (#2112)

* Fix GitHub URL for black

Black is now officially supported by the Python Software Foundation

* Update* Fix markdown formatting* Update link to official website FAQ

* Update

Co-authored-by: brandonaut <>
Co-authored-by: finswimmer <>
Co-authored-by: Yannick PÉROUX <>
Co-authored-by: Edward George <>
Co-authored-by: Jan Škoda <>
Co-authored-by: Andrew Marshall <>
Co-authored-by: Andrew Selzer <>
Co-authored-by: Andriy Maletsky <>
Co-authored-by: Julien Lhermitte <>
Co-authored-by: Michael Aquilina <>
Co-authored-by: Joshua Cannon <>
Co-authored-by: László Velinszky <>
Co-authored-by: Lu Zhu <>
Co-authored-by: BSKY <>
Co-authored-by: Trim21 <>
Co-authored-by: Frost Ming <>
Co-authored-by: Raphael Yancey <>
Co-authored-by: adisbladis <>
Co-authored-by: Dimitri Merejkowsky <>
Co-authored-by: Jules Chéron <>
Co-authored-by: Alex Povel <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

4 participants