From caa1655dd6f571354064cfb05c2f045ef93dc1d6 Mon Sep 17 00:00:00 2001 From: "rogerta@chromium.org" Date: Mon, 18 Mar 2013 20:45:05 +0000 Subject: [PATCH] Save the GIT hash of HEAD when uploading to rietveld. Review URL: https://chromiumcodereview.appspot.com/12811006 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@188807 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 17 +++++++++++++---- tests/git_cl_test.py | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/git_cl.py b/git_cl.py index 2fd5d852f1..79d0715f66 100755 --- a/git_cl.py +++ b/git_cl.py @@ -95,9 +95,14 @@ def ask_for_data(prompt): def git_set_branch_value(key, value): branch = Changelist().GetBranch() - if branch: - git_key = 'branch.%s.%s' % (branch, key) - RunGit(['config', '--int', git_key, "%d" % value]) + if not branch: + return + + cmd = ['config'] + if isinstance(value, int): + cmd.append('--int') + git_key = 'branch.%s.%s' % (branch, key) + RunGit(cmd + [git_key, str(value)]) def git_get_branch_default(key, default): @@ -1288,7 +1293,11 @@ def CMDupload(parser, args): print_stats(options.similarity, options.find_copies, args) if settings.GetIsGerrit(): return GerritUpload(options, args, cl) - return RietveldUpload(options, args, cl) + ret = RietveldUpload(options, args, cl) + if not ret: + git_set_branch_value('last-upload-hash', RunGit(['rev-parse', 'HEAD'])) + + return ret def IsSubmoduleMergeCommit(ref): diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index d8ee317222..23488ce516 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -166,6 +166,9 @@ class TestGitCl(TestCase): ((['git', 'config', 'branch.master.rietveldserver', 'https://codereview.example.com'],), ''), ((['git', 'config', 'branch.master.rietveldpatchset', '2'],), ''), + ((['git', 'rev-parse', 'HEAD'],), 'hash'), + ((['git', 'symbolic-ref', 'HEAD'],), 'hash'), + ((['git', 'config', 'branch.hash.last-upload-hash', 'hash'],), ''), ] @staticmethod