-
-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update contributors list #1010
update contributors list #1010
Conversation
Codecov Report
@@ Coverage Diff @@
## next #1010 +/- ##
==========================================
+ Coverage 37.74% 37.82% +0.08%
==========================================
Files 48 48
Lines 10869 10844 -25
==========================================
Hits 4102 4102
+ Misses 6767 6742 -25 |
i think that it's better to only replace the |
3fa4c09
to
4cee9f7
Compare
4cee9f7
to
0de0f3f
Compare
I think automating this task is a good idea.
Got a bit of free time... 🙈 Python scriptRewritten the above script in python. Does not directly write the file but should instead be used with redirecting stdout to the CONTRIBUTORS file.#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Generate contributors list from git commit history."""
import shutil
import subprocess
# Contributors with these names will be discarded.
# Used to gracefully remove duplicates based on contributor's preference.
NAME_BLACKLIST = {
"yshui", # prefer 'Yuxuan Shui'
}
# Contributors with these emails will be discarded.
# Used to gracefully remove duplicates based on contributor's preference,
# and to remove non-contributors (bots, etc.).
EMAIL_BLACKLIST = {
"[email protected]", # prefer "[email protected]"
"[email protected]", # prefer "[email protected]"
"[email protected]", # prefer "[email protected]"
# Bots
"[email protected]", # GitHub
"[email protected]", # The Gitter Badger
}
HEADER = (
"Sorted in alphabetical order. Feel free to open an issue or create a\n"
"pull request if you want to change or remove your mention.\n"
)
GIT_LOG_FORMAT = "%an\t%ae%n%aN\t%aE%n%cn\t%ce%n%cN\t%cE%n%gn\t%ge%n%gN\t%ge"
def get_git_contributors():
"""Get sorted list of contributors from git commit history."""
git_exe = shutil.which("git")
command = (git_exe, "log", f"--format={GIT_LOG_FORMAT}")
result = subprocess.run(command, shell=False,
capture_output=True, text=True)
result.check_returncode()
contributors = {
line.strip()
for line in result.stdout.splitlines()
if line.strip()
}
return sorted(contributors, key=str.casefold)
def format_contributors(contributor_list):
"""Format name and email address of each contributor."""
contributors = []
for contributor in contributor_list:
name, email = contributor.split("\t")
name = name.strip()
email = email.strip()
# ignore empty and blacklisted entries
if (not name or name in NAME_BLACKLIST
or not email or email in EMAIL_BLACKLIST):
continue
# remove invalid or private github email addresses
if "@" not in email or email.endswith("noreply.github.com"):
email = None
# rudimentary obfuscate the provided email address
if email:
email = f"<{email.replace('@', ' at ').lower()}>"
if contributors and contributors[-1][0] == name:
if email:
contributors[-1][1].append(email)
else:
contributors.append((name, [email] if email else []))
return contributors
def main():
print(HEADER)
contributors = format_contributors(get_git_contributors())
for name, emails in contributors:
if not emails:
print(name)
else:
print(name, " ".join(emails))
if __name__ == "__main__":
main() |
0de0f3f
to
23538d8
Compare
@tryone144, perfect, thank you! i've updated the if you wish you could do a pull request in this branch to add the script to the source tree (i believe that's how it supposed to be done to preserve your authorship?) naming it whatever you like and placing it wherever you like. |
it's (almost) automatically generated from the git log and the contributors' emails are (trivially) obfuscated
23538d8
to
6496f75
Compare
i think that this pull request can be merged without waiting for @tryone144. he could do a pull request adding his script to the source tree later if he wants. btw, a couple of notes about his script:
|
nice thought replacing |
it's (almost) automatically generated from the git log and the contributors' emails are (trivially) obfuscated
the script used:
ideally, it should be written in python but i don't know python (just like i don't know javascript, i used to be good at it but getting back to it after a long time proved that it's not true anymore :D). and the `git log` command should be integrated into it so you only have to run a single command to get a nice contributors list.if someone will rewrite this script in python it could be included in the source tree for convenience and be run before each release but for now i just leave it here: