Skip to content

Commit 1b6b951

Browse files
committed
Fixed bug that would cause the author's email to be a generic default one, instead of the existing and valid. The rest of the ConfigParser handling is correct, as it reads all configuration files available to git
see http://github.com/Byron/GitPython/issues#issue/1
1 parent 2c0b92e commit 1b6b951

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lib/git/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __init__(self, file_or_files, read_only=True):
136136
# initialize lock base - we want to write
137137
self._lock = self.t_lock(file_or_files)
138138

139-
self._lock._obtain_lock()
139+
self._lock._obtain_lock()
140140
# END read-only check
141141

142142

lib/git/objects/commit.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
5252
env_email = "EMAIL"
5353

5454
# CONFIGURATION KEYS
55-
conf_email = 'email'
5655
conf_name = 'name'
56+
conf_email = 'email'
5757
conf_encoding = 'i18n.commitencoding'
5858

5959
# INVARIANTS
@@ -294,7 +294,7 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False):
294294
conf_email = cr.get_value('user', cls.conf_email, default_email)
295295

296296
author_name = env.get(cls.env_author_name, conf_name)
297-
author_email = env.get(cls.env_author_email, default_email)
297+
author_email = env.get(cls.env_author_email, conf_email)
298298

299299
committer_name = env.get(cls.env_committer_name, conf_name)
300300
committer_email = env.get(cls.env_committer_email, conf_email)

test/git/test_index.py

+9
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ def test_index_mutation(self, rw_repo):
353353
num_entries = len(index.entries)
354354
cur_head = rw_repo.head
355355

356+
uname = "Some Developer"
357+
umail = "sd@company.com"
358+
rw_repo.config_writer().set_value("user", "name", uname)
359+
rw_repo.config_writer().set_value("user", "email", umail)
360+
356361
# remove all of the files, provide a wild mix of paths, BaseIndexEntries,
357362
# IndexEntries
358363
def mixed_iterator():
@@ -404,6 +409,10 @@ def mixed_iterator():
404409
commit_message = "commit default head"
405410

406411
new_commit = index.commit(commit_message, head=False)
412+
assert new_commit.author.name == uname
413+
assert new_commit.author.email == umail
414+
assert new_commit.committer.name == uname
415+
assert new_commit.committer.email == umail
407416
assert new_commit.message == commit_message
408417
assert new_commit.parents[0] == cur_commit
409418
assert len(new_commit.parents) == 1

0 commit comments

Comments
 (0)