Skip to content
Snippets Groups Projects
Commit 5154fa66 authored by Amir Mohammadi's avatar Amir Mohammadi
Browse files

gitlab/update_feedstock.py fix the title bug for merge requests

parent 4692871d
No related branches found
No related tags found
1 merge request!35update install scripts to use our own channel
...@@ -94,13 +94,15 @@ class Gitlab(object): ...@@ -94,13 +94,15 @@ class Gitlab(object):
pipeline = subprocess.check_output(cmd) pipeline = subprocess.check_output(cmd)
return json.loads(pipeline.decode()) return json.loads(pipeline.decode())
def create_merge_request(self, project_id, source_branch, target_branch, title, def create_merge_request(self, project_id, source_branch, target_branch,
assignee_id='', description='', target_project_id='', title, assignee_id='', description='',
labels='', milestone_id='', remove_source_branch=''): target_project_id='', labels='', milestone_id='',
remove_source_branch=''):
url = "projects/{}/merge_requests?" url = "projects/{}/merge_requests?"
url += "&".join(['source_branch={}', 'target_branch={}', 'title={}']) url += "&".join(['source_branch={}', 'target_branch={}', 'title={}',
url += "&".join(['assignee_id={}', 'description={}', 'target_project_id={}', 'assignee_id={}', 'description={}',
'labels={}', 'milestone_id={}', 'remove_source_branch={}']) 'target_project_id={}', 'labels={}',
'milestone_id={}', 'remove_source_branch={}'])
url = url.format(project_id, source_branch, target_branch, title, url = url.format(project_id, source_branch, target_branch, title,
assignee_id, description, target_project_id, labels, assignee_id, description, target_project_id, labels,
milestone_id, remove_source_branch) milestone_id, remove_source_branch)
...@@ -181,12 +183,15 @@ def main(package, direct_push=False): ...@@ -181,12 +183,15 @@ def main(package, direct_push=False):
f.write(doc) f.write(doc)
run_commands(['git', '--no-pager', 'diff'], run_commands(['git', '--no-pager', 'diff'],
['git', 'config', 'user.email', os.environ.get('GITLAB_USER_EMAIL')], ['git', 'config', 'user.email',
['git', 'config', 'user.name', os.environ.get('GITLAB_USER_ID')], os.environ.get('GITLAB_USER_EMAIL')],
['git', 'config', 'user.name',
os.environ.get('GITLAB_USER_ID')],
['git', 'add', '-A']) ['git', 'add', '-A'])
try: try:
run_commands(['git', 'commit', '-am', run_commands(['git', 'commit', '-am',
'Update to version {}'.format(stable_version)]) '[{}] Update to version {}'.format(package,
stable_version)])
except ValueError: except ValueError:
print('Feedstock is already uptodate, skipping.') print('Feedstock is already uptodate, skipping.')
return return
...@@ -202,13 +207,14 @@ def main(package, direct_push=False): ...@@ -202,13 +207,14 @@ def main(package, direct_push=False):
'https://github.com/conda-forge/' 'https://github.com/conda-forge/'
'{}-feedstock/commits/master\n\n'.format(package)) '{}-feedstock/commits/master\n\n'.format(package))
else: else:
subprocess.call(['git', 'remote', 'set-url', 'origin', origin_url = 'https://idiapbbb:{}@gitlab.idiap.ch/bob/bob.conda.git'
'https://idiapbbb:{}@gitlab.idiap.ch/bob/bob.conda.git'.format(os.environ.get('IDIAPBBB_PASS'))]) origin_url = origin_url.format(os.environ.get('IDIAPBBB_PASS'))
subprocess.call(['git', 'remote', 'set-url', 'origin', origin_url])
run_commands(['git', 'push', '--quiet', '--force', '--set-upstream', run_commands(['git', 'push', '--quiet', '--force', '--set-upstream',
'origin', branch_name]) 'origin', branch_name])
gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN')) gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN'))
project_id = gitlab.get_project('bob.conda')['id'] project_id = gitlab.get_project('bob.conda')['id']
title = 'Update-to-version-{}'.format(branch_name) title = 'Update-to-{}'.format(branch_name)
gitlab.create_merge_request(project_id, branch_name, 'master', title, gitlab.create_merge_request(project_id, branch_name, 'master', title,
remove_source_branch='true') remove_source_branch='true')
finally: finally:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment