mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
70ee4dd313
commit
f7f9dd4deb
4
error.py
4
error.py
@ -107,6 +107,10 @@ class GitError(RepoError):
|
|||||||
return self.message
|
return self.message
|
||||||
|
|
||||||
|
|
||||||
|
class GitAuthError(RepoExitError):
|
||||||
|
"""Cannot talk to remote due to auth issue."""
|
||||||
|
|
||||||
|
|
||||||
class GitcUnsupportedError(RepoExitError):
|
class GitcUnsupportedError(RepoExitError):
|
||||||
"""Gitc no longer supported."""
|
"""Gitc no longer supported."""
|
||||||
|
|
||||||
|
15
project.py
15
project.py
@ -32,6 +32,7 @@ import urllib.parse
|
|||||||
|
|
||||||
from color import Coloring
|
from color import Coloring
|
||||||
from error import DownloadError
|
from error import DownloadError
|
||||||
|
from error import GitAuthError
|
||||||
from error import GitError
|
from error import GitError
|
||||||
from error import ManifestInvalidPathError
|
from error import ManifestInvalidPathError
|
||||||
from error import ManifestInvalidRevisionError
|
from error import ManifestInvalidRevisionError
|
||||||
@ -2713,6 +2714,20 @@ class Project:
|
|||||||
file=output_redir,
|
file=output_redir,
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
elif (
|
||||||
|
ret == 128
|
||||||
|
and gitcmd.stdout
|
||||||
|
and "remote helper 'sso' aborted session" in gitcmd.stdout
|
||||||
|
):
|
||||||
|
# User needs to be authenticated, and Git wants to prompt for
|
||||||
|
# username and password.
|
||||||
|
print(
|
||||||
|
"git requires authentication, but repo cannot perform "
|
||||||
|
"interactive authentication.",
|
||||||
|
file=output_redir,
|
||||||
|
)
|
||||||
|
raise GitAuthError(gitcmd.stdout)
|
||||||
|
break
|
||||||
elif current_branch_only and is_sha1 and ret == 128:
|
elif current_branch_only and is_sha1 and ret == 128:
|
||||||
# Exit code 128 means "couldn't find the ref you asked for"; if
|
# Exit code 128 means "couldn't find the ref you asked for"; if
|
||||||
# we're in sha1 mode, we just tried sync'ing from the upstream
|
# we're in sha1 mode, we just tried sync'ing from the upstream
|
||||||
|
Loading…
Reference in New Issue
Block a user