diff options
author | Josip Sokcevic <sokcevic@chromium.org> | 2024-10-03 20:32:04 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-10-03 20:47:50 +0000 |
commit | f7f9dd4deb3b92bf175a0411dac60e7b6fdd9cfa (patch) | |
tree | 2af4bfdc9b02d2c44a2652af7ba1a62170d3af7e /project.py | |
parent | 70ee4dd313bda9cca7fdd826f1c58de03fad1121 (diff) | |
download | git-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>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -32,6 +32,7 @@ import urllib.parse | |||
32 | 32 | ||
33 | from color import Coloring | 33 | from color import Coloring |
34 | from error import DownloadError | 34 | from error import DownloadError |
35 | from error import GitAuthError | ||
35 | from error import GitError | 36 | from error import GitError |
36 | from error import ManifestInvalidPathError | 37 | from error import ManifestInvalidPathError |
37 | from error import ManifestInvalidRevisionError | 38 | from 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 |