Skip to content

Commit f7f9dd4

Browse files
sokcevicGLUCI
authored andcommitted
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 <[email protected]> Tested-by: Josip Sokcevic <[email protected]> Commit-Queue: Josip Sokcevic <[email protected]>
1 parent 70ee4dd commit f7f9dd4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

error.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def __str__(self):
107107
return self.message
108108

109109

110+
class GitAuthError(RepoExitError):
111+
"""Cannot talk to remote due to auth issue."""
112+
113+
110114
class GitcUnsupportedError(RepoExitError):
111115
"""Gitc no longer supported."""
112116

project.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
from color import Coloring
3434
from error import DownloadError
35+
from error import GitAuthError
3536
from error import GitError
3637
from error import ManifestInvalidPathError
3738
from error import ManifestInvalidRevisionError
@@ -2713,6 +2714,20 @@ def _RemoteFetch(
27132714
file=output_redir,
27142715
)
27152716
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
27162731
elif current_branch_only and is_sha1 and ret == 128:
27172732
# Exit code 128 means "couldn't find the ref you asked for"; if
27182733
# we're in sha1 mode, we just tried sync'ing from the upstream

0 commit comments

Comments
 (0)