summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosip Sokcevic <sokcevic@chromium.org>2024-10-03 20:32:04 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-10-03 20:47:50 +0000
commitf7f9dd4deb3b92bf175a0411dac60e7b6fdd9cfa (patch)
tree2af4bfdc9b02d2c44a2652af7ba1a62170d3af7e
parent70ee4dd313bda9cca7fdd826f1c58de03fad1121 (diff)
downloadgit-repo-f7f9dd4deb3b92bf175a0411dac60e7b6fdd9cfa.tar.gz
project: Handle git sso auth failures as repo exit
If a user is not authenticated, repo continues execution and it will likely result in more of the same errors being printed. A user is also likely to SIGTERM the process resulting in more errors. This change stops repo sync if any of repositories can't be fetched to Git authentcation using sso helper. We could extend this to all Git authentication Change-Id: I9e471e063450c0a51f25a5e7f12a83064dfb170c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/438522 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
-rw-r--r--error.py4
-rw-r--r--project.py15
2 files changed, 19 insertions, 0 deletions
diff --git a/error.py b/error.py
index 7958a0a1..36bc2129 100644
--- a/error.py
+++ b/error.py
@@ -107,6 +107,10 @@ class GitError(RepoError):
107 return self.message 107 return self.message
108 108
109 109
110class GitAuthError(RepoExitError):
111 """Cannot talk to remote due to auth issue."""
112
113
110class GitcUnsupportedError(RepoExitError): 114class GitcUnsupportedError(RepoExitError):
111 """Gitc no longer supported.""" 115 """Gitc no longer supported."""
112 116
diff --git a/project.py b/project.py
index b29e604f..88dd747b 100644
--- a/project.py
+++ b/project.py
@@ -32,6 +32,7 @@ import urllib.parse
32 32
33from color import Coloring 33from color import Coloring
34from error import DownloadError 34from error import DownloadError
35from error import GitAuthError
35from error import GitError 36from error import GitError
36from error import ManifestInvalidPathError 37from error import ManifestInvalidPathError
37from error import ManifestInvalidRevisionError 38from error import ManifestInvalidRevisionError
@@ -2713,6 +2714,20 @@ class Project:
2713 file=output_redir, 2714 file=output_redir,
2714 ) 2715 )
2715 break 2716 break
2717 elif (
2718 ret == 128
2719 and gitcmd.stdout
2720 and "remote helper 'sso' aborted session" in gitcmd.stdout
2721 ):
2722 # User needs to be authenticated, and Git wants to prompt for
2723 # username and password.
2724 print(
2725 "git requires authentication, but repo cannot perform "
2726 "interactive authentication.",
2727 file=output_redir,
2728 )
2729 raise GitAuthError(gitcmd.stdout)
2730 break
2716 elif current_branch_only and is_sha1 and ret == 128: 2731 elif current_branch_only and is_sha1 and ret == 128:
2717 # Exit code 128 means "couldn't find the ref you asked for"; if 2732 # Exit code 128 means "couldn't find the ref you asked for"; if
2718 # we're in sha1 mode, we just tried sync'ing from the upstream 2733 # we're in sha1 mode, we just tried sync'ing from the upstream