Commit 6c692edf authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

Reland "bot_update: Set user.{name,email} when applying patch refs."

This is a reland of e86fe982

Original change's description:
> bot_update: Set user.{name,email} when applying patch refs.
> 
> git rebase complains when user name/email has not been configured, as was
> the case for the Chromium trybot.
> 
> Bug: 643346
> Change-Id: Iab7dac0a98608e09b63a53d5bacb98925701fbfd
> Reviewed-on: https://chromium-review.googlesource.com/1031524
> Reviewed-by: Aaron Gable <agable@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

Bug: 643346
Change-Id: I4b4d07675222d39d704560ed84f9c221e87aba8b
Reviewed-on: https://chromium-review.googlesource.com/1036309Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 1037c743
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import cStringIO import cStringIO
import codecs import codecs
from contextlib import contextmanager
import copy import copy
import ctypes import ctypes
import json import json
...@@ -331,6 +332,24 @@ def gclient_configure(solutions, target_os, target_os_only, target_cpu, ...@@ -331,6 +332,24 @@ def gclient_configure(solutions, target_os, target_os_only, target_cpu,
solutions, target_os, target_os_only, target_cpu, git_cache_dir)) solutions, target_os, target_os_only, target_cpu, git_cache_dir))
@contextmanager
def git_config_if_not_set(key, value):
"""Set git config for key equal to value if key was not set.
If key was not set, unset it once we're done."""
should_unset = True
try:
git('config', '--global', key)
should_unset = False
except SubprocessFailed as e:
git('config', '--global', key, value)
try:
yield
finally:
if should_unset:
git('config', '--global', '--unset', key)
def gclient_sync( def gclient_sync(
with_branch_heads, with_tags, shallow, revisions, break_repo_locks, with_branch_heads, with_tags, shallow, revisions, break_repo_locks,
disable_syntax_validation, gerrit_repo, gerrit_ref, gerrit_reset, disable_syntax_validation, gerrit_repo, gerrit_ref, gerrit_reset,
...@@ -903,21 +922,24 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, ...@@ -903,21 +922,24 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only,
# This forces gclient to always treat solutions deps as unmanaged. # This forces gclient to always treat solutions deps as unmanaged.
for solution_name in list(solution_dirs): for solution_name in list(solution_dirs):
gc_revisions[solution_name] = 'unmanaged' gc_revisions[solution_name] = 'unmanaged'
# Let gclient do the DEPS syncing.
# The branch-head refspec is a special case because its possible Chrome with git_config_if_not_set('user.name', 'chrome-bot'):
# src, which contains the branch-head refspecs, is DEPSed in. with git_config_if_not_set('user.email', 'chrome-bot@chromium.org'):
gclient_output = gclient_sync( # Let gclient do the DEPS syncing.
BRANCH_HEADS_REFSPEC in refs, # The branch-head refspec is a special case because its possible Chrome
TAGS_REFSPEC in refs, # src, which contains the branch-head refspecs, is DEPSed in.
shallow, gclient_output = gclient_sync(
gc_revisions, BRANCH_HEADS_REFSPEC in refs,
break_repo_locks, TAGS_REFSPEC in refs,
disable_syntax_validation, shallow,
gerrit_repo, gc_revisions,
gerrit_ref, break_repo_locks,
gerrit_reset, disable_syntax_validation,
gerrit_rebase_patch_ref, gerrit_repo,
apply_patch_on_gclient) gerrit_ref,
gerrit_reset,
gerrit_rebase_patch_ref,
apply_patch_on_gclient)
# Now that gclient_sync has finished, we should revert any .DEPS.git so that # Now that gclient_sync has finished, we should revert any .DEPS.git so that
# presubmit doesn't complain about it being modified. # presubmit doesn't complain about it being modified.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment