def test_fixup(self): self.assertEqual( "git://github.com/jelmer/dulwich", fixup_broken_git_url("git://github.com:jelmer/dulwich"), ) self.assertEqual( "git://github.com/jelmer/dulwich -b blah", fixup_broken_git_url("git://github.com:jelmer/dulwich -b blah"), )
def test_preserves(self): self.assertEqual( "git://github.com/jelmer/dulwich", fixup_broken_git_url("git://github.com/jelmer/dulwich"), ) self.assertEqual( "https://github.com/jelmer/dulwich", fixup_broken_git_url("https://github.com/jelmer/dulwich"), )
def test_strip_username(self): self.assertEqual( "git://github.com/RPi-Distro/pgzero.git", fixup_broken_git_url("git://[email protected]:RPi-Distro/pgzero.git"), ) self.assertEqual( "https://salsa.debian.org/debian-astro-team/pyavm.git", fixup_broken_git_url( "https://[email protected]:debian-astro-team/pyavm.git"), )
def test_freedesktop(self): self.assertEqual( "https://gitlab.freedesktop.org/xorg/xserver", fixup_broken_git_url("git://anongit.freedesktop.org/xorg/xserver"), ) self.assertEqual( "https://gitlab.freedesktop.org/xorg/lib/libSM", fixup_broken_git_url( "git://anongit.freedesktop.org/git/xorg/lib/libSM"), )
def test_github_tree_url(self): self.assertEqual( "https://github.com/blah/blah -b master", fixup_broken_git_url("https://github.com/blah/blah/tree/master"), )
def test_strip_extra_colon(self): self.assertEqual( "https://salsa.debian.org/mckinstry/lcov.git", fixup_broken_git_url( "https://salsa.debian.org:/mckinstry/lcov.git"), )
def test_strip_extra_slash(self): self.assertEqual( "https://salsa.debian.org/salve/auctex.git", fixup_broken_git_url("https://salsa.debian.org//salve/auctex.git"), )
def test_salsa_tree_branch(self): self.assertEqual( "https://salsa.debian.org/jelmer/dulwich -b master", fixup_broken_git_url( "https://salsa.debian.org/jelmer/dulwich/tree/master"), )
def test_salsa_uses_cgit(self): self.assertEqual( "https://salsa.debian.org/jelmer/dulwich", fixup_broken_git_url( "https://salsa.debian.org/cgit/jelmer/dulwich"), )
def test_salsa_not_https(self): self.assertEqual( "https://salsa.debian.org/jelmer/dulwich", fixup_broken_git_url("git://salsa.debian.org/jelmer/dulwich"), )
def test_gnome(self): self.assertEqual( "https://gitlab.gnome.org/GNOME/alacarte", fixup_broken_git_url("https://git.gnome.org/browse/alacarte"), )
def test_anongit(self): self.assertEqual( "https://anongit.kde.org/kdev-php.git", fixup_broken_git_url("git://anongit.kde.org/kdev-php.git"), )
#!/usr/bin/python3 from lintian_brush.fixer import control, report_result from lintian_brush.vcs import fixup_broken_git_url with control as updater: if "Vcs-Git" in updater.source: updater.source['Vcs-Git'] = fixup_broken_git_url( updater.source["Vcs-Git"]) report_result("Fix broken Vcs URL.")
async def update_package_metadata( conn, distribution: str, provided_packages, package_overrides, origin ): logging.info("Updating package metadata.") packages = [] for package in provided_packages: try: override = package_overrides[package.name] except KeyError: vcs_url = package.vcs_url else: vcs_url = override.branch_url or package.vcs_url or None vcs_last_revision = None if package.vcs_type and package.vcs_type.capitalize() == "Git": new_vcs_url = fixup_broken_git_url(vcs_url) if new_vcs_url != vcs_url: logging.info("Fixing up VCS URL: %s -> %s", vcs_url, new_vcs_url) vcs_url = new_vcs_url if package.commit_id: vcs_last_revision = default_mapping.revision_id_foreign_to_bzr( package.commit_id.encode("ascii") ) if package.vcs_type: # Drop the subpath, we're storing it separately. (url, branch, subpath) = split_vcs_url(vcs_url) url = unsplit_vcs_url(url, branch) url = canonicalize_vcs_url(package.vcs_type, url) try: branch_url = convert_debian_vcs_url(package.vcs_type.capitalize(), url) except ValueError as e: logging.info("%s: %s", package.name, e) branch_url = None else: subpath = None branch_url = None if vcs_url: vcs_browser = determine_browser_url(package.vcs_type, vcs_url) else: vcs_browser = None if vcs_browser is None and package.vcs_browser: vcs_browser = package.vcs_browser packages.append( ( package.name, distribution, branch_url if branch_url else None, subpath if subpath else None, package.maintainer_email if package.maintainer_email else None, package.uploader_email if package.uploader_email else [], package.archive_version if package.archive_version else None, package.vcs_type.lower() if package.vcs_type else None, vcs_url, vcs_browser, vcs_last_revision.decode("utf-8") if vcs_last_revision else None, package.vcswatch_status.lower() if package.vcswatch_status else None, package.vcswatch_version if package.vcswatch_version else None, package.insts, package.removed, package.in_base, origin ) ) await conn.executemany( "INSERT INTO package " "(name, distribution, branch_url, subpath, maintainer_email, " "uploader_emails, archive_version, vcs_type, vcs_url, vcs_browse, " "vcs_last_revision, vcswatch_status, vcswatch_version, popcon_inst, " "removed, in_base, origin) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, " "$13, $14, $15, $16, $17) ON CONFLICT (name, distribution) DO UPDATE SET " "branch_url = EXCLUDED.branch_url, " "subpath = EXCLUDED.subpath, " "maintainer_email = EXCLUDED.maintainer_email, " "uploader_emails = EXCLUDED.uploader_emails, " "archive_version = EXCLUDED.archive_version, " "vcs_type = EXCLUDED.vcs_type, " "vcs_url = EXCLUDED.vcs_url, " "vcs_last_revision = EXCLUDED.vcs_last_revision, " "vcs_browse = EXCLUDED.vcs_browse, " "vcswatch_status = EXCLUDED.vcswatch_status, " "vcswatch_version = EXCLUDED.vcswatch_version, " "popcon_inst = EXCLUDED.popcon_inst, " "removed = EXCLUDED.removed, " "in_base = EXCLUDED.in_base", packages, )