diff options
author | João Valverde <j@v6e.pt> | 2023-01-20 10:51:10 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-01-20 12:04:57 +0000 |
commit | 5f63989ee0b3d77d2b484ae712ac370f84a3ba68 (patch) | |
tree | d8680b567efe95a92e8a14fbed46c8dc8869250b /tools | |
parent | 597bcca9ee7c4e00da52bc3363b97381c9a516fc (diff) |
Update authors file in place
Instead of having AUTHORS.src and copying that to a new AUTHORS
file with git log information appended to that have a single
AUHTORS file and update it in place with git log info.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/generate_authors.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/generate_authors.py b/tools/generate_authors.py index 6d020d954c..a74ef1c40b 100755 --- a/tools/generate_authors.py +++ b/tools/generate_authors.py @@ -107,15 +107,23 @@ def generate_git_contributors_text(contributors_emails, git_authors_emails): return "\n".join(output_lines) -def main(): - stdoutu8 = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') +# Read authos file until we find gitlog entries, then stop +def read_authors(parsed_args): + lines = [] + with open(parsed_args.authors[0], 'r', encoding='utf-8') as fh: + for line in fh.readlines(): + if '= From git log =' in line: + break + lines.append(line) + return ''.join(lines) + +def main(): parser = argparse.ArgumentParser(description="Generate the AUTHORS file combining existing AUTHORS file with git commit log.") parser.add_argument("authors", metavar='authors', nargs=1, help="path to AUTHORS file") parsed_args = parser.parse_args() - with open(parsed_args.authors[0], encoding='utf-8') as fh: - author_content = fh.read() + author_content = read_authors(parsed_args) # Collect the listed contributors emails so that we don't duplicate them # in the listing of git contributors @@ -125,9 +133,11 @@ def main(): git_contributors_text = generate_git_contributors_text(contributors_emails, git_authors_emails) # Now we can write our output: - git_contributor_header = '\n\n= From git log =\n\n' + git_contributor_header = '= From git log =\n\n' output = author_content + git_contributor_header + git_contributors_text + '\n' - stdoutu8.write(output) + + with open(parsed_args.authors[0], 'w', encoding='utf-8') as fh: + fh.write(output) if __name__ == '__main__': |