Skip to content

Commit

Permalink
Add commit url output option
Browse files Browse the repository at this point in the history
  • Loading branch information
clamey committed Sep 9, 2024
1 parent c9e8b1a commit cb667e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ committers at the end.
```console
usage: github-repo-committers.py [-h] --access_token ACCESS_TOKEN [--org_name ORG_NAME]
[--max_repos MAX_REPOS] [--repo_name REPO_NAME]
[--commit_urls | --no-commit_urls]
[--ghe_hostname GHE_HOSTNAME] [--count-by {login,name,email}]

Count developers on a GitHub repo or in a GitHub Organization for the last 90 days
Expand All @@ -110,6 +111,8 @@ optional arguments:
How many repos in the Org do you want to inspect? Default=100
--repo_name REPO_NAME
Name of the repo you want to check in 'org/repo' format
--commit_urls, --no-commit_urls
Controls outputting commit URLs, defaults to '--no-commit-urls'
--ghe_hostname GHE_HOSTNAME
If you use GHE, this is the hostname part of the URL
--count-by {username,name,email}
Expand Down
19 changes: 16 additions & 3 deletions github-repo-committers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import re


class CommitterInfo:
def __init__(self, date, commit_url):
self.date = date
self.commit_url = commit_url


def parse_args():
parser = argparse.ArgumentParser(description="Count developers on a GitHub repo or in a GitHub Organization "
"for the last 90 days")
Expand All @@ -18,6 +24,9 @@ def parse_args():
parser.add_argument('--max_repos', default=100, type=str, help="How many repos in the Org do you want "
"to inspect? Default=100")
parser.add_argument('--repo_name', type=str, help="Name of the repo you want to check in 'org/repo' format")
parser.add_argument('--commit_urls', type=bool,
help="Controls outputting commit URLs, defaults to '--no-commit-urls'",
default=False, action=argparse.BooleanOptionalAction)
parser.add_argument('--ghe_hostname', type=str, help="If you use GHE, this is the hostname part of the URL")
parser.add_argument('--count-by', default="username", choices=["username", "name", "email"],
help="How to count contributors. Either by GitHub username, display name or email address of "
Expand Down Expand Up @@ -125,7 +134,8 @@ def repo_details(repo_name, count_by):
author = author_email

if author not in repo_authors:
repo_authors[author] = commit.raw_data['commit']['committer']['date']
repo_authors[author] = CommitterInfo(commit.raw_data['commit']['committer']['date'],
commit.raw_data['html_url'])
else:
break

Expand All @@ -134,8 +144,11 @@ def repo_details(repo_name, count_by):
f' contributor(s) over 90 days with the earliest commit'
f' on {earliest_commit}.')
print('Here is the list of Github contributors:')
for author, commit_date in repo_authors.items():
print(author + ': ' + commit_date)
for author, committer_info in repo_authors.items():
print(author + ': ' + committer_info.date, end='')
if args.commit_urls:
print(',', committer_info.commit_url, end='')
print()
print('\n')
return repo_authors

Expand Down

0 comments on commit cb667e6

Please sign in to comment.