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

Convert empty git refs to 'HEAD' (Fixes #2992) #3003

Merged
merged 1 commit into from
Jul 16, 2018

Conversation

tjd2002
Copy link
Contributor

@tjd2002 tjd2002 commented Jul 5, 2018

As discussed at #2992, if an empty git_rev line is included in a meta.yaml file, then conda-build may build from a stale git commit in the cache (rather than the cache being updated to the current HEAD).

This is because an empty line results in the Source_dict.git_rev key containing an empty dict, which does not get replaced with the default value ('HEAD') when returned with dict.get. Then that empty dict value causes get_mirror_checkout_recursive to skip the logic it has to update the local cache's HEAD (since it assumes any value other than 'HEAD' is a specific commit).

The two fixes here are currently redundant (either one would prevent the bug seen in #2992), but they both seem reasonable to me.

Thanks to @stuarteberg for suggestions.

@tjd2002
Copy link
Contributor Author

tjd2002 commented Jul 5, 2018

The CI tests that fail here seem to be the same ones currently failing in master.

I'm not sure the best place for a regression test for this fix, however the following steps trigger the bug in conda-build 3.10.9 (with conda 4.6.0a2):

mkdir issue-2992 issue-2992-buildroot
cd issue-2992
git init
printf "package:\n  name: cb2992\nsource:\n  git_url: .\n  git_rev:\n" > meta.yaml
git add meta.yaml
git commit -m "commit #1 (on master)"
conda-build --croot ../issue2992-buildroot meta.yaml # builds from master #1
git commit -m "commit #2 (on master)"
conda-build --croot ../issue2992-buildroot meta.yaml # builds from master #2
git checkout -b "new-branch"
git commit --allow-empty -m "commit #3 (on new-branch)"
conda-build meta.yaml # builds from commit #2 <--ERROR: should be #3 on new-branch
# deleting git cache fixes
rm -rf ../issue2992-buildroot/git_cache
conda-build meta.yaml # builds from commit #3 <--FIXED; builds from new-branch

(It seems like conda_build will update if HEAD is on the same branch, but if you switch to another branch after the initial build it won't follow.)

@msarahan
Copy link
Contributor

Thanks! Merging.

@msarahan msarahan merged commit e5197ae into conda:master Jul 16, 2018
@github-actions
Copy link

Hi there, thank you for your contribution!

This pull request has been automatically locked because it has not had recent activity after being closed.

Please open a new issue or pull request if needed.

Thanks!

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Apr 20, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants