Back to home page

EIC code displayed by LXR

 
 

    


Warning, /iDDS/main/tools/git/submit-push is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env python
0002 #
0003 # Licensed under the Apache License, Version 2.0 (the "License");
0004 # You may not use this file except in compliance with the License.
0005 # You may obtain a copy of the License at
0006 # http://www.apache.org/licenses/LICENSE-2.0
0007 #
0008 # Authors:
0009 # - Wen Guan, <wen.guan@cern.ch>, 2016-2017
0010 
0011 import commands
0012 import sys
0013 import json
0014 import requests
0015 
0016 # requests.packages.urllib3.disable_warnings()
0017 
0018 project_url = "https://api.github.com/repos/wguanicedew/ess/pulls"
0019 
0020 def submit_merge_request(token, data):
0021     r = requests.post(url='%s' % project_url,
0022                       headers={"Content-Type": "application/json",
0023                                "Authorization": "token %s" % token},
0024                       data=json.dumps(data))
0025     return r
0026 
0027 
0028 root_git_dir = commands.getstatusoutput('git rev-parse --show-toplevel')[1]
0029 
0030 # Load private_token
0031 print 'Loading private token ...',
0032 try:
0033     with open(root_git_dir + '/.githubkey', 'r') as f:
0034         private_token = f.readline().strip()
0035         print 'OK'
0036 except:
0037     print 'ERROR'
0038     print 'No github keyfile found at %s' % root_git_dir + '/.githubkey'
0039     sys.exit(-1)
0040 
0041 # Check if current branch is not master or next
0042 print 'Checking if current branch is a patch/dev branch ...',
0043 current_branch = commands.getstatusoutput('git rev-parse --abbrev-ref HEAD')[1]
0044 
0045 # Push the branch to origin
0046 print 'Pushing the dev/patch branch to origin ...',
0047 op = commands.getstatusoutput('git push origin %s' % current_branch)
0048 if op[0] == 0:
0049     print 'OK'
0050 else:
0051     print 'ERROR'
0052     print op[1]
0053     sys.exit(-1)
0054