Set proper git user while SR tagging from dashboard 74/144374/1
authorhyokeun <hyokeun.jeon@samsung.com>
Wed, 16 Aug 2017 10:50:41 +0000 (19:50 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Wed, 16 Aug 2017 10:50:41 +0000 (19:50 +0900)
Change-Id: I57ca19a2210a04295051d3cbd872b1fbb3fb0047

job_add_git_tag.py

index 03a9e24..8a0e5f5 100644 (file)
@@ -91,15 +91,6 @@ def main():
         return 1
     orig_git_user_email = out.strip()
 
-    # masquerade user name/ email
-    gitcmd = "git config user.name \"%s\"" % (event['tagger_username'])
-    if runner.show(gitcmd)[0] != 0:
-        raise Exception("failed to execute %s" % gitcmd)
-
-    gitcmd = "git config user.email \"%s\"" % (event['tagger_useremail'])
-    if runner.show(gitcmd)[0] != 0:
-        raise Exception("failed to execute %s" % gitcmd)
-
     os.environ["GIT_AUTHOR_EMAIL"] = event['tagger_useremail']
     os.environ["GIT_AUTHOR_NAME"] = event['tagger_username']
 
@@ -123,6 +114,17 @@ def main():
 
       mygit = Git(prjdir)
 
+      cur_dir = os.getcwd()
+      os.chdir(prjdir)
+      # masquerade user name/ email
+      gitcmd = "git config user.name \"%s\"" % (event['tagger_username'])
+      if runner.show(gitcmd)[0] != 0:
+          raise Exception("failed to execute %s" % gitcmd)
+      gitcmd = "git config user.email \"%s\"" % (event['tagger_useremail'])
+      if runner.show(gitcmd)[0] != 0:
+          raise Exception("failed to execute %s" % gitcmd)
+      os.chdir(cur_dir)
+
       branches = mygit.branch_contains(commit)
       if event['branch'] not in branches:
         raise LocalError("commit %s is not in branch %s" % (commit, event['branch']))