Skip to content

Commit

Permalink
feat: add generated CONTRIBUTORS.txt, fixes #47
Browse files Browse the repository at this point in the history
  • Loading branch information
ntamas committed Mar 11, 2024
1 parent 4c68c8d commit e5d83d7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions etc/scripts/update_contributors_txt.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit e5d83d7

Please sign in to comment.