Show More
@@ -12,6 +12,7 b' import re' | |||||
12 | import sys |
|
12 | import sys | |
13 |
|
13 | |||
14 | from datetime import datetime, timedelta |
|
14 | from datetime import datetime, timedelta | |
|
15 | from subprocess import check_output | |||
15 | from urllib import urlopen |
|
16 | from urllib import urlopen | |
16 |
|
17 | |||
17 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
@@ -124,15 +125,27 b' if __name__ == "__main__":' | |||||
124 | show_urls = True |
|
125 | show_urls = True | |
125 |
|
126 | |||
126 | # By default, search one month back |
|
127 | # By default, search one month back | |
|
128 | tag = None | |||
127 | if len(sys.argv) > 1: |
|
129 | if len(sys.argv) > 1: | |
128 | days = int(sys.argv[1]) |
|
130 | try: | |
|
131 | days = int(sys.argv[1]) | |||
|
132 | except: | |||
|
133 | tag = sys.argv[1] | |||
129 | else: |
|
134 | else: | |
130 | days = 30 |
|
135 | tag = check_output(['git', 'describe', '--abbrev=0']).strip() | |
|
136 | ||||
|
137 | if tag: | |||
|
138 | cmd = ['git', 'log', '-1', '--format=%ai', tag] | |||
|
139 | tagday, tz = check_output(cmd).strip().rsplit(' ', 1) | |||
|
140 | since = datetime.strptime(tagday, "%Y-%m-%d %H:%M:%S") | |||
|
141 | else: | |||
|
142 | since = datetime.now() - timedelta(days=days) | |||
131 |
|
143 | |||
|
144 | print("fetching GitHub stats since %s (tag: %s)" % (since, tag), file=sys.stderr) | |||
132 | # turn off to play interactively without redownloading, use %run -i |
|
145 | # turn off to play interactively without redownloading, use %run -i | |
133 | if 1: |
|
146 | if 1: | |
134 |
issues = issues_closed_since( |
|
147 | issues = issues_closed_since(since, pulls=False) | |
135 |
pulls = issues_closed_since( |
|
148 | pulls = issues_closed_since(since, pulls=True) | |
136 |
|
149 | |||
137 | # For regular reports, it's nice to show them in reverse chronological order |
|
150 | # For regular reports, it's nice to show them in reverse chronological order | |
138 | issues = sorted_by_field(issues, reverse=True) |
|
151 | issues = sorted_by_field(issues, reverse=True) | |
@@ -140,12 +153,34 b' if __name__ == "__main__":' | |||||
140 |
|
153 | |||
141 | n_issues, n_pulls = map(len, (issues, pulls)) |
|
154 | n_issues, n_pulls = map(len, (issues, pulls)) | |
142 | n_total = n_issues + n_pulls |
|
155 | n_total = n_issues + n_pulls | |
143 |
|
156 | |||
144 | # Print summary report we can directly include into release notes. |
|
157 | # Print summary report we can directly include into release notes. | |
145 | print("GitHub stats for the last %d days." % days) |
|
158 | print() | |
146 | print("We closed a total of %d issues, %d pull requests and %d regular \n" |
|
159 | since_day = since.strftime("%Y/%m/%d") | |
147 | "issues; this is the full list (generated with the script \n" |
|
160 | today = datetime.today().strftime("%Y/%m/%d") | |
148 | "`tools/github_stats.py`):" % (n_total, n_pulls, n_issues)) |
|
161 | print("GitHub stats for %s - %s (tag: %s)" % (since_day, today, tag)) | |
|
162 | print() | |||
|
163 | print("These lists are automatically generated, and may be incomplete or contain duplicates.") | |||
|
164 | print() | |||
|
165 | if tag: | |||
|
166 | # print git info, in addition to GitHub info: | |||
|
167 | since_tag = tag+'..' | |||
|
168 | cmd = ['git', 'log', '--oneline', since_tag] | |||
|
169 | ncommits = len(check_output(cmd).splitlines()) | |||
|
170 | ||||
|
171 | author_cmd = ['git', 'log', '--format=* %aN', since_tag] | |||
|
172 | all_authors = check_output(author_cmd).splitlines() | |||
|
173 | unique_authors = sorted(set(all_authors)) | |||
|
174 | ||||
|
175 | print("The following %i authors contributed %i commits." % (len(unique_authors), ncommits)) | |||
|
176 | print() | |||
|
177 | print('\n'.join(unique_authors)) | |||
|
178 | print() | |||
|
179 | ||||
|
180 | print() | |||
|
181 | print("We closed a total of %d issues, %d pull requests and %d regular issues;\n" | |||
|
182 | "this is the full list (generated with the script \n" | |||
|
183 | ":file:`tools/github_stats.py`):" % (n_total, n_pulls, n_issues)) | |||
149 | print() |
|
184 | print() | |
150 | print('Pull Requests (%d):\n' % n_pulls) |
|
185 | print('Pull Requests (%d):\n' % n_pulls) | |
151 | report(pulls, show_urls) |
|
186 | report(pulls, show_urls) |
General Comments 0
You need to be logged in to leave comments.
Login now