Skip to content

Infer bug_tracking_url and code_view_url from vcs_url#4944

Open
Kaushik-Kumar-CEG wants to merge 1 commit intoaboutcode-org:developfrom
Kaushik-Kumar-CEG:4943/infer-urls-from-vcs
Open

Infer bug_tracking_url and code_view_url from vcs_url#4944
Kaushik-Kumar-CEG wants to merge 1 commit intoaboutcode-org:developfrom
Kaushik-Kumar-CEG:4943/infer-urls-from-vcs

Conversation

@Kaushik-Kumar-CEG
Copy link
Copy Markdown

Fixes #4943

This PR adds a post-parsing step to automatically infer bug_tracking_url and code_view_url from a package's vcs_url if they aren't already provided in the manifest.

It handles standard HTTPS links, as well as git@ SSH strings and git+ prefixes, stripping trailing .git suffixes so the final URLs resolve properly in a browser.

Added tests covering all 4 requested platforms (GitHub, GitLab, Codeberg, and Bitbucket) alongside the URL edge cases.

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Copy link
Copy Markdown
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Kaushik-Kumar-CEG, see comments for your consideration.

Comment thread src/packagedcode/models.py
Comment thread src/packagedcode/utils.py Outdated

def parse_vcs_urls(vcs_url):
'''
given a vcs_url, return (code_view_url, bug_tracking_url) when the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You misunderstand code view URLs, this should showthe source tree at a specific version/commit and not just the default code view.

Add this for pinned packages with exact versions only. No need to populate this for purls without versions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed! code_view_url now points to the tagged source tree (e.g. /tree/1.2.3 for GitHub) and is only populated when the package has a concrete version

@@ -128,3 +129,45 @@ def test_normalize_vcs_url_does_not_fail_on_empty(self):
assert normalize_vcs_url(None) == None
assert normalize_vcs_url('') == None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprises there are no test expectation changes, there should be lots of test files with updated URLs, can you look for/fix test failures?

Copy link
Copy Markdown
Author

@Kaushik-Kumar-CEG Kaushik-Kumar-CEG Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, fixed. Updated the expected fixtures across the test suite (SCANCODE_REGEN_TEST_FIXTURES) — they now include the inferred URLs

@Kaushik-Kumar-CEG Kaushik-Kumar-CEG force-pushed the 4943/infer-urls-from-vcs branch from 43257b0 to cb98430 Compare April 21, 2026 12:07
Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
@Kaushik-Kumar-CEG Kaushik-Kumar-CEG force-pushed the 4943/infer-urls-from-vcs branch from cb98430 to eef1893 Compare April 21, 2026 13:13
@Kaushik-Kumar-CEG
Copy link
Copy Markdown
Author

Kaushik-Kumar-CEG commented Apr 21, 2026

@AyanSinhaMahapatra
Updated the PR based on your review. code_view_url now points to the version-specific source tree and is only set for packages with a concrete version. Test fixtures updated across the suite. All locals test passing

ready for review :)

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.

Infer bug_tracking_url and code_view_url from vcs_url for major code hosting platforms

2 participants