From 2b4da1228f58c6da5c9c76da5076365ef4b81ff4 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Tue, 14 Feb 2017 15:16:46 +0100 Subject: [PATCH] bot_update: speculative fix for gerrit patch application failure. bot_update doesn't properly cleanup git index state from unmerged paths, which are likely if Rietveld patches were failed to be applied in prior runs in the same checkout dir. R=machenbach@chromium.org BUG=692067 Change-Id: I8fd326caefce8623731697a368cbad3159405257 Reviewed-on: https://chromium-review.googlesource.com/442426 Commit-Queue: Andrii Shyshkalov Reviewed-by: Michael Achenbach --- recipe_modules/bot_update/resources/bot_update.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipe_modules/bot_update/resources/bot_update.py b/recipe_modules/bot_update/resources/bot_update.py index 2d9d87eef..c6b12e686 100755 --- a/recipe_modules/bot_update/resources/bot_update.py +++ b/recipe_modules/bot_update/resources/bot_update.py @@ -659,6 +659,12 @@ def apply_gerrit_ref(gerrit_repo, gerrit_ref, root, gerrit_reset, print '===Applying gerrit ref===' print 'Repo is %r @ %r, ref is %r, root is %r' % ( gerrit_repo, base_rev, gerrit_ref, root) + # TODO(tandrii): move the fix below to common rietveld/gerrit codepath. + # Speculative fix: prior bot_update run with Rietveld patch may leave git + # index with unmerged paths. bot_update calls 'checkout --force xyz' thus + # ignoring such paths, but potentially never cleaning them up. The following + # command will do so. See http://crbug.com/692067. + git('reset', '--hard', cwd=root) try: git('retry', 'fetch', gerrit_repo, gerrit_ref, cwd=root, tries=1) git('checkout', 'FETCH_HEAD', cwd=root)