Improve error message on gclient sync failure

The new error message should clarify what we expect from user to do.

Also, git v2.42.0 introduced new advice on merge failure, which breaks
existing regex match. Instead, use search.

R=aravindvasudev@google.com

Fixed: 1475622
Change-Id: Ib4e60947aaa7994715cfae3260dd27f85f2380b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4823716
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
changes/16/4823716/2
Josip Sokcevic 2 years ago committed by LUCI CQ
parent d40cda515b
commit 1a8bf9e370

@ -906,7 +906,7 @@ class GitWrapper(SCMWrapper):
merge_output = self._Capture(merge_args)
except subprocess2.CalledProcessError as e:
rebase_files = []
if re.match(b'fatal: Not possible to fast-forward, aborting.',
if re.search(b'fatal: Not possible to fast-forward, aborting.',
e.stderr):
if not printed_path:
self.Print('_____ %s at %s' % (self.relpath, revision),
@ -1375,8 +1375,9 @@ class GitWrapper(SCMWrapper):
except subprocess2.CalledProcessError:
raise gclient_utils.Error('\n____ %s at %s\n'
'\tYou have unstaged changes.\n'
'\tPlease commit, stash, or reset.\n'
% (self.relpath, revision))
'\tcd into %s, run git status to see changes,\n'
'\tand commit, stash, or reset.\n' %
(self.relpath, revision, self.relpath))
try:
scm.GIT.Capture(['diff-index', '--cached', '--name-status', '-r',
'--ignore-submodules', 'HEAD', '--'],
@ -1384,8 +1385,9 @@ class GitWrapper(SCMWrapper):
except subprocess2.CalledProcessError:
raise gclient_utils.Error('\n____ %s at %s\n'
'\tYour index contains uncommitted changes\n'
'\tPlease commit, stash, or reset.\n'
% (self.relpath, revision))
'\tcd into %s, run git status to see changes,\n'
'\tand commit, stash, or reset.\n' %
(self.relpath, revision, self.relpath))
def _CheckDetachedHead(self, revision, _options):
# HEAD is detached. Make sure it is safe to move away from (i.e., it is

@ -598,10 +598,10 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
with self.assertRaises(gclient_scm.gclient_utils.Error) as e:
scm.update(options, (), [])
self.assertEqual(
e.exception.args[0],
'\n____ . at refs/remotes/origin/main\n'
e.exception.args[0], '\n____ . at refs/remotes/origin/main\n'
'\tYou have unstaged changes.\n'
'\tPlease commit, stash, or reset.\n')
'\tcd into ., run git status to see changes,\n'
'\tand commit, stash, or reset.\n')
sys.stdout.close()

Loading…
Cancel
Save