-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -556,12 +556,12 @@ def username(self): | |
Something similar to 'Martin Pool <[email protected]>' | ||
$BRZ_EMAIL can be set to override this, then | ||
$BRZ_EMAIL or $BZR_EMAIL can be set to override this, then | ||
the concrete policy type is checked, and finally | ||
$EMAIL is examined. | ||
If no username can be found, NoWhoami exception is raised. | ||
""" | ||
v = os.environ.get('BRZ_EMAIL') | ||
v = os.environ.get('BRZ_EMAIL') or os.environ.get('BZR_EMAIL') | ||
if v: | ||
if not PY3: | ||
v = v.decode(osutils.get_user_encoding()) | ||
|
@@ -2546,7 +2546,7 @@ def get_help(self, key=None): | |
Option('editor', | ||
help='The command called to launch an editor to enter a message.')) | ||
option_registry.register( | ||
Option('email', override_from_env=['BRZ_EMAIL'], | ||
Option('email', override_from_env=['BRZ_EMAIL', 'BZR_EMAIL'], | ||
default=bedding.default_email, help='The users identity')) | ||
option_registry.register( | ||
Option('gpg_signing_key', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1484,6 +1484,13 @@ def test_BRZ_EMAIL_OVERRIDES(self): | |
self.assertEqual("Robert Collins <[email protected]>", | ||
my_config.username()) | ||
|
||
def test_BRZ_EMAIL_OVERRIDES(self): | ||
self.overrideEnv('BZR_EMAIL', "Robert Collins <[email protected]>") | ||
branch = FakeBranch() | ||
my_config = config.BranchConfig(branch) | ||
self.assertEqual("Robert Collins <[email protected]>", | ||
my_config.username()) | ||
|
||
def test_get_user_option_global(self): | ||
my_config = self.get_branch_config(global_config=sample_config_text) | ||
self.assertEqual('something', | ||
|
@@ -4648,8 +4655,16 @@ class EmailOptionTests(tests.TestCase): | |
|
||
def test_default_email_uses_BRZ_EMAIL(self): | ||
conf = config.MemoryStack(b'[email protected]') | ||
# BRZ_EMAIL takes precedence over EMAIL | ||
# BRZ_EMAIL takes precedence over BZR_EMAIL and EMAIL | ||
self.overrideEnv('BRZ_EMAIL', '[email protected]') | ||
self.overrideEnv('BZR_EMAIL', '[email protected]') | ||
self.overrideEnv('EMAIL', '[email protected]') | ||
self.assertEqual('[email protected]', conf.get('email')) | ||
|
||
def test_default_email_uses_BZR_EMAIL(self): | ||
conf = config.MemoryStack(b'[email protected]') | ||
# BZR_EMAIL takes precedence over EMAIL | ||
self.overrideEnv('BZR_EMAIL', '[email protected]') | ||
self.overrideEnv('EMAIL', '[email protected]') | ||
self.assertEqual('[email protected]', conf.get('email')) | ||
|
||
|