From 4fd7b945dfca73caf00883d4cf43740edb7516df Mon Sep 17 00:00:00 2001 From: firm1 Date: Thu, 4 Sep 2014 03:38:08 +0200 Subject: add support of utf8 --- git/refs/log.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'git') diff --git a/git/refs/log.py b/git/refs/log.py index 8ce98d30..c6f9a218 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -32,7 +32,6 @@ __all__ = ["RefLog", "RefLogEntry"] class RefLogEntry(tuple): """Named tuple allowing easy access to the revlog data fields""" - _fmt = "%s %s %s <%s> %i %s\t%s\n" _re_hexsha_only = re.compile('^[0-9A-Fa-f]{40}$') __slots__ = tuple() @@ -40,9 +39,8 @@ class RefLogEntry(tuple): """Representation of ourselves in git reflog format""" act = self.actor time = self.time - return self._fmt % (self.oldhexsha, self.newhexsha, act.name, act.email, - time[0], altz_to_utctz_str(time[1]), self.message) - + return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, self.newhexsha, act.name, act.email, + time[0], altz_to_utctz_str(time[1]), self.message).encode("utf-8") @property def oldhexsha(self): """The hexsha to the commit the ref pointed to before the change""" @@ -267,7 +265,6 @@ class RefLog(list, Serializable): lf = LockFile(filepath) lf._obtain_lock_or_raise() - fd = open(filepath, 'ab') try: fd.write(repr(entry).encode(defenc)) -- cgit v1.2.3 From 28bda3aaa19955d1c172bd86d62478bee024bf7b Mon Sep 17 00:00:00 2001 From: firm1 Date: Sat, 6 Sep 2014 03:12:38 +0200 Subject: suppression des prefixes de commit --- git/objects/commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git') diff --git a/git/objects/commit.py b/git/objects/commit.py index 8f93d1b9..f2ce91ca 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -358,7 +358,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): # as well ... import git.refs try: - repo.head.set_commit(new_commit, logmsg="commit: %s" % message) + repo.head.set_commit(new_commit, logmsg=message) except ValueError: # head is not yet set to the ref our HEAD points to # Happens on first commit -- cgit v1.2.3 From 1dec7a822424bbe58b7b2a7787b1ea32683a9c19 Mon Sep 17 00:00:00 2001 From: firm1 Date: Wed, 7 Jan 2015 11:42:57 +0100 Subject: add tests for commit by actor --- git/test/test_index.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'git') diff --git a/git/test/test_index.py b/git/test/test_index.py index f7504b32..a0d1ffbc 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -444,6 +444,22 @@ class TestIndex(TestBase): assert new_commit.parents[0] == cur_commit assert len(new_commit.parents) == 1 assert cur_head.commit == cur_commit + + # commit with other actor + cur_commit = cur_head.commit + + my_author = Actor("An author", "author@example.com") + my_committer = Actor("An committer", "committer@example.com") + commit_actor = index.commit(commit_message, author=my_author, committer=my_committer) + assert cur_commit != commit_actor + assert commit_actor.author.name == "An author" + assert commit_actor.author.email == "author@example.com" + assert commit_actor.committer.name == "An committer" + assert commit_actor.committer.email == "committer@example.com" + assert commit_actor.message == commit_message + assert commit_actor.parents[0] == cur_commit + assert len(new_commit.parents) == 1 + assert cur_head.commit == cur_commit # same index, no parents commit_message = "index without parents" -- cgit v1.2.3 From b6ed8d46c72366e111b9a97a7c238ef4af3bf4dc Mon Sep 17 00:00:00 2001 From: firm1 Date: Wed, 7 Jan 2015 13:51:48 +0100 Subject: fix pep8 --- git/refs/log.py | 10 ++++++++-- git/test/test_index.py | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'git') diff --git a/git/refs/log.py b/git/refs/log.py index c6f9a218..ec19c1e8 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -39,8 +39,14 @@ class RefLogEntry(tuple): """Representation of ourselves in git reflog format""" act = self.actor time = self.time - return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, self.newhexsha, act.name, act.email, - time[0], altz_to_utctz_str(time[1]), self.message).encode("utf-8") + return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, + self.newhexsha, + act.name, + act.email, + time[0], + altz_to_utctz_str(time[1]), + self.message).encode("utf-8") + @property def oldhexsha(self): """The hexsha to the commit the ref pointed to before the change""" diff --git a/git/test/test_index.py b/git/test/test_index.py index a0d1ffbc..f7d1cc6a 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -10,6 +10,7 @@ from git.test.lib import ( fixture, with_rw_repo ) +from git.util import Actor from git import ( IndexFile, BlobFilter, @@ -444,10 +445,10 @@ class TestIndex(TestBase): assert new_commit.parents[0] == cur_commit assert len(new_commit.parents) == 1 assert cur_head.commit == cur_commit - + # commit with other actor cur_commit = cur_head.commit - + my_author = Actor("An author", "author@example.com") my_committer = Actor("An committer", "committer@example.com") commit_actor = index.commit(commit_message, author=my_author, committer=my_committer) -- cgit v1.2.3