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

Feature request: Option to shallow clone but still fetch tags #338

Open
Scotchester opened this issue Aug 25, 2020 · 7 comments
Open

Feature request: Option to shallow clone but still fetch tags #338

Scotchester opened this issue Aug 25, 2020 · 7 comments

Comments

@Scotchester
Copy link

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.

matklad added a commit to matklad/cov-mark that referenced this issue Aug 28, 2020
We need this for auto-publish.

Upstream issue: actions/checkout#338
@dlech
Copy link

dlech commented Oct 12, 2020

Does this workaround work for you? #217 (comment)

@dlech
Copy link

dlech commented Oct 12, 2020

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.

@andig
Copy link

andig commented Nov 23, 2020

@dlech came here with a similar problem. Using #217 (comment) 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.

@dlech
Copy link

dlech commented Nov 23, 2020

Setting fetch-depth: 0 seems as simple as it gets.

@andig
Copy link

andig commented Nov 23, 2020

Setting fetch-depth: 0 seems as simple as it gets.

Sorry for the OT interruption. Came from googling and misread the issue.

@devinrsmith
Copy link

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.

@RobertWieczoreck
Copy link
Contributor

RobertWieczoreck commented Sep 19, 2021

@Scotchester @devinrsmith:
I forged a pull request to fix #448, that introduces a fetch-tags option (but doesn't omit fetch-depth though): #579
Could you guys have a look if this would also "solve" this issue? Maybe it's sufficient to specify fetch-depth: 1 (default if omitted) and fetch-tags: true to only get the head commit and its tags?

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

No branches or pull requests

5 participants