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

g10k not stopping on wrong :commit #91

Closed
chutzimir opened this issue Feb 8, 2018 · 3 comments
Closed

g10k not stopping on wrong :commit #91

chutzimir opened this issue Feb 8, 2018 · 3 comments

Comments

@chutzimir
Copy link
Contributor

Steps to reproduce:

$ cat > Puppetfile <<EOF
mod 'stdlib',
  :git    => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
  :commit => '0000000000000000000000000000000000000000'
EOF

$ g10k -puppetfile -debug
2018/02/08 20:01:55 DEBUG main(): Trying to use as Puppetfile: ./Puppetfile
2018/02/08 20:01:55 DEBUG checkDirAndCreate(): Using as cachedir default value: /tmp/g10k/
2018/02/08 20:01:55 DEBUG readPuppetfile(): Trying to parse: ./Puppetfile
2018/02/08 20:01:55 DEBUG preparePuppetfile(): adding line:mod 'stdlib',
2018/02/08 20:01:55 DEBUG preparePuppetfile(): adding line::git    => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
2018/02/08 20:01:55 DEBUG preparePuppetfile(): adding line::commit => '0000000000000000000000000000000000000000'
2018/02/08 20:01:55 DEBUG readPuppetfile(): Setting moduledir for Puppetfile ./Puppetfile to modules
2018/02/08 20:01:55 DEBUG resolvePuppetfile(): Resolving cmdlineparam
2018/02/08 20:01:55 DEBUG resolveForgeModules(): empty ForgeModule[] found, skipping...
2018/02/08 20:01:55 DEBUG timeTrack(): resolveForgeModules() took 0.00001s
2018/02/08 20:01:55 DEBUG resolveGitRepositories(): Resolving 1 Git modules with 50 workers
2018/02/08 20:01:55 DEBUG resolveGitRepositories(): git repo url https://github.com/puppetlabs/puppetlabs-stdlib.git
2018/02/08 20:01:55 DEBUG git repo url https://github.com/puppetlabs/puppetlabs-stdlib.git without ssh key
2018/02/08 20:01:55 DEBUG executeCommand(): Executing git clone --mirror https://github.com/puppetlabs/puppetlabs-stdlib.git /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git
2018/02/08 20:01:58 Executing git clone --mirror https://github.com/puppetlabs/puppetlabs-stdlib.git /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git took 3.47622s
2018/02/08 20:01:58 DEBUG timeTrack(): resolveGitRepositories() took 3.47632s
2018/02/08 20:01:58 DEBUG resolvePuppetfile(): Syncing cmdlineparam with workDir .
2018/02/08 20:01:58 DEBUG checkDirAndCreate(): Using as basedir 2 for source cmdlineparam: ./
2018/02/08 20:01:58 DEBUG checkDirAndCreate(): Using as moduleDir for cmdlineparam: ./modules/
2018/02/08 20:01:58 DEBUG executeCommand(): Executing git --git-dir /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git rev-parse --verify '0000000000000000000000000000000000000000'
2018/02/08 20:01:58 Executing git --git-dir /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git rev-parse --verify '0000000000000000000000000000000000000000' took 0.00189s
Need to sync ./modules/stdlib/
2018/02/08 20:01:58 DEBUG createOrPurgeDir(): Trying to create dir: ./modules/stdlib/ called from syncToModuleDir()
2018/02/08 20:01:58 DEBUG syncToModuleDir(): Executing git --git-dir /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git archive 0000000000000000000000000000000000000000
2018/02/08 20:01:58 syncToModuleDir(): Executing git --git-dir /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git archive 0000000000000000000000000000000000000000 took 0.00158s
2018/02/08 20:01:58 DEBUG executeCommand(): Executing git --git-dir /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git rev-parse --verify '0000000000000000000000000000000000000000'
2018/02/08 20:01:58 Executing git --git-dir /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git rev-parse --verify '0000000000000000000000000000000000000000' took 0.00177s
2018/02/08 20:01:58 DEBUG syncToModuleDir(): Writing hash 0000000000000000000000000000000000000000
 from command git --git-dir /tmp/g10k/https-__github.com_puppetlabs_puppetlabs-stdlib.git rev-parse --verify '0000000000000000000000000000000000000000' to ./modules/stdlib//.latest_commit
2018/02/08 20:01:58 DEBUG main(): Forge response JSON parsing took 0.0000 seconds
2018/02/08 20:01:58 DEBUG main(): Forge modules metadata.json parsing took 0.0000 seconds
Synced ./Puppetfile with 1 git repositories and 0 Forge modules in 3.5s with git (3.5s sync, I/O 0.0s) and Forge (0.0s query+download, I/O 0.0s) using 50 resolv and 20 extract workers

$ echo $?
0

$ find
.
./modules
./modules/stdlib
./modules/stdlib/.latest_commit
./Puppetfile

$ cat modules/stdlib/.latest_commit
0000000000000000000000000000000000000000

I was expecting the g10k command to fail.

chutzimir added a commit to chutzimir/g10k that referenced this issue Feb 8, 2018
`git rev-parse --verify` would not throw an error if the input "looks"
like a commit id, e.g. it is 40 hexadecimal characters. Therefore, check
that `git archive` exited with no errors.

Fixes xorpaul#91
@xorpaul
Copy link
Owner

xorpaul commented Feb 8, 2018

Yeah, and g10k is expecting git rev-parse --verify to fail. 😏

@xorpaul
Copy link
Owner

xorpaul commented Feb 8, 2018

Hmm, I could also adjust the parameter to check for really existing objects and not accept commit-ish looking parameters. Taken from the git-rev-parse(1) man page:

$ git --git-dir tmp/modules/https-__github.com_puppetlabs_puppetlabs-apache.git rev-parse --verify "e587f2af793111adab04bb776808f99a09ca092b^{object}"   
e587f2af793111adab04bb776808f99a09ca092b
$ git --git-dir tmp/modules/https-__github.com_puppetlabs_puppetlabs-apache.git rev-parse --verify "0000000000000000000000000000000000000000^{object}"   
fatal: Needed a single revision                      
$ git --git-dir tmp/modules/https-__github.com_puppetlabs_puppetlabs-apache.git rev-parse --verify "master^{object}"                                     
e587f2af793111adab04bb776808f99a09ca092b             
$ git --git-dir tmp/modules/https-__github.com_puppetlabs_puppetlabs-apache.git rev-parse --verify "641576a137a6d1b401510308dda462f076c1559d^{object}"   
641576a137a6d1b401510308dda462f076c1559d             
$ git --git-dir tmp/modules/https-__github.com_puppetlabs_puppetlabs-apache.git rev-parse --verify "release^{object}"                                    
3e399f6e74acf0f80c7ad84217faea281e7a272e 

@xorpaul
Copy link
Owner

xorpaul commented Feb 12, 2018

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

2 participants