From e5d83d7e28d9a3d3db2e8b2ddd38d15e233cc32a Mon Sep 17 00:00:00 2001 From: Tamas Nepusz Date: Mon, 11 Mar 2024 08:24:55 +0100 Subject: [PATCH] feat: add generated CONTRIBUTORS.txt, fixes #47 --- .pre-commit-config.yaml | 8 +++++ CONTRIBUTORS.txt | 14 +++++++++ etc/scripts/update_contributors_txt.py | 41 ++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 CONTRIBUTORS.txt create mode 100755 etc/scripts/update_contributors_txt.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e6bc9fc..059e094 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,3 +13,11 @@ repos: exclude: "data/" - id: check-merge-conflict - id: fix-byte-order-marker + + - repo: local + hooks: + - id: update-contributors-txt + name: Update CONTRIBUTORS.txt + language: python + entry: python3 etc/scripts/update_contributors_txt.py + pass_filenames: false diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt new file mode 100644 index 0000000..6466c6b --- /dev/null +++ b/CONTRIBUTORS.txt @@ -0,0 +1,14 @@ +Thanks goes to these wonderful people: + +Tamás Nepusz (@ntamas) +Szabolcs Horvát (@szhorvat) +Jérôme Benoit (@jgmbenoit) +Robert Schütz (@dotlambda) +Biswapriyo Nath (@Biswa96) +Michael Orlitzky (@orlitzky) + +This project follows the [all-contributors][1] specification. Contributions of any kind welcome! + +This file is an automatically generated, plain-text version of CONTRIBUTORS.md. + +[1]: https://github.com/all-contributors/all-contributors diff --git a/etc/scripts/update_contributors_txt.py b/etc/scripts/update_contributors_txt.py new file mode 100755 index 0000000..89077d3 --- /dev/null +++ b/etc/scripts/update_contributors_txt.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +"""Update the contents of CONTRIBUTORS.txt based on .all-contributorsrc.""" + +from json import load +from os import chdir +from pathlib import Path + + +HEADER = """\ +Thanks goes to these wonderful people: + +""" + +FOOTER = """\ + +This project follows the [all-contributors][1] specification. Contributions of any kind welcome! + +This file is an automatically generated, plain-text version of CONTRIBUTORS.md. + +[1]: https://github.com/all-contributors/all-contributors +""" + +def main(): + root_dir = Path(__file__).parent.parent.parent + chdir(root_dir) + + with (root_dir / ".all-contributorsrc").open("r") as fp: + contributors = load(fp)["contributors"] + + with (root_dir / "CONTRIBUTORS.txt").open("w") as fp: + fp.write(HEADER) + for c in contributors: + if c["name"]: + fp.write(f"{c['name']} (@{c['login']})\n") + else: + fp.write(f"@{c['login']}\n") + fp.write(FOOTER) + + +if __name__ == "__main__": + main()