~racb/git-ubuntu:prepare-upload-fetch

Last commit made on 2023-07-18
Get this branch:
git clone -b prepare-upload-fetch https://git.launchpad.net/~racb/git-ubuntu
Only Robie Basak can upload to this branch. If you are Robie Basak please log in for upload directions.

Branch merges

Branch information

Name:
prepare-upload-fetch
Repository:
lp:~racb/git-ubuntu

Recent commits

4fd07c8... by Robie Basak

sandbox/gu-build: remove duplication of CLI args

These now exist in prepare_upload.py, so we can call that function
instead. That API isn't stable, but Steve prefers that to this code
duplication in his review in the MP, and I don't have a strong opinion.

2b27577... by Robie Basak

sandbox/gu-build: update for API changes

prepare-upload's internal API has changed, so update gu-build to match.

475682b... by Robie Basak

prepare_upload: rename printargs to establish_args

Now that the Python printargs method doesn't actually print the
arguments, it's a misnomer and establish_args is better. "Establish"
because it has side-effects (possible fetch, push, force-push) before
the args are known to be correct.

952dd02... by Robie Basak

prepare-upload: fix docstrings

4feceea... by Robie Basak

prepare-upload: allow arguments either side

5b75701... by Robie Basak

prepare-upload: add --force-push

Add a --force-push command to pass on as --force to "git push", so that
if an uploader has amended their branch locally, they can push that rich
history directly with prepare-upload.

Since we now fetch first, we can detect when a force push would be
required, and fail with a friendly error message if this is the case and
--force-push was not specified.

LP: #2015488

66c2e7c... by Robie Basak

Rewrite prepare-upload to fetch before push

This is a major refactoring/rewrite of the prepare-upload code. So much
changed that it didn't seem worth breaking it down. It's probably easier
to review afresh.

Functionally, what has changed is that we now fetch from the remote
using its default configured refspecs first, assuming that this will
update the remote tracking branch following normal conventions. Then we
can determine if the remote branch already contains our rich history or
not. We then only push if it does not.

In the code, this involved considerable refactoring. There is now a
Parameters namedtuple that carries the various facts around, and the
determination of these facts are moved into a classmethod constructor.
Various common steps between the "args" and "mangle" operations are
broken out.

Tests are updated and added accordingly.

LP: #1999177

a0a1ef5... by Robie Basak

Drop amavisd-new from denylist

This import was fixed by the previous commit.

8a489b3... by Robie Basak

importer: ignore rich history requiring auth

Rich history may be supplied in such a way that fetching it requires
authentication. For example, Launchpad does this when referring to a
repository that does not exist, since a private repository may become
visible following authentication.

For rich history purposes, we should ignore this case and ensure that
git does not prompt the user for authentication but instead treat the
case as "rich history not provided".

It does not seem worth arranging a test for this, since we would need to
fake a remote repository that requires authentication and we don't
currently have (and until now have not needed) a test fixture for that.
I have tested this implementation manually. It is unlikely to regress in
our code base. If it were to regress because a future version of git
changes behaviour, then behaviour would revert back to a soft failure,
and we would be able to detect and debug the problem from there.

LP: #1980982

fe21a9f... by Robie Basak

snap.sh: run snapcraft with sudo

A regression in snapcraft causes it to start failing with:

    Sorry, an error occurred in Snapcraft:
    [Errno 13] Permission denied: '/etc/apt/keyrings'

We run snapcraft with --destructive-mode. Presumably it used to use
sudo.

A workaround is to just run the whole thing with sudo ourselves.

See also my upstream report:
https://github.com/snapcore/snapcraft/issues/4225