Rev 6375: Fix gpg_signing_ket default values handling in file:///home/vila/src/bzr/bugs/904550-default-gpg-key/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Dec 15 08:23:05 UTC 2011
At file:///home/vila/src/bzr/bugs/904550-default-gpg-key/
------------------------------------------------------------
revno: 6375
revision-id: v.ladeuil+lp at free.fr-20111215082305-4bdo7z8e1wlk5wdh
parent: v.ladeuil+lp at free.fr-20111215080938-e5fz674dka1c93m9
fixes bug: https://launchpad.net/bugs/904550
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 904550-default-gpg-key
timestamp: Thu 2011-12-15 09:23:05 +0100
message:
Fix gpg_signing_ket default values handling
-------------- next part --------------
=== modified file 'bzrlib/gpg.py'
--- a/bzrlib/gpg.py 2011-12-15 08:09:38 +0000
+++ b/bzrlib/gpg.py 2011-12-15 08:23:05 +0000
@@ -27,7 +27,7 @@
import subprocess
from bzrlib import (
- config as _mod_config,
+ config,
errors,
trace,
ui,
@@ -183,8 +183,8 @@
def _command_line(self):
key = self._config_stack.get('gpg_signing_key')
- if key is None:
- key = _mod_config.extract_email_address(self._config_stack.get('email'))
+ if key is None or key == 'default':
+ key = config.extract_email_address(self._config_stack.get('email'))
return [self._config_stack.get('gpg_signing_command'), '--clearsign',
'-u', key]
=== modified file 'bzrlib/tests/test_gpg.py'
--- a/bzrlib/tests/test_gpg.py 2011-12-15 07:53:13 +0000
+++ b/bzrlib/tests/test_gpg.py 2011-12-15 08:23:05 +0000
@@ -36,11 +36,13 @@
class FakeConfig(config.Stack):
- def __init__(self):
+ def __init__(self, content=None):
store = config.IniFileStore()
- store._load_from_string('''
+ if content is None:
+ content = '''
gpg_signing_key=amy at example.com
-gpg_signing_command=false''')
+gpg_signing_command=false'''
+ store._load_from_string(content)
super(FakeConfig, self).__init__([store.get_sections])
@@ -54,6 +56,23 @@
self.assertEqual(['false', '--clearsign', '-u', 'amy at example.com'],
self.my_gpg._command_line())
+ def test_signing_command_line_from_default(self):
+ # Using 'default' for gpg_signing_key will use the mail part of 'email'
+ my_gpg = gpg.GPGStrategy(FakeConfig('''
+email=Amy <amy at example.com>
+gpg_signing_key=default
+gpg_signing_command=false'''))
+ self.assertEqual(['false', '--clearsign', '-u', 'amy at example.com'],
+ my_gpg._command_line())
+
+ def test_signing_command_line_from_email(self):
+ # Not setting gpg_signing_key will use the mail part of 'email'
+ my_gpg = gpg.GPGStrategy(FakeConfig('''
+email=Amy <amy at example.com>
+gpg_signing_command=false'''))
+ self.assertEqual(['false', '--clearsign', '-u', 'amy at example.com'],
+ my_gpg._command_line())
+
def test_checks_return_code(self):
# This test needs a unix like platform - one with 'false' to run.
# if you have one, please make this work :)
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-12-14 21:50:54 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-12-15 08:23:05 +0000
@@ -59,6 +59,10 @@
* Properly ignore '\n' in an option reference since this cannot be part of a
config option identifier. (Vincent Ladeuil, #902125)
+* Not setting ``gpg_signing_key`` or setting it to ``default`` will use the
+ user email (obtained from the ``email`` configuration option or its
+ default value). (Vincent Ladeuil, Jelmer Vernooij, #904550)
+
Documentation
*************
More information about the bazaar-commits
mailing list