~racb/git-ubuntu:fix-publication-list-truncation

Last commit made on 2022-06-23
Get this branch:
git clone -b fix-publication-list-truncation 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:
fix-publication-list-truncation
Repository:
lp:~racb/git-ubuntu

Recent commits

2133870... by Robie Basak

Refactor _head_version_is_equal

Add a docstring, refactor the code to make it more readable, and rename
the method to match its definition better.

This should not result in any functional change.

0b8cc0b... by Robie Basak

Rewrite launchpad_versions_published_after

The logic in this method can be simplified significantly with a rewrite.
To mitigate any regression, a parametrized unit test is added with the
expected behaviour thought out from the importer spec.

There is still an inefficiency present here. In theory we could skip
importing pocket copies if the branch corresponding to a pocket is
up-to-date. However, currently the algorithm only matches against the
exact date_created attribute of the Launchpad publication object against
which a particular version was first imported. To ensure that branches
are updated if any new pocket copies have occurred, we must "replay"
them all through the importer. Therefore there is potential here for a
future performance improvement.

9addaa0... by Robie Basak

launchpad_versions_published_after: drop return

This return statement is redundant since it's at the end of the method
anyway.

a11bfa8... by Robie Basak

launchpad_versions_published_after: refactor call

We don't need to set args and then call with **args, given that is all
we do with it. Instead, just call self.archive.getPublishedSources()
with keyword arguments directly.

b2f98c1... by Robie Basak

GitUbuntuSourceInformation: dependency injection

Add dependency injection to GitUbuntuSourceInformation. This allows the
creation of this object in tests such that we can mock a
launchpadlib.launchpad.Launchpad object.

284beb9... by Robie Basak

Add unit test for get_head_info()

Now that get_head_info() returns what we expect, we can add a unit test
for it now.

535dca8... by Robie Basak

Use date_created to determine head versions

It's incorrect to use date_published to determine head versions that
will be used to match against Launchpad publications, since we use
date_created at commit creation time. We should be using date_created
consistently instead.

Not doing so means that we often (always?) fail to find a matching
Launchpad publication that is already imported and end up redundantly
reimporting everything from the beginning of time. This is terrible for
performance.

More details on date_created vs. date_published here:
https://irclogs.ubuntu.com/2020/04/16/%23launchpad.html#t13:45

This change is difficult to test right here. Further refactoring follows
in subsequent changes and a test is added later.

LP: #1979650

f5dc43c... by Robie Basak

Clean up get_head_versions()

This method had no tests, and returning a pygit2.Branch object made it
harder to supply test data to other functions that accept data in the
structure returned by this method.

In practice, callers only need the version, commit time and commit hash
of each branch head, so return only exactly this, and adjust all
callers. This should not change any behaviour.

We also adjust and fill out the docstring.

A unit test will follow in a subsequent change. It can't be added here
without fixing a bug first.

5aad111... by Robie Basak

Update default bot account name

usd-importer-bot is now renamed to git-ubuntu-bot as part of catching up
the project rename to git-ubuntu.

2f0e855... by Robie Basak

Update email address default used in tests

Since <email address hidden> no longer exists, we'll use
<email address hidden> instead. This shouldn't affect
production code since the repo_builder and source_builder modules are
only used in tests.