We use the Python package setuptools-git-version for a variety of Python package automation steps and it runs git describe --tags --long --dirty in order to compare the HEAD commit with the most recent tag.
With checkout@v2's default to shallow clones (a default that I agree is sensible), this no longer works, and we have to set fetch-depth: 0. This works just fine, but it would be nice if there were an option to do a shallow clone of the HEAD commit _and_ also fetch tags.
Thanks for considering.
Does this workaround work for you? https://github.com/actions/checkout/issues/217#issuecomment-636481619
My experience is that git describe does not work unless the full history is checked out since it has to traverse the git tree to get from the currently checkout out commit to the tags. If the commits in between are not checked out, then git describe can't figure out that tags are connected to the current tree.
@dlech came here with a similar problem. Using https://github.com/actions/checkout/issues/217#issuecomment-636481619 only leads to the next issue:
Run git fetch --depth=1 origin +refs/tags/*:refs/tags/*
From https://github.com/andig/evcc
* [new tag] 0.1 -> 0.1
* [new tag] 0.10 -> 0.10
...
Run make test || true
fatal: No tags can describe '55748c1c9c85ce2d9e5044d9b7d803e5b6553534'.
Try --always, or create some tags.
I'm using
- name: Fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Seems that we'd still need a _simple_ solution to fetch a "describable" history.
Setting fetch-depth: 0 seems as simple as it gets.
Setting fetch-depth: 0 seems as simple as it gets.
Sorry for the OT interruption. Came from googling and misread the issue.
I'm looking for this feature as well (the ability to git-describe the checkout), but I don't think this can be done in a shallow manner. That said, you don't need unrelated history; only the history related to the desired commit. Right now I'm using fetch-depth: 0 as a workaround, but that is a heavy hammer that is pulling in more than necessary.
The default checkout seems to do:
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +<sha>:<ref>
and I think by omitting --no-tags and --depth=1, it achieves the desired goals. (Note, that specifying --tags is not the same as omitting --no-tags.) Ie:
git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules origin +<sha>:<ref>
It would be nice if there was an easy way to configure this type of checkout.
Most helpful comment
I'm looking for this feature as well (the ability to
git-describethe checkout), but I don't think this can be done in a shallow manner. That said, you don't need unrelated history; only the history related to the desired commit. Right now I'm usingfetch-depth: 0as a workaround, but that is a heavy hammer that is pulling in more than necessary.The default checkout seems to do:
and I think by omitting
--no-tagsand--depth=1, it achieves the desired goals. (Note, that specifying--tagsis not the same as omitting--no-tags.) Ie:It would be nice if there was an easy way to configure this type of checkout.