| Index: recipe_modules/bot_update/resources/bot_update.py
|
| diff --git a/recipe_modules/bot_update/resources/bot_update.py b/recipe_modules/bot_update/resources/bot_update.py
|
| index 3211369667372e4ec45a6b52343120b69985a912..2fc8a1504decdbbe33cdfbd52782276687e60c48 100755
|
| --- a/recipe_modules/bot_update/resources/bot_update.py
|
| +++ b/recipe_modules/bot_update/resources/bot_update.py
|
| @@ -465,6 +465,25 @@ def is_broken_repo_dir(repo_dir):
|
| return not path.exists(os.path.join(repo_dir, '.git', 'config'))
|
|
|
|
|
| +def _maybe_break_locks(checkout_path):
|
| + """This removes all .lock files from this repo's .git directory.
|
| +
|
| + In particular, this will cleanup index.lock files, as well as ref lock
|
| + files.
|
| + """
|
| + git_dir = os.path.join(checkout_path, '.git')
|
| + for dirpath, _, filenames in os.walk(git_dir):
|
| + for filename in filenames:
|
| + if filename.endswith('.lock'):
|
| + to_break = os.path.join(dirpath, filename)
|
| + print 'breaking lock: %s' % to_break
|
| + try:
|
| + os.remove(to_break)
|
| + except OSError as ex:
|
| + print 'FAILED to break lock: %s: %s' % (to_break, ex)
|
| + raise
|
| +
|
| +
|
| def git_checkout(solutions, revisions, shallow, refs, git_cache_dir):
|
| build_dir = os.getcwd()
|
| # Before we do anything, break all git_cache locks.
|
| @@ -518,6 +537,18 @@ def git_checkout(solutions, revisions, shallow, refs, git_cache_dir):
|
| refspec = '%s:%s' % (ref, ref.lstrip('+'))
|
| git('fetch', 'origin', refspec, cwd=sln_dir)
|
|
|
| + # Windows sometimes has trouble deleting files.
|
| + # This can make git commands that rely on locks fail.
|
| + # Try a few times in case Windows has trouble again (and again).
|
| + if sys.platform.startswith('win'):
|
| + tries = 3
|
| + while tries:
|
| + try:
|
| + _maybe_break_locks(sln_dir)
|
| + break
|
| + except Exception:
|
| + tries -= 1
|
| +
|
| revision = get_target_revision(name, url, revisions) or 'HEAD'
|
| force_revision(sln_dir, revision)
|
| done = True
|
|
|