summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-03-21 10:57:23 -0500
committerMonty Taylor <mordred@inaugust.com>2013-03-22 10:41:06 -0400
commit6e8b9ba12c96cbf422edd54a6cb12cbc0df66514 (patch)
tree2a4e6f703c19c24c5e153edce1248ef7b8f7ed43
parentbf70726d4228ebf3e65aa75b8f0ca6cab5e1e159 (diff)
downloadoslo-6e8b9ba12c96cbf422edd54a6cb12cbc0df66514.tar.gz
oslo-6e8b9ba12c96cbf422edd54a6cb12cbc0df66514.tar.xz
oslo-6e8b9ba12c96cbf422edd54a6cb12cbc0df66514.zip
Include Co-authored-by entries in AUTHORS.
Co-authored-by lines are the way we've decided to indicated shared authorship of a patch, so content from them should be included in the generated AUTHORS file. Fixes bug 1158319. Change-Id: I9dacf78c01f3ad74e696f16a7aa39edb98e8d185
-rw-r--r--openstack/common/setup.py8
-rw-r--r--tests/unit/test_setup.py24
2 files changed, 28 insertions, 4 deletions
diff --git a/openstack/common/setup.py b/openstack/common/setup.py
index 030df61..dec74fd 100644
--- a/openstack/common/setup.py
+++ b/openstack/common/setup.py
@@ -171,6 +171,14 @@ def generate_authors():
" log --format='%aN <%aE>' | sort -u | "
"egrep -v '" + jenkins_email + "'")
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 = _parse_git_mailmap(git_dir)
with open(new_authors, 'w') as new_authors_fh:
new_authors_fh.write(canonicalize_emails(changelog, mailmap))
diff --git a/tests/unit/test_setup.py b/tests/unit/test_setup.py
index 62decc8..64ca0e2 100644
--- a/tests/unit/test_setup.py
+++ b/tests/unit/test_setup.py
@@ -119,23 +119,38 @@ class GitLogsTest(utils.BaseTestCase):
with open(os.path.join(root_dir, "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
root_dir = self._root_dir()
+
+ git_log_cmd = ("git --git-dir=%s log --format" %
+ os.path.join(root_dir, '.git'))
+ git_co_log_cmd = ("git log --git-dir=%s" %
+ os.path.join(root_dir, '.git'))
+ cmd_map = {
+ git_log_cmd: author_new,
+ git_co_log_cmd: co_author_by,
+ }
+
exist_files = [os.path.join(root_dir, ".git"),
os.path.abspath("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" % os.path.join(root_dir, '.git')
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("AUTHORS.in", "w") as auth_fh:
@@ -147,6 +162,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 GetCmdClassTest(utils.BaseTestCase):