Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix default actor name handling #1073

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
Byron merged 1 commit into gitpython-developers:master from athos-ribeiro:fix-lazy-user
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion git/util.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def default_email():
return user_id

def default_name():
default_email().split('@')[0]
return default_email().split('@')[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s funny this slipped by me as well since I only write Rust these says, in which this is exactly what we would have expected.
Maybe I have just been a sloppy reviewer though 😅

Copy link
Author

@athos-ribeiro athos-ribeiro Oct 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this one early, @harupy!

harupy reacted with rocket emoji

for attr, evar, cvar, default in (('name', env_name, cls.conf_name, default_name),
('email', env_email, cls.conf_email, default_email)):
Expand Down
18 changes: 14 additions & 4 deletions test/test_util.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,25 @@ def test_actor_get_uid_laziness_not_called(self, mock_get_uid):
}
os.environ.update(env)
for cr in (None, self.rorepo.config_reader()):
Actor.committer(cr)
Actor.author(cr)
committer = Actor.committer(cr)
author = Actor.author(cr)
self.assertEqual(committer.name, 'Jane Doe')
self.assertEqual(committer.email, 'jane@example.com')
self.assertEqual(author.name, 'John Doe')
self.assertEqual(author.email, 'jdoe@example.com')
self.assertFalse(mock_get_uid.called)

@mock.patch("getpass.getuser")
def test_actor_get_uid_laziness_called(self, mock_get_uid):
mock_get_uid.return_value = "user"
for cr in (None, self.rorepo.config_reader()):
Actor.committer(cr)
Actor.author(cr)
committer = Actor.committer(cr)
author = Actor.author(cr)
if cr is None: # otherwise, use value from config_reader
self.assertEqual(committer.name, 'user')
self.assertTrue(committer.email.startswith('user@'))
self.assertEqual(author.name, 'user')
self.assertTrue(committer.email.startswith('user@'))
self.assertTrue(mock_get_uid.called)
self.assertEqual(mock_get_uid.call_count, 4)

Expand Down

AltStyle によって変換されたページ (->オリジナル) /