From 58888e1171349063ac0536a8a756f6bb6b22d548 Mon Sep 17 00:00:00 2001 From: "akuegel@chromium.org" Date: Tue, 9 Jun 2015 15:26:37 +0000 Subject: [PATCH] Fix git branch parsing. In git version 2.4 the git branch command prints "* (HEAD detached at" or "* (HEAD detached from" instead of "* (detached from". Adjust the parsing to make our tests still work with git 2.4. BUG=487172 Review URL: https://codereview.chromium.org/1162763003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295578 0039d316-1c4b-4281-b951-d872f2087c98 --- git_common.py | 2 +- tests/git_common_test.py | 7 +------ tests/git_rebase_update_test.py | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/git_common.py b/git_common.py index 6b21050b22..a01f8e5694 100644 --- a/git_common.py +++ b/git_common.py @@ -293,7 +293,7 @@ def branch_config_map(option): def branches(*args): - NO_BRANCH = ('* (no branch', '* (detached from ') + NO_BRANCH = ('* (no branch', '* (detached', '* (HEAD detached') key = 'depot-tools.branch-limit' limit = 20 diff --git a/tests/git_common_test.py b/tests/git_common_test.py index 5ba00b2579..5c6febe0d0 100755 --- a/tests/git_common_test.py +++ b/tests/git_common_test.py @@ -230,7 +230,6 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase, self.repo.git('checkout', 'branch_D') self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D') - @unittest.skip('broken by git 2.4') def testBranches(self): # This check fails with git 2.4 (see crbug.com/487172) self.assertEqual(self.repo.run(set, self.gc.branches()), @@ -448,7 +447,6 @@ class GitMutableStructuredTest(git_test_utils.GitRepoReadWriteTestBase, self.repo.git('branch', '--set-upstream-to', 'root_A', 'branch_G') self.repo.git('branch', '--set-upstream-to', 'root_X', 'root_A') - @unittest.skip('broken by git 2.4') def testTooManyBranches(self): for i in xrange(30): self.repo.git('branch', 'a'*i) @@ -535,7 +533,6 @@ class GitMutableStructuredTest(git_test_utils.GitRepoReadWriteTestBase, self.assertIsNone( self.repo.run(self.gc.get_or_create_merge_base, 'branch_DOG')) - @unittest.skip('broken by git 2.4') def testGetBranchTree(self): skipped, tree = self.repo.run(self.gc.get_branch_tree) # This check fails with git 2.4 (see crbug.com/487172) @@ -731,6 +728,4 @@ class GitFreezeThaw(git_test_utils.GitRepoReadWriteTestBase): if __name__ == '__main__': sys.exit(coverage_utils.covered_main( - os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'), - required_percentage=88.0 - )) + os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'))) diff --git a/tests/git_rebase_update_test.py b/tests/git_rebase_update_test.py index f374948c64..ea12d16c27 100755 --- a/tests/git_rebase_update_test.py +++ b/tests/git_rebase_update_test.py @@ -6,7 +6,6 @@ """Unit tests for git_rebase_update.py""" import os -import unittest import sys DEPOT_TOOLS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -69,7 +68,6 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase): self.origin.nuke() super(GitRebaseUpdateTest, self).tearDown() - @unittest.skip('broken by git 2.4') def testRebaseUpdate(self): self.repo.git('checkout', 'branch_K') @@ -342,4 +340,4 @@ if __name__ == '__main__': os.path.join(DEPOT_TOOLS_ROOT, 'git_new_branch.py'), os.path.join(DEPOT_TOOLS_ROOT, 'git_reparent_branch.py'), os.path.join(DEPOT_TOOLS_ROOT, 'git_rename_branch.py') - ), required_percentage=85.0)) + )))