Skip to content

Commit 0898907

Browse files
Athos RibeiroByron
authored andcommitted
Fix default actor name handling
In c96476b, the new default_name nested function does not contain a retun statement. This leads to an issue when the environment variables are not present, where the actor name would not be set. Signed-off-by: Athos Ribeiro <athos@redhat.com>
1 parent e30a597 commit 0898907

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

git/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ def default_email():
591591
return user_id
592592

593593
def default_name():
594-
default_email().split('@')[0]
594+
return default_email().split('@')[0]
595595

596596
for attr, evar, cvar, default in (('name', env_name, cls.conf_name, default_name),
597597
('email', env_email, cls.conf_email, default_email)):

test/test_util.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,25 @@ def test_actor_get_uid_laziness_not_called(self, mock_get_uid):
226226
}
227227
os.environ.update(env)
228228
for cr in (None, self.rorepo.config_reader()):
229-
Actor.committer(cr)
230-
Actor.author(cr)
229+
committer = Actor.committer(cr)
230+
author = Actor.author(cr)
231+
self.assertEqual(committer.name, 'Jane Doe')
232+
self.assertEqual(committer.email, 'jane@example.com')
233+
self.assertEqual(author.name, 'John Doe')
234+
self.assertEqual(author.email, 'jdoe@example.com')
231235
self.assertFalse(mock_get_uid.called)
232236

233237
@mock.patch("getpass.getuser")
234238
def test_actor_get_uid_laziness_called(self, mock_get_uid):
239+
mock_get_uid.return_value = "user"
235240
for cr in (None, self.rorepo.config_reader()):
236-
Actor.committer(cr)
237-
Actor.author(cr)
241+
committer = Actor.committer(cr)
242+
author = Actor.author(cr)
243+
if cr is None: # otherwise, use value from config_reader
244+
self.assertEqual(committer.name, 'user')
245+
self.assertTrue(committer.email.startswith('user@'))
246+
self.assertEqual(author.name, 'user')
247+
self.assertTrue(committer.email.startswith('user@'))
238248
self.assertTrue(mock_get_uid.called)
239249
self.assertEqual(mock_get_uid.call_count, 4)
240250

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy