"chef update" checks out a non-existent branch from a git repo
Description
When using a git source with a branch reference in Policyfile.rb, chef update checks out some commit from that git repository even though the upstream branch has been deleted.
ChefDK Version
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:52:16]
└─[0] <git:(3041a1f 3041a1f) > chef --version
Chef Development Kit Version: 1.3.43
chef-client version: 12.19.36
delivery version: master (dd319aa632c2f550c92a2172b9d1226478fea997)
berks version: 5.6.4
kitchen version: 1.16.0
Platform Version
Arch Linux
Replication Case
With the following in Policyfile.rb:
cookbook 'cub_shared',
git: 'ssh://[email protected]:7999/sc/cub_shared.git',
branch: 'CF-596'
Running chef update succeeds and creates the following entry in Policyfile.lock.json:
"cub_shared": {
"version": "0.1.3",
"identifier": "b413a721af9d7d677c7ff5c0ca71ae5cfe488262",
"dotted_decimal_identifier": "50687104353541501.29128811626941041.191714426389090",
"cache_key": "cub_shared-3041a1fbdab4fdbf3e92228c6438c19c7624a617",
"origin": "ssh://[email protected]:7999/sc/cub_shared.git",
"source_options": {
"git": "ssh://[email protected]:7999/sc/cub_shared.git",
"revision": "3041a1fbdab4fdbf3e92228c6438c19c7624a617",
"branch": "CF-596"
}
},
However, the referenced branch does not exist:
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:50:45]
└─[0] <git:(3041a1f 3041a1f) > git remote -v show
origin ssh://[email protected]:7999/sc/cub_shared.git (fetch)
origin ssh://[email protected]:7999/sc/cub_shared.git (push)
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:52:03]
└─[0] <git:(3041a1f 3041a1f) > git fetch -p
X11 forwarding request failed on channel 0
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:52:09]
└─[0] <git:(3041a1f 3041a1f) > git branch -r
origin/GREQ0141247
origin/HEAD -> origin/master
origin/master
I would expect Chef to emit an error that it couldn't find the CF-596 branch instead of what actually happened.
The branch CF-596 was deleted from upstream some months ago, and the commit that chef checked out, 3041a1f, is not at the tip of master, nor do any other branches or tags point to it. So it seems that Chef is caching repo metadata somewhere.
Stacktrace
n/a
This needs to be verified under the current Workstation build.