Show More
@@ -12,6 +12,7 b' import re' | |||
|
12 | 12 | import sys |
|
13 | 13 | |
|
14 | 14 | from datetime import datetime, timedelta |
|
15 | from subprocess import check_output | |
|
15 | 16 | from urllib import urlopen |
|
16 | 17 | |
|
17 | 18 | #----------------------------------------------------------------------------- |
@@ -124,15 +125,27 b' if __name__ == "__main__":' | |||
|
124 | 125 | show_urls = True |
|
125 | 126 | |
|
126 | 127 | # By default, search one month back |
|
128 | tag = None | |
|
127 | 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 | 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 | 145 | # turn off to play interactively without redownloading, use %run -i |
|
133 | 146 | if 1: |
|
134 |
issues = issues_closed_since( |
|
|
135 |
pulls = issues_closed_since( |
|
|
147 | issues = issues_closed_since(since, pulls=False) | |
|
148 | pulls = issues_closed_since(since, pulls=True) | |
|
136 | 149 | |
|
137 | 150 | # For regular reports, it's nice to show them in reverse chronological order |
|
138 | 151 | issues = sorted_by_field(issues, reverse=True) |
@@ -140,12 +153,34 b' if __name__ == "__main__":' | |||
|
140 | 153 | |
|
141 | 154 | n_issues, n_pulls = map(len, (issues, pulls)) |
|
142 | 155 | n_total = n_issues + n_pulls |
|
143 | ||
|
156 | ||
|
144 | 157 | # Print summary report we can directly include into release notes. |
|
145 | print("GitHub stats for the last %d days." % days) | |
|
146 | print("We closed a total of %d issues, %d pull requests and %d regular \n" | |
|
147 | "issues; this is the full list (generated with the script \n" | |
|
148 | "`tools/github_stats.py`):" % (n_total, n_pulls, n_issues)) | |
|
158 | print() | |
|
159 | since_day = since.strftime("%Y/%m/%d") | |
|
160 | today = datetime.today().strftime("%Y/%m/%d") | |
|
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 | 184 | print() |
|
150 | 185 | print('Pull Requests (%d):\n' % n_pulls) |
|
151 | 186 | report(pulls, show_urls) |
General Comments 0
You need to be logged in to leave comments.
Login now