We don't want imported repositories to languish; if imported once into
Launchpad, they should continue to be maintained.
Rather than relying on manual import into the whitelist, we can instead
just dynamically check to see if we have already imported a package, and
if so, treat it as if it is whitelisted.
This implements that, calling it a "team whitelist" and adding a
--team-whitelist option to the poller to specify which Launchpad team
should be consulted in order to determine if a package is already
imported.
As the logic gets more complex, we refactor it all into
a filter function created by
importer_service_poller.create_filter_func(). This neatly simplifies
importer_service.request_imports(). For this to work, we pull out the
Launchpad login into the caller, renaming the object to "lp" everywhere
to match convention elsewhere.
I chose to add has_import_repository() to importer_service.py as it's a
general function that feels like it isn't necessary poller specific. But
I placed create_filter_func() to importer_service_poller.py as the logic
of what to include and exclude is closely tied to the poller itself.
This nicely separates the decision logic and list management in the
poller from the search implementation in the main importer_service.py
service handling library.
As the blacklist and whitelist functionality is now pulled into
create_filter_func(), that functionality is removed from
srcpkgs_to_import_list() and should_import_srcpkg(). This invalidates
the admin tools import-source-packages.py, source-package-walker.py and
update-repository-alias.py, so I've removed them. These tools haven't
been used in a long time anyway. import-source-packages.py and
source-package-walker.py are redundant now that we have the queue driven
importer service implementation. update-repository-alias.py is currently
done by hand, but I intend to replace it with an
imported-repository-driven equivalent anyway.
Finally, this means that scriptutils.py becomes mostly redundant and it
might be worth removing the redundant parts and pulling what's left into
importer_service_poller.py, but this change seems to have gotten big
enough now that I'll leave that for another time.
build.py currently has no tests, so it's difficult to add a test for
this fix. But this is a trivial and obvious improvement, so I think it's
worth landing without.
Now that we have unpinned pygit2, the newer version of pygit2 provides a
pygit2.Repository.descendant_of() method directly, so we can drop our
temporary implementation and adjust the single caller.
We retain the test to ensure that the implementation swap does not
change behaviour.
With LP: #1918967 fixed in snapcraft, we must match and change the
substring of the fingerprint used for the public key file supplied to
snapcraft; otherwise the build fails.