Skip to content

Disable GPG Signing in Test Config #467

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

Merged
merged 1 commit into from
Apr 19, 2020
Merged

Disable GPG Signing in Test Config #467

merged 1 commit into from
Apr 19, 2020

Conversation

pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Apr 14, 2020

Your checklist for this pull request

  • Ensure all commits include DCO sign-off.
  • Ensure that your contributions pass unit testing.
  • Ensure that your contributions contain documentation if applicable.

Description

If a user has GPG signing set to true in their global .gitconfig file, the test suite will fail. This is because the test suit now includes a check of a commit message (the test_commit_with_no_verify test in tests/units/test_lib.rb that was added by #454) but did not update the test config file. This commit updates the config file to set the gpgsign option to false.

If a user has GPG signing set to true in their global .gitconfig file,
the test suite will fail. This is because the test suit now includes a
check of a commit message (the `test_commit_with_no_verify` test in
`tests/units/test_lib.rb`) but did not update the test config file. This
commit updates the config file to set the `gpgsign` option to false.

Signed-off-by: Michael Camilleri <mike@inqk.net>
@pyrmont
Copy link
Contributor Author

pyrmont commented Apr 18, 2020

@perlun @tarcinil @jcouball I'm pretty sure this PR is ready for review. Please let me know if there's anything additional I can add.

@jcouball
Copy link
Member

I tested this change and found that the test suite still fails if commit.gpgsign is set in my global config. Here are the steps I took to test:

  • Ensure that gpgsign is not set in my global config
$ git config --global --unset commit.gpgsign
  • Checkout the master branch and run bundle
$ git clone https://github.com/ruby-git/ruby-git.git ruby-git-gpgsign
...
$ cd ruby-git-gpgsign
$ bundle
...
$ 
  • Run tests to see them pass
$ bundle exec rake test
...
122 tests, 486 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
...
$ 
  • Set gpgsign to true in the global config
$ git config --global commit.gpgsign true
...
$
  • Run the tests again to see 27 errors:
$ bundle exec rake test
...
122 tests, 356 assertions, 1 failures, 27 errors, 0 pendings, 0 omissions, 0 notifications
77.0492% passed
...
$
  • checkout the PR branch
$ git fetch origin +refs/pull/467/merge
...
$ git checkout FETCH_HEAD
...
HEAD is now at e338a88 Merge 0c9cbcd9a8b352e44c4bf84bb483c6a19ee21233 into 861eb71e1c266606eefacf7ebd4bee4f34bee5de
$
  • Verify I have the right PR
$ cat tests/files/working/dot_git/config
[user]
	name = Scott Chacon
	email = schacon@gmail.com
[commit]
	gpgsign = false
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[gui]
	geometry = 986x682+365+124 211 500
[remote "working"]
	url = ../working.git
	fetch = +refs/heads/*:refs/remotes/working/*
$
  • Run the tests again to see that they all pass (they do not... there are 26 failures)
$ bundle exec rake test
...
122 tests, 358 assertions, 0 failures, 26 errors, 0 pendings, 0 omissions, 0 notifications
78.6885% passed
...
$ 

@pyrmont
Copy link
Contributor Author

pyrmont commented Apr 18, 2020

@jcouball Thanks for the quick response.

I'm not seeing the errors that you are seeing. My guess is that you're getting that result because you've enabled the commit.gpgsign option but don't have a GPG key set up. With my setup I can't cause 26 errors to occur but I can reproduce a single error if I remove the user.signingkey option from my ~/.gitconfig file:

/home/.../ruby-git/tests/units/test_tags.rb:11:in `test_tags'
/home/.../ruby-git/tests/test_helper.rb:53:in `in_temp_dir'
/home/.../ruby-git/tests/test_helper.rb:53:in `chdir'
/home/.../ruby-git/tests/test_helper.rb:54:in `block in in_temp_dir'
     25:         new_file('new_file', 'new content')
     26:       end
     27:       r1.add
  => 28:       r1.commit('my commit')
     29:       r1.add_tag('second')
     30:
     31:       assert(r1.tags.any?{|t| t.name == 'first'})
/home/.../ruby-git/tests/units/test_tags.rb:28:in `block in test_tags'
/home/.../ruby-git/lib/git/base.rb:293:in `commit'
/home/.../ruby-git/lib/git/lib.rb:575:in `commit'
/home/.../ruby-git/lib/git/lib.rb:989:in `command'
Error: test_tags(TestTags):
  Git::GitExecuteError: git '--git-dir=/tmp/git_test1587233407092/repo1/.git' '--work-tree=/tmp/git_test1587233407092/repo1' '-c' 'color.ui=false' commit '--message=my commit'  2>&1:error: gpg failed to sign the data
  fatal: failed to write commit object

That error goes away once I put the user.signingkey option back. I don't know if you want to go to the trouble of setting up a GPG key but there are instructions here on how to do so.

@jcouball
Copy link
Member

Ah, yes! Your guess was spot on. Once I set the signingkey, the errors disappeared. Thank you for the explanation.

# not a real signing key, of course :)
$ git config --global user.signingkey F2C7AB29
$ bundle exec rake test
...
122 tests, 486 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
...
$ 

Copy link
Member

@jcouball jcouball 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 your contribution! Looks good.

@jcouball jcouball merged commit b8c6320 into ruby-git:master Apr 19, 2020
@jcouball jcouball mentioned this pull request Apr 19, 2020
3 tasks
@pyrmont pyrmont deleted the bugfix.disable-gpg-signing branch April 20, 2020 02:37
@pyrmont
Copy link
Contributor Author

pyrmont commented Apr 20, 2020

@jcouball That's great! Thanks for the merge! :)

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.

2 participants