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
diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
index ebd88af..a50c3e6 100644
--- a/gitubuntu/importer.py
+++ b/gitubuntu/importer.py
@@ -102,6 +102,12 @@ VCS_GIT_COMMIT_VALIDATION = re.compile(r'[A-Za-z0-9]{40}')
102# must be called with LC_ALL="C.UTF-8".102# must be called with LC_ALL="C.UTF-8".
103GIT_REMOTE_REF_MISSING_PREFIX = b"fatal: couldn't find remote ref"103GIT_REMOTE_REF_MISSING_PREFIX = b"fatal: couldn't find remote ref"
104104
105# These are the first bytes in stderr from git if "git fetch" is called and
106# prompts for authentication but we have disabled that with
107# GIT_TERMINAL_PROMPT=0. This seems like the least worst method of detecting
108# this case to turn it into a RichHistoryNotFound exception.
109GIT_REMOTE_AUTH_FAILED_PREFIX = b"fatal: could not read Username "
110
105111
106class GitUbuntuImportError(Exception):112class GitUbuntuImportError(Exception):
107 pass113 pass
@@ -1951,8 +1957,12 @@ def fetch_rich_history_from_changes_file(
1951 repo.git_run(1957 repo.git_run(
1952 ['fetch', rich_url, rich_ref],1958 ['fetch', rich_url, rich_ref],
1953 # Since we parse the output, we must make sure the1959 # Since we parse the output, we must make sure the
1954 # output will contain untranslated strings1960 # output will contain untranslated strings. If this
1955 env={'LC_ALL': 'C.UTF-8'},1961 # prompts for auth, then we can just treat it as a
1962 # failure, and it's generally wrong for Vcs-Git to
1963 # require auth anyway, so we should just suppress the
1964 # prompt (LP: #1980982).
1965 env={'LC_ALL': 'C.UTF-8', 'GIT_TERMINAL_PROMPT': '0'},
1956 )1966 )
1957 except CalledProcessError as e:1967 except CalledProcessError as e:
1958 if (1968 if (
@@ -1960,6 +1970,11 @@ def fetch_rich_history_from_changes_file(
1960 e.stderr.startswith(GIT_REMOTE_REF_MISSING_PREFIX)1970 e.stderr.startswith(GIT_REMOTE_REF_MISSING_PREFIX)
1961 ):1971 ):
1962 raise RichHistoryNotFoundError() from e1972 raise RichHistoryNotFoundError() from e
1973 elif (
1974 e.stderr and
1975 e.stderr.startswith(GIT_REMOTE_AUTH_FAILED_PREFIX)
1976 ):
1977 raise RichHistoryNotFoundError() from e
1963 else:1978 else:
1964 raise1979 raise
1965 except tenacity.RetryError as e:1980 except tenacity.RetryError as e:

Subscribers

People subscribed via source and target branches