Skip to content

Commit ba07347

Browse files
Christopher Friedtstephanosio
authored andcommitted
scripts: release: use GITHUB_TOKEN and start_date in scripts
Updated bug_bash.py and list_issues.py to use the GITHUB_TOKEN environment variable for consistency with other scripts. Updated bug_bash.py to use `-s / --start-date` instead of `-b / --begin-date`. Signed-off-by: Christopher Friedt <[email protected]> (cherry picked from commit 3b3fc27)
1 parent e423902 commit ba07347

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

scripts/release/bug_bash.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ def parse_args():
2626
parser.add_argument('-a', '--all', dest='all',
2727
help='Show all bugs squashed', action='store_true')
2828
parser.add_argument('-t', '--token', dest='tokenfile',
29-
help='File containing GitHub token', metavar='FILE')
30-
parser.add_argument('-b', '--begin', dest='begin', help='begin date (YYYY-mm-dd)',
31-
metavar='date', type=valid_date_type, required=True)
29+
help='File containing GitHub token (alternatively, use GITHUB_TOKEN env variable)', metavar='FILE')
30+
parser.add_argument('-s', '--start', dest='start', help='start date (YYYY-mm-dd)',
31+
metavar='START_DATE', type=valid_date_type, required=True)
3232
parser.add_argument('-e', '--end', dest='end', help='end date (YYYY-mm-dd)',
33-
metavar='date', type=valid_date_type, required=True)
33+
metavar='END_DATE', type=valid_date_type, required=True)
3434

3535
args = parser.parse_args()
3636

37-
if args.end < args.begin:
37+
if args.end < args.start:
3838
raise ValueError(
39-
'end date {} is before begin date {}'.format(args.end, args.begin))
39+
'end date {} is before start date {}'.format(args.end, args.start))
4040

4141
if args.tokenfile:
4242
with open(args.tokenfile, 'r') as file:
@@ -53,12 +53,12 @@ def parse_args():
5353

5454

5555
class BugBashTally(object):
56-
def __init__(self, gh, begin_date, end_date):
56+
def __init__(self, gh, start_date, end_date):
5757
"""Create a BugBashTally object with the provided Github object,
58-
begin datetime object, and end datetime object"""
58+
start datetime object, and end datetime object"""
5959
self._gh = gh
6060
self._repo = gh.get_repo('zephyrproject-rtos/zephyr')
61-
self._begin_date = begin_date
61+
self._start_date = start_date
6262
self._end_date = end_date
6363

6464
self._issues = []
@@ -122,12 +122,12 @@ def get_issues(self):
122122

123123
cutoff = self._end_date + timedelta(1)
124124
issues = self._repo.get_issues(state='closed', labels=[
125-
'bug'], since=self._begin_date)
125+
'bug'], since=self._start_date)
126126

127127
for i in issues:
128128
# the PyGithub API and v3 REST API do not facilitate 'until'
129129
# or 'end date' :-/
130-
if i.closed_at < self._begin_date or i.closed_at > cutoff:
130+
if i.closed_at < self._start_date or i.closed_at > cutoff:
131131
continue
132132

133133
ipr = i.pull_request
@@ -167,7 +167,7 @@ def print_top_ten(top_ten):
167167

168168
def main():
169169
args = parse_args()
170-
bbt = BugBashTally(Github(args.token), args.begin, args.end)
170+
bbt = BugBashTally(Github(args.token), args.start, args.end)
171171
if args.all:
172172
# print one issue per line
173173
issues = bbt.get_issues()

scripts/release/list_issues.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ def parse_args():
147147
def main():
148148
parse_args()
149149

150-
token = os.environ.get('GH_TOKEN', None)
150+
token = os.environ.get('GITHUB_TOKEN', None)
151151
if not token:
152152
sys.exit("""Github token not set in environment,
153-
set the env. variable GH_TOKEN please and retry.""")
153+
set the env. variable GITHUB_TOKEN please and retry.""")
154154

155155
i = Issues(args.org, args.repo, token)
156156

@@ -213,5 +213,6 @@ def main():
213213
f.write("* :github:`{}` - {}\n".format(
214214
item['number'], item['title']))
215215

216+
216217
if __name__ == '__main__':
217218
main()

0 commit comments

Comments
 (0)