aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-02-06 08:52:24 +0100
committerGuido Günther <agx@sigxcpu.org>2017-02-07 07:34:53 +0100
commit80044e1655266ad30fe0e1c0f3ff4803a95d026e (patch)
tree1eb5b1536a8ce680334dd6b5eff7029df0ce7ec3
parentfd7a3775dc6df2bf38e804533b3df153690524b3 (diff)
GitRepository: shorten reflog message
Closes: #854333 Thanks: Chris Lamb for the report
-rw-r--r--gbp/git/repository.py2
-rw-r--r--tests/28_test_gbp_git_repository_commit_dir.py42
2 files changed, 43 insertions, 1 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index c9456a7..75f2ebc 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1530,7 +1530,7 @@ class GitRepository(object):
if not commit:
raise GitRepositoryError("Failed to commit tree")
self.update_ref("refs/heads/%s" % branch, commit, cur,
- msg="gbp: %s" % msg)
+ msg="gbp: %s" % msg.split('\n')[0])
return commit
def commit_tree(self, tree, msg, parents, author={}, committer={}):
diff --git a/tests/28_test_gbp_git_repository_commit_dir.py b/tests/28_test_gbp_git_repository_commit_dir.py
new file mode 100644
index 0000000..67d4750
--- /dev/null
+++ b/tests/28_test_gbp_git_repository_commit_dir.py
@@ -0,0 +1,42 @@
+# vim: set fileencoding=utf-8 :
+
+import os
+
+from . testutils import DebianGitTestRepo
+from gbp.git.repository import GitRepositoryError
+
+
+class TestGitRepositoryCommitDir(DebianGitTestRepo):
+ def setUp(self):
+ DebianGitTestRepo.setUp(self)
+ self.content = os.path.join(str(self.tmpdir), 'new')
+ os.mkdir(self.content)
+ with open(os.path.join(self.content, 'file1'), 'w') as f:
+ f.write('content1')
+
+ def test_simple(self):
+ self.repo.commit_dir(self.content,
+ 'new content',
+ 'master',
+ create_missing_branch=True)
+ self.assertEquals(self.repo.show('master:file1'), 'content1')
+
+ def test_long_reflog(self):
+ """Make sure we fail on onverly long msg resulting in an
+ overly long reflog enry"""
+ with self.assertRaises(GitRepositoryError):
+ self.repo.commit_dir(self.content,
+ 'foo' * 100000,
+ 'master',
+ create_missing_branch=True)
+
+ def test_long_msg_854333(self):
+ """Make sure we shorten the reflog entry properly"""
+ self.repo.commit_dir(self.content,
+ 'foo\n' * 100000,
+ 'master',
+ create_missing_branch=True)
+ self.assertEquals(self.repo.show('master:file1'), 'content1')
+ out, dummy, ret = self.repo._git_inout('reflog', [])
+ self.assertEquals(ret, 0)
+ self.assertIn('HEAD@{0}: gbp: foo\n', out)