summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-03-24 18:21:50 +0100
committerMonty Taylor <mordred@inaugust.com>2013-03-24 18:21:50 +0100
commit5b3e94254f43e87993b60d155407877fc574c1d4 (patch)
tree49d69f6d6503dca8d15d325c8aed438a6ff35443
parent014afbd2af4ab135f713e81183d1487eaaac059c (diff)
downloadpbr-5b3e94254f43e87993b60d155407877fc574c1d4.tar.gz
Ported in Co-authored-by support from oslo.
Change-Id: I2db5b4f22f24686ada7c40fad2da134403812675
-rw-r--r--pbr/packaging.py9
-rw-r--r--pbr/tests/test_setup.py23
2 files changed, 27 insertions, 5 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index c5036b8..cde813d 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -156,6 +156,15 @@ def write_git_changelog(git_dir=None, dest_dir=os.path.curdir):
if git_dir:
git_log_cmd = 'git --git-dir=%s log' % git_dir
changelog = _run_shell_command(git_log_cmd)
+ signed_cmd = ("git log --git-dir=" + git_dir +
+ " | grep -i Co-authored-by: | sort -u")
+ signed_entries = _run_shell_command(signed_cmd)
+ if signed_entries:
+ new_entries = "\n".join(
+ [signed.split(":", 1)[1].strip()
+ for signed in signed_entries.split("\n") if signed])
+ changelog = "\n".join((changelog, new_entries))
+
mailmap = read_git_mailmap(git_dir)
with open(new_changelog, "w") as changelog_file:
changelog_file.write(canonicalize_emails(changelog, mailmap))
diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py
index 4e086d9..86ac3c1 100644
--- a/pbr/tests/test_setup.py
+++ b/pbr/tests/test_setup.py
@@ -109,22 +109,34 @@ class GitLogsTest(utils.BaseTestCase):
with open(os.path.join(self.temp_path, "ChangeLog"), "r") as ch_fh:
self.assertTrue("email@foo.com" in ch_fh.read())
+ def _fake_log_output(self, cmd, mapping):
+ for (k, v) in mapping.items():
+ if cmd.startswith(k):
+ return v
+ return ""
+
def test_generate_authors(self):
author_old = "Foo Foo <email@foo.com>"
author_new = "Bar Bar <email@bar.com>"
+ co_author = "Foo Bar <foo@bar.com>"
+ co_author_by = "Co-authored-by: " + co_author
+
+ git_log_cmd = ("git --git-dir=%s log --format" % self.git_dir)
+ git_co_log_cmd = ("git log --git-dir=%s" % self.git_dir)
+ cmd_map = {
+ git_log_cmd: author_new,
+ git_co_log_cmd: co_author_by,
+ }
- exist_files = [os.path.join(self.root_dir, ".git"),
+ exist_files = [self.git_dir,
os.path.join(self.temp_path, "AUTHORS.in")]
self.useFixture(fixtures.MonkeyPatch(
"os.path.exists",
lambda path: os.path.abspath(path) in exist_files))
- git_log_cmd = "git --git-dir=%s log" % self.git_dir
self.useFixture(fixtures.FakePopen(lambda proc_args: {
"stdout": StringIO.StringIO(
- author_new
- if proc_args["args"][2].startswith(git_log_cmd)
- else "")
+ self._fake_log_output(proc_args["args"][2], cmd_map))
}))
with open(os.path.join(self.temp_path, "AUTHORS.in"), "w") as auth_fh:
@@ -137,6 +149,7 @@ class GitLogsTest(utils.BaseTestCase):
authors = auth_fh.read()
self.assertTrue(author_old in authors)
self.assertTrue(author_new in authors)
+ self.assertTrue(co_author in authors)
class BuildSphinxTest(utils.BaseTestCase):