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

Add --fetch-branches and --fetch-tags options #245

Merged
merged 1 commit into from
Apr 9, 2022

Conversation

abitmore
Copy link
Contributor

And fix --skip-fetch .

Follow-up of #238.

Features:

@devrandom please review. Thanks.

@devrandom
Copy link
Owner

Sorry for the delay, missed the notification. Will review this week.

@softminus
Copy link

softminus commented Apr 8, 2022

Hey, would you be up to reviewing this PR? The current way gitian fetches git repos causes an issue (described here) with the git describe output on more recent versions of git. git on debian buster doesn't run into this issue, but the git version on debian bullseye does, as shown below.

sasha_work@sasha-vm:~/tmp/zcash-gitian-fetch$ git init
sasha_work@sasha-vm:~/tmp/zcash-gitian-fetch$ git fetch -f --update-head-ok https://github.com/zcash/zcash v4.6.0-2:refs/tags/tobuild 
sasha_work@sasha-vm:~/tmp/zcash-gitian-fetch$ git checkout -q tobuild
sasha_work@sasha-vm:~/tmp/zcash-gitian-fetch$ git submodule update --init --recursive --force
sasha_work@sasha-vm:~/tmp/zcash-gitian-fetch$ git --version; git describe
git version 2.30.2
warning: tag 'tobuild' is externally known as 'v4.6.0-2'
v4.6.0-2-0-gac0c24cfa
sasha_work@sasha-vm:~/tmp/zcash-gitian-fetch$ ~/bin/tmp/usr/bin/git --version; ~/bin/tmp/usr/bin/git describe
git version 2.20.1
warning: tag 'v4.6.0-2' is really 'tobuild' here
v4.6.0-2
sasha_work@sasha-vm:~/tmp/zcash-gitian-fetch$ 

This causes commit hashes to end up in the zcash version string when they shouldn't be going there.

This PR's fetch commands (when run with --fetch-tags) don't run into that issue:

sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ git init
Initialized empty Git repository in /home/sasha_work/tmp/proposed-fetch-method/.git/
sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ git fetch -f --update-head-ok https://github.com/zcash/zcash +refs/tags/*:refs/tags/* 2>/dev/null 
sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ git fetch -f --update-head-ok https://github.com/zcash/zcash v4.6.0-2
From https://github.com/zcash/zcash
 * tag                   v4.6.0-2   -> FETCH_HEAD
sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ git checkout -q FETCH_HEAD
sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ git submodule update --init --recursive --force
sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ ~/bin/tmp/usr/bin/git --version; ~/bin/tmp/usr/bin/git describe
git version 2.20.1
v4.6.0-2
sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ git --version ; git describe
git version 2.30.2
v4.6.0-2
sasha_work@sasha-vm:~/tmp/proposed-fetch-method$ 

Copy link
Owner

@devrandom devrandom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the thorough test @abitmore . I think one of the issues with the existing code is that tobuild is created as a tag rather than a branch.

Your solution seems fine.

if @options[:fetch_tags]
system!("cd inputs/#{dir} && git fetch -f --update-head-ok #{sanitize_path(remote["url"], remote["url"])} +refs/tags/*:refs/tags/*")
end
system!("cd inputs/#{dir} && git fetch -f --update-head-ok #{sanitize_path(remote["url"], remote["url"])} #{commit}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noting that the --update-head-ok here is what makes FETCH_HEAD unconditionally update here. without it, FETCH_HEAD will usually be blank.

@devrandom devrandom merged commit 8af9efb into devrandom:master Apr 9, 2022
@abitmore abitmore deleted the fix-fetch branch November 2, 2022 23:11
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

Successfully merging this pull request may close these issues.

Checking out source as tobuild is not ideal
3 participants