Skip to content

Fix Cgit parse_url truncating repository names - #2171

Merged
mergify[bot] merged 1 commit into
fedora-infra:masterfrom
patelshivani2283-lab:fix-2170-cgit-parse-url
Nov 13, 2026
Merged

mergify[bot] merged 1 commit into
fedora-infra:masterfrom
patelshivani2283-lab:fix-2170-cgit-parse-url

Conversation

@patelshivani2283-lab

Copy link
Copy Markdown
Contributor

Resolves #2170

Problem

CgitBackend.parse_url used str.rstrip(".git"), which strips any trailing occurrences of the characters ., g, i, and t instead of stripping only a literal .git suffix. As a result:

  • A repository named cgit (e.g. https://git.zx2c4.com/cgit.git or https://git.zx2c4.com/cgit) was imported as 'c'.
  • A repository named git (e.g. https://git.kernel.org/pub/scm/git/git.git) was imported as '' (empty string).
  • A repository named widget was imported as 'widge'.
  • A repository named edit was imported as 'ed'.

Solution

  • Use utilities.remove_suffix(url.rstrip("/"), ".git").split("/")[-1] to remove only a literal .git suffix.
  • Add regression unit tests in anitya/tests/lib/backends/test_cgit.py covering repository names ending in those characters (cgit, git, widget, waiting).
  • Add towncrier news fragment news/2170.bug.

CgitBackend.parse_url used str.rstrip(".git"), which strips any trailing
run of the characters '.', 'g', 'i' and 't' instead of a single .git suffix.
As a result a repository named widget was imported as widge, cgit as c,
and git as an empty string. Remove only a literal .git suffix using
utilities.remove_suffix, and add regression tests for names ending in
those characters.

Fixes fedora-infra#2170

Signed-off-by: patelshivani2283-lab <patelshivani2283@gmail.com>
@patelshivani2283-lab
patelshivani2283-lab requested a review from a team as a code owner November 13, 2026 05:16
@mergify

mergify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@mergify
mergify Bot merged commit ed277bb into fedora-infra:master Nov 13, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Cgit parse_url truncating repository names

2 participants