xorpaul / g10k

my r10k fork in Go
Apache License 2.0
125 stars 50 forks source link

Support git module with both branch and ref specified #216

Open ekohl opened 1 year ago

ekohl commented 1 year ago

This is what puppetfile-updater generates and it makes sense. For reproducible builds you want to pin to a specific commit, but sometimes that's not on the default branch so it can help to specify the branch to generate the correct refspec.

I see there is an explicit test for this case (https://github.com/xorpaul/g10k/blob/master/tests/TestReadPuppetfileConflictingGitAttributesRef) so that does imply it's explicitly chose, but I'm not sure it really is invalid.

xorpaul commented 1 year ago

Hmm, are you saying specifying a commit hash can not be unique in a git repository? Because that would be news to me.

Or what do you want to archive by specifying the branch and a commit hash of a Puppet module repository?

ekohl commented 1 year ago

Hmm, are you saying specifying a commit hash can not be unique in a git repository? Because that would be news to me.

No, that's not what I'm saying

Or what do you want to archive by specifying the branch and a commit hash of a Puppet module repository?

Updating is easier: if you know it which branch it came from then you can easily check if there are new commits. A commit hash can belong to multiple branches, so it's hard to figure out.

Another thing you can consider is the fetch spec. The default is something like fetch = +refs/heads/*:refs/remotes/origin/* but if you know the branch you can use fetch = +refs/heads/master:refs/remotes/origin/master and only retrieve that single branch. That can save bandwidth and make cloning faster when there are a lot of branches.