Skip to content

Commit b540d3e

Browse files
Add main to tools/DOI/authors.py (#40633)
To make debugging the author mapping easier, add a main entrypoint to the authors tool. It also adds some flags to the `git log` call to make it more stable and skip merge commits. There is no associated issue. This is a trimmed down version of #40396 because we decided that having a mailmap file required finding a place to store/share it. ### To test: This added the ability to get the authors directly from tools/DOI/authors.py and can be run without accidentally creating a DOI. Use tools/DOI/authors.py --help to find out how to use it and try the two modes. *This does not require release notes* because it modifies how authors are generated for the DOI tool.
1 parent 1188137 commit b540d3e

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

tools/DOI/authors.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,16 @@ def _authors_from_tag_info(tag_info):
462462
"""Given some tag/commit information, will return the corresponding Git
463463
authors.
464464
"""
465-
args = ["git", "log", "--pretty=short", tag_info, '--format="%aN"', "--reverse"]
465+
args = [
466+
"git",
467+
"log",
468+
"--no-mailmap", # use names in commits without mapping
469+
"--no-merges", # ignore merge commits
470+
"--pretty=short",
471+
tag_info,
472+
'--format="%aN"', # only author name, ignore committer
473+
"--reverse",
474+
]
466475
proc = subprocess.run(args, stdout=subprocess.PIPE, encoding="utf-8")
467476
authors = proc.stdout.replace('"', "").split("\n")
468477
return _clean_up_author_list(authors)
@@ -548,3 +557,26 @@ def authors_under_git_tag(tag):
548557
previous_tag = all_tags[all_tags.index(tag) - 1]
549558

550559
return _authors_from_tag_info(previous_tag + ".." + tag)
560+
561+
562+
if __name__ == "__main__":
563+
"""This should normally be run as a library for doi.py, but for testing/development a command line was added."""
564+
import argparse
565+
566+
parser = argparse.ArgumentParser(
567+
description="Generate list of authors for a release", epilog="This requires having a .gitmailmap file from a TWG member"
568+
)
569+
parser.add_argument("version", type=str, help='Version of Mantid whose DOI is to be created/updated in the form "major.minor.patch"')
570+
parser.add_argument("--full", action="store_true", help="Get full list of authors back to start of project")
571+
# process inputs
572+
args = parser.parse_args()
573+
git_tag = find_tag(args.version)
574+
# generate list of authors
575+
if args.full:
576+
authors = authors_up_to_git_tag(git_tag)
577+
else:
578+
authors = authors_under_git_tag(git_tag)
579+
# print out the results
580+
print("For", git_tag)
581+
for author in authors:
582+
print(author)

0 commit comments

Comments
 (0)