From 0fa63f31b4bd24aa40dc262b8e53aa14f5ab5830 Mon Sep 17 00:00:00 2001 From: hyokeun Date: Mon, 2 Jul 2018 14:27:30 +0900 Subject: [PATCH] [MCD Git Sync] Set git user to requester Change-Id: I75d0a913e57e2f25ba5e3ca060c70be2b35d06cd --- job_git_sync_downstream.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/job_git_sync_downstream.py b/job_git_sync_downstream.py index e7551b2..2b29cce 100644 --- a/job_git_sync_downstream.py +++ b/job_git_sync_downstream.py @@ -46,7 +46,7 @@ class GitType: return type_name IS_SUBMIT_REQUEST=True -def submit_request(project, branch, commit, tagname): +def submit_request(project, branch, commit, tagname, tagger=None): """ Submit Request """ @@ -63,6 +63,11 @@ def submit_request(project, branch, commit, tagname): gitprj.set_branch(branch) print 'set branch' + # Register local git user + if tagger is not None: + with open(os.path.join(gitprj.path, '.git', 'config'), 'a') as gitconfig: + gitconfig.write('[user]\n\tname = %s\n\temail = %s\n' \ + % (tagger.split('@')[0], tagger)) gitprj.checkout(commit) print 'checkout' gitprj.create_tag(tagname, message) @@ -189,6 +194,7 @@ def main(): sync_history_id = content.get('sync_history_id') tagname = content.get('sr_tag') pkg_sync_list = content.get('package_list') + sync_requester_email = content.get('triggered_by') if not pkg_info_url: print 'Error : Can not parse from package-info.xml' @@ -274,7 +280,8 @@ def main(): merge_successs.append((private_project, '%s -> %s' %(commit, commit))) if IS_SUBMIT_REQUEST: - ret = submit_request(project=private_project, branch=branch, commit=commit, tagname=tagname) + ret = submit_request(project=private_project, branch=branch, commit=commit, \ + tagname=tagname, tagger=sync_requester_email) if not ret: raise SubmitRequestError('submit request failed(%s, %s)' % (private_project, commit)) submit_request_successs.append((private_project, commit, tagname)) @@ -326,7 +333,8 @@ def main(): merge_successs.append((private_project, '%s -> %s' %(commit, merge_commit))) if IS_SUBMIT_REQUEST: - ret = submit_request(project=private_project, branch=branch, commit=merge_commit, tagname=tagname) + ret = submit_request(project=private_project, branch=branch, commit=merge_commit, \ + tagname=tagname, tagger=sync_requester_email) if not ret: raise SubmitRequestError('submit request failed(%s, %s)' % (private_project, merge_commit)) submit_request_successs.append((private_project, merge_commit, tagname)) -- 2.7.4