Skip to content

Commit e06f5e6

Browse files
committed
Allow listing PRs merged until a certain date
1 parent 4925582 commit e06f5e6

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

devel-tools/print_pr_list.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,37 @@ def get_pr_authors(pr):
7474

7575
def print_pr_report(kwargs):
7676

77-
ref_date = kwargs.get('since')
77+
since_date = kwargs.get('since')
78+
until_date = kwargs.get('until')
7879

79-
if not ref_date is None:
80-
print()
81-
print("The following is a list of pull requests since",
82-
ref_date+":")
83-
ref_date_ts = date_parser.parse(ref_date).timestamp()
80+
msg = "The following is a list of"
81+
if since_date is None and until_date is None:
82+
msg += " all"
83+
msg += " pull requests"
84+
85+
if since_date:
86+
since_date_ts = date_parser.parse(since_date).timestamp()
87+
msg += f" merged since {since_date}"
88+
else:
89+
since_date_ts = 0
90+
91+
if until_date:
92+
until_date_ts = date_parser.parse(until_date).timestamp()
93+
if since_date:
94+
msg += f" and until {until_date}"
95+
else:
96+
msg += f" merged until {until_date}"
8497
else:
85-
ref_date_ts = 0
86-
print()
87-
print("The following is a list of all pull requests:")
98+
until_date_ts = 0
99+
100+
print(msg + ":")
88101

89102
pr_db = get_pr_list(kwargs.get('state'), label=kwargs['label'])
90103
all_authors = []
91104
for pr in pr_db:
92105
pr['mergedAt'] = date_parser.parse(pr['mergedAt']).timestamp()
93106
pr_labels = [label['name'] for label in pr['labels']]
94-
if pr['mergedAt'] > ref_date_ts and affects_backend(
107+
if pr['mergedAt'] >= since_date_ts and pr['mergedAt'] <= until_date_ts and affects_backend(
95108
pr_labels, kwargs.get('backend')):
96109
pr_authors = get_pr_authors(pr)
97110
all_authors += pr_authors
@@ -100,8 +113,7 @@ def print_pr_report(kwargs):
100113
print(" ", pr['url'], "("+", ".join(pr_authors)+")")
101114

102115
print()
103-
print("Authors:", ", ".join(sorted(list(set(all_authors)),
104-
key=str.casefold)))
116+
print("Authors:", ", ".join(sorted(list(set(all_authors)), key=str.casefold)))
105117

106118

107119
if __name__ == '__main__':
@@ -112,7 +124,10 @@ def print_pr_report(kwargs):
112124
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
113125
parser.add_argument('--since',
114126
type=str,
115-
help="List PRs merged this date; default is all")
127+
help="List PRs merged since this date; default is all")
128+
parser.add_argument('--until',
129+
type=str,
130+
help="List PRs merged until this date; default is all")
116131
parser.add_argument('--backend',
117132
type=str,
118133
choices=backends,

0 commit comments

Comments
 (0)