@@ -169,7 +169,6 @@ def post_request(url, timeout, data, headers=[], proxy=None):
169
169
raise MyError ("server returned non-JSON output" )
170
170
except HTTPError as e :
171
171
print e .code
172
- # XXX print string representation of the code
173
172
raise MyError ("got HTTP error: {} ({})" .format (e .code , e .reason ))
174
173
175
174
def upload_file (filepath , upload_url , headers , timeout , proxy = None ):
@@ -235,8 +234,6 @@ def main():
235
234
sys .exit (1 )
236
235
_files .append (file )
237
236
238
- # TODO: Check if the tag is not already present in the repo.
239
-
240
237
try :
241
238
password = os .environ ["GITHUB_PASSWORD" ]
242
239
except :
@@ -250,6 +247,16 @@ def main():
250
247
headers = {}
251
248
headers ['Authorization' ] = _get_auth (user , password )
252
249
250
+ # Check if the tag is not already present in the repo.
251
+ _url = "https://api.github.com"
252
+ _path = '%s%s%s' % ("/repos/" , repo , "/releases/tags/" + tag )
253
+ url = '%s%s' % (_url , _path )
254
+ output_json = post_request (url ,
255
+ arguments .timeout , None , headers , proxy )
256
+ if output_json ["tag_name" ] == tag :
257
+ print "tag '" + tag + "' already present in the releases"
258
+ sys .exit (1 )
259
+
253
260
prerelease = False
254
261
if arguments .prerelease :
255
262
prerelease = True
0 commit comments