Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2076)

Unified Diff: Tools/Scripts/webkitpy/tool/commands/rebaseline.py

Issue 1235353002: Fix resolution of local branch name in scm and rebaseline tools. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: convert HEAD to empty string Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Tools/Scripts/webkitpy/tool/commands/rebaseline.py
diff --git a/Tools/Scripts/webkitpy/tool/commands/rebaseline.py b/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
index 6f1161f7fdfb3be003fd0dbc5b01c3f0d3b27118..3283f3d0336df0162ddcdde9f77599125c2c24ba 100644
--- a/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
+++ b/Tools/Scripts/webkitpy/tool/commands/rebaseline.py
@@ -57,6 +57,14 @@ def _baseline_name(fs, test_name, suffix):
return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED + "." + suffix
+def _get_branch_name_or_ref(tool):
+ branch_name = tool.scm().current_branch()
+ if not branch_name:
+ # If HEAD is detached use commit SHA instead.
+ return tool.executive.run_command(['git', 'rev-parse', 'HEAD']).strip()
+ return branch_name
+
+
class AbstractRebaseliningCommand(AbstractDeclarativeCommand):
# not overriding execute() - pylint: disable=W0223
@@ -834,6 +842,7 @@ class AutoRebaseline(AbstractParallelRebaselineCommand):
test_prefix_list, lines_to_remove = self.get_test_prefix_list(tests)
did_finish = False
+ old_branch_name_or_ref = ''
try:
# Setup git-svn for dcommit if necessary.
if tool.executive.run_command(
@@ -842,11 +851,7 @@ class AutoRebaseline(AbstractParallelRebaselineCommand):
tool.executive.run_command(['git', 'auto-svn'])
# Save the current branch name and checkout a clean branch for the patch.
- old_branch_name = tool.executive.run_command(
- ["git", "rev-parse", "--symbolic-full-name", "HEAD"])
- if old_branch_name == "HEAD":
- # If HEAD is detached use commit SHA instead.
- old_branch_name = tool.executive.run_command(["git", "rev-parse", "HEAD"])
+ old_branch_name_or_ref = _get_branch_name_or_ref(tool)
tool.scm().delete_branch(self.AUTO_REBASELINE_BRANCH_NAME)
tool.scm().create_clean_branch(self.AUTO_REBASELINE_BRANCH_NAME)
@@ -881,7 +886,8 @@ class AutoRebaseline(AbstractParallelRebaselineCommand):
self._run_git_cl_command(options, ['set_close'])
tool.scm().ensure_cleanly_tracking_remote_master()
- tool.scm().checkout_branch(old_branch_name)
+ if old_branch_name_or_ref:
+ tool.scm().checkout_branch(old_branch_name_or_ref)
tool.scm().delete_branch(self.AUTO_REBASELINE_BRANCH_NAME)
@@ -942,8 +948,9 @@ class RebaselineOMatic(AbstractDeclarativeCommand):
self._log_queue = Queue.Queue(256)
log_thread = threading.Thread(name='LogToServer', target=self._log_to_server_thread)
log_thread.start()
+ old_branch_name_or_ref = ''
try:
- old_branch_name = self._tool.scm().current_branch()
+ old_branch_name_or_ref = _get_branch_name_or_ref(self._tool)
self._run_logged_command(['git', 'pull'])
rebaseline_command = [self._tool.filesystem.join(self._tool.scm().checkout_root, 'Tools', 'Scripts', 'webkit-patch'), 'auto-rebaseline']
if self._verbose:
@@ -953,7 +960,8 @@ class RebaselineOMatic(AbstractDeclarativeCommand):
self._log_queue.put(self.QUIT_LOG)
traceback.print_exc(file=sys.stderr)
# Sometimes git crashes and leaves us on a detached head.
- self._tool.scm().checkout_branch(old_branch_name)
+ if old_branch_name_or_ref:
+ self._tool.scm().checkout_branch(old_branch_name_or_ref)
else:
self._log_queue.put(self.QUIT_LOG)
log_thread.join()
« no previous file with comments | « Tools/Scripts/webkitpy/common/checkout/scm/git.py ('k') | Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698