1
+ """
2
+ Usage: python scripts/release_notes/retrieve_prs.py tags/v0.10.0 \
3
+ 18685a517ae68353b05b9a0ede5343df31525c76 --file data.json
4
+ """
5
+ import argparse
1
6
import json
2
7
import re
3
- import sys
4
- import argparse
5
8
import subprocess
6
9
from collections import namedtuple
7
10
from os .path import expanduser
11
+ from pathlib import Path
8
12
9
13
import requests
10
14
15
+ ROOT_DIR = Path (__file__ ).parent .resolve ()
16
+
11
17
Features = namedtuple (
12
18
"Features" ,
13
19
[
@@ -57,11 +63,12 @@ def get_ghstack_token():
57
63
58
64
59
65
def run_query (query ):
60
- request = requests .post ("https://github.com/api/graphql" , json = {"query" : query }, headers = headers )
61
- if request .status_code == 200 :
62
- return request .json ()
63
- else :
64
- raise Exception ("Query failed to run by returning code of {}. {}" .format (request .status_code , query ))
66
+ response = requests .post ("https://github.com/api/graphql" , json = {"query" : query }, headers = headers )
67
+ try :
68
+ response .raise_for_status ()
69
+ return response .json ()
70
+ except requests .exceptions .HTTPError as e :
71
+ print (e )
65
72
66
73
67
74
def gh_labels (pr_number ):
@@ -109,7 +116,10 @@ def get_commits_between(base_version, new_version):
109
116
110
117
111
118
def _parse_args (args ):
112
- parser = argparse .ArgumentParser ()
119
+ parser = argparse .ArgumentParser (
120
+ description = __doc__ ,
121
+ formatter_class = argparse .RawTextHelpFormatter ,
122
+ )
113
123
parser .add_argument ("base_version" , type = str , help = "starting tag or commit (exclusive)" )
114
124
parser .add_argument ("new_version" , type = str , help = "final tag or commit (inclusive)" )
115
125
parser .add_argument ("--file" , type = str , default = "data.json" , help = "output json file" )
@@ -131,6 +141,4 @@ def _main(args):
131
141
132
142
133
143
if __name__ == "__main__" :
134
- # Usage: python scripts/release_notes/retrieve_prs.py tags/v0.10.0 \
135
- # 18685a517ae68353b05b9a0ede5343df31525c76 --file data.json
136
- _main (_parse_args (sys .argv [1 :]))
144
+ _main (_parse_args ())
0 commit comments