Skip to content

Strip only a trailing .git from the remote URL, so ktsu-dev/.github no longer parses as ktsu-dev/hub [patch] - #171

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/remote-url-trailing-git-only
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/remote-url-trailing-git-only

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #164

What was wrong

When GITHUB_REPOSITORY is unset, as on every local run, BuildConfigurationProvider.ParseRepositoryFromRemoteUrl gets owner/repo from the Git remote using .Replace(".git", string.Empty). That removes every .git in the string, not just the suffix:

  • https://github.com/ktsu-dev/.github.git became ktsu-dev/hub
  • git@github.com:ktsu-dev/ktsu-dev.github.io.git became ktsu-dev/ktsu-devhub.io

The wrong value then goes into PROJECT_URL.url and into {PROJECT_URL} in LICENSE.md.

Change

After trimming trailing slashes, only a trailing .git is stripped, compared case-insensitively. This is the same rule WingetService.DetectGitHubRepoAsync already uses.

I didn't merge the two parsers into one, although the issue lists that as optional. The triage note points out that sharing the parser would reach into the area of #162, so this PR stays a one-line fix.

Tests

CreateFromEnvironmentAsync_RemoteContainingDotGit_StripsOnlyTheTrailingSuffix, which goes through the same mocked-remote path as the existing remote tests. Its rows:

  • .github over HTTPS, over SSH, and with no suffix
  • a *.github.io repo over SSH
  • an upper-case .GIT suffix
  • repo.git/, a suffix followed by a slash

Before the fix, 5 of the 6 rows fail (ktsu-dev/hub, ktsu-dev/ktsu-devhub.io, owner/repo.GIT). With the fix, the full KtsuBuild.Tests suite passes (760/760).

🤖 Generated with Claude Code

https://claude.ai/code/session_01PHrrj7bWzA48Gf3akqi476


Generated by Claude Code

…o longer parses as ktsu-dev/hub [patch]

ParseRepositoryFromRemoteUrl removed every ".git" in the URL, so local runs in
ktsu-dev/.github or any *.github.io repository wrote a wrong PROJECT_URL.url and
LICENSE.md. Only a trailing suffix is stripped now, case-insensitively, matching
WingetService.DetectGitHubRepoAsync.

Fixes #164

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PHrrj7bWzA48Gf3akqi476
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 3929b53 into main Sep 28, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/remote-url-trailing-git-only branch September 28, 2026 08:56
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.

Remote-URL parsing strips every ".git" substring, turning ktsu-dev/.github into "ktsu-dev/hub" in PROJECT_URL.url and LICENSE.md

1 participant