Merge ~racb/git-ubuntu:rich-history-auth into git-ubuntu:main

Proposed by Robie Basak
Status: Merged
Merged at revision: 8a489b3d2bee82e6938afb96675528334e9ffcd3
Proposed branch: ~racb/git-ubuntu:rich-history-auth
Merge into: git-ubuntu:main
Diff against target: 44 lines (+17/-2)
1 file modified
gitubuntu/importer.py (+17/-2)
Reviewer Review Type Date Requested Status
Lena Voytek (community) Approve
Server Team CI bot continuous-integration Approve
Canonical Server Reporter Pending
git-ubuntu developers Pending
Review via email: mp+446523@code.launchpad.net

Commit message

Make Jenkins happy

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:820afcd1e0d2db9e431cbbfe6c8b5a91173419c1
https://jenkins.canonical.com/server-team/job/git-ubuntu-ci/33/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: VM Reset
    SUCCESS: Unit Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.canonical.com/server-team/job/git-ubuntu-ci/33//rebuild

review: Approve (continuous-integration)
Revision history for this message
Lena Voytek (lvoytek) wrote :

LGTM, just found one comment that could use some slight rewording. Thanks for adding this!

review: Approve
Revision history for this message
Robie Basak (racb) wrote :

Fixed, thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
2index ebd88af..a50c3e6 100644
3--- a/gitubuntu/importer.py
4+++ b/gitubuntu/importer.py
5@@ -102,6 +102,12 @@ VCS_GIT_COMMIT_VALIDATION = re.compile(r'[A-Za-z0-9]{40}')
6 # must be called with LC_ALL="C.UTF-8".
7 GIT_REMOTE_REF_MISSING_PREFIX = b"fatal: couldn't find remote ref"
8
9+# These are the first bytes in stderr from git if "git fetch" is called and
10+# prompts for authentication but we have disabled that with
11+# GIT_TERMINAL_PROMPT=0. This seems like the least worst method of detecting
12+# this case to turn it into a RichHistoryNotFound exception.
13+GIT_REMOTE_AUTH_FAILED_PREFIX = b"fatal: could not read Username "
14+
15
16 class GitUbuntuImportError(Exception):
17 pass
18@@ -1951,8 +1957,12 @@ def fetch_rich_history_from_changes_file(
19 repo.git_run(
20 ['fetch', rich_url, rich_ref],
21 # Since we parse the output, we must make sure the
22- # output will contain untranslated strings
23- env={'LC_ALL': 'C.UTF-8'},
24+ # output will contain untranslated strings. If this
25+ # prompts for auth, then we can just treat it as a
26+ # failure, and it's generally wrong for Vcs-Git to
27+ # require auth anyway, so we should just suppress the
28+ # prompt (LP: #1980982).
29+ env={'LC_ALL': 'C.UTF-8', 'GIT_TERMINAL_PROMPT': '0'},
30 )
31 except CalledProcessError as e:
32 if (
33@@ -1960,6 +1970,11 @@ def fetch_rich_history_from_changes_file(
34 e.stderr.startswith(GIT_REMOTE_REF_MISSING_PREFIX)
35 ):
36 raise RichHistoryNotFoundError() from e
37+ elif (
38+ e.stderr and
39+ e.stderr.startswith(GIT_REMOTE_AUTH_FAILED_PREFIX)
40+ ):
41+ raise RichHistoryNotFoundError() from e
42 else:
43 raise
44 except tenacity.RetryError as e:

Subscribers

People subscribed via source and target branches