Skip to content

Commit

Permalink
refactor: Change command to obtain latest tag
Browse files Browse the repository at this point in the history
We now use `git tag -l --sort=-committerdate`
instead of `git describe --tags --abbrev=0`.

In CI, in order to use `griffe check`,
we usually do not fetch the whole history.
Instead, we fetch HEAD and all tags, sparsely.
With a sparse history, `git describe` fails,
whereas `git tag` works.

This will improve support in CI.
  • Loading branch information
pawamoy committed Jul 1, 2023
1 parent 87fca69 commit f70f630
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/griffe/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def _get_latest_tag(path: str | Path) -> str:
if not path.is_dir():
path = path.parent
output = subprocess.check_output(
["git", "describe", "--tags", "--abbrev=0"],
["git", "tag", "-l", "--sort=-committerdate"],
cwd=path,
text=True,
)
return output.decode().strip()
return output.strip().split("\n", 1)[0]


def _get_repo_root(path: str | Path) -> str:
Expand Down

0 comments on commit f70f630

Please sign in to comment.