From 77569908de07daee32019019a9c53cb0fca0a56d Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Fri, 15 Apr 2022 12:41:19 -0700 Subject: [PATCH] Merge bot: Always set up username on gce Sligthly changes the logic. If we are on GCE, always use the authdaemon and set up the git user info for the service account. Outside of GCE just check if a cookie is available. BUG=None TEST=Faked out is_gce_instance and ran locally Change-Id: Icf4c521b650b5d47f395a59695d1f1470621f661 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585016 Reviewed-by: Anton Romanov Tested-by: Dennis Kempin --- tools/chromeos/merge_bot | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/chromeos/merge_bot b/tools/chromeos/merge_bot index 86e4b148a7..438f94cefb 100755 --- a/tools/chromeos/merge_bot +++ b/tools/chromeos/merge_bot @@ -175,19 +175,19 @@ def setup_tracking_branch(branch_name: str, tracking: str): def gerrit_prerequisites(): "Make sure we can upload to gerrit." - # Make sure we have http cookies to access gerrit - cookie_file = git("config http.cookiefile").stdout(check=False) - if not cookie_file: - if is_gce_instance(): - # Grab http cookies for accessing GOB. See go/gob-gce - gcompute_path = f"{os.environ['KOKORO_ARTIFACTS_DIR']}/gcompute-tools" - git("clone", "https://gerrit.googlesource.com/gcompute-tools", gcompute_path).fg() - cmd(f"{gcompute_path}/git-cookie-authdaemon", "--no-fork").fg() + if is_gce_instance(): + # Grab http cookies for accessing GOB. See go/gob-gce + gcompute_path = f"{os.environ['KOKORO_ARTIFACTS_DIR']}/gcompute-tools" + git("clone", "https://gerrit.googlesource.com/gcompute-tools", gcompute_path).fg() + cmd(f"{gcompute_path}/git-cookie-authdaemon", "--no-fork").fg() - # Setup correct user info for the GCE service account. - git("config user.name", quoted("Crosvm Bot")) - git("config user.email", quoted("crosvm-bot@crosvm-packages.iam.gserviceaccount.com")) - else: + # Setup correct user info for the GCE service account. + git("config user.name", quoted("Crosvm Bot")).fg() + git("config user.email", quoted("crosvm-bot@crosvm-packages.iam.gserviceaccount.com")).fg() + else: + # Make sure we have http cookies to access gerrit + cookie_file = git("config http.cookiefile").stdout(check=False) + if not cookie_file: print("Cannot access gerrit without http cookies.") print(f"Install one via: {GERRIT_URL}/new-password") sys.exit(1)