9d1519222c
New internal/forge (provider-abstracted, Gitea impl via code.gitea.io/sdk/gitea) with tested remote-URL parsing and read+write ops: list open PRs, and merge-and-cleanup (squash-merge + delete head branch when head/base share a repo). Service resolves repo->owner/repo from remotes (prefers origin) and records a pr-merged event; config gains GITEA_URL/GITEA_TOKEN (forge disabled without both). MCP tools list_prs and merge_and_cleanup_pr (merge tool tells Claude to confirm first, 1.4). HTTP GET /api/repo/prs, POST /api/repo/pr/merge. New <pr-list> component with a confirming Merge & clean up button, hidden when no forge. Verified graceful-disabled path; real merge pending token + a designated PR. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
package forge
|
|
|
|
import "testing"
|
|
|
|
func TestParseRemote(t *testing.T) {
|
|
cases := []struct {
|
|
in string
|
|
host, owner, repo string
|
|
ok bool
|
|
}{
|
|
{"https://git.nilles.net/TBNilles/GitManager.git", "git.nilles.net", "TBNilles", "GitManager", true},
|
|
{"https://git.nilles.net/TBNilles/GitManager", "git.nilles.net", "TBNilles", "GitManager", true},
|
|
{"git@git.nilles.net:TBNilles/GitManager.git", "git.nilles.net", "TBNilles", "GitManager", true},
|
|
{"https://git.nilles.net:3000/org/sub/Repo.git", "git.nilles.net", "sub", "Repo", true},
|
|
{"ssh://git@git.nilles.net:2222/TBNilles/GitManager.git", "git.nilles.net", "TBNilles", "GitManager", true},
|
|
{"not a url", "", "", "", false},
|
|
{"https://git.nilles.net/", "", "", "", false},
|
|
}
|
|
for _, c := range cases {
|
|
host, owner, repo, ok := ParseRemote(c.in)
|
|
if ok != c.ok {
|
|
t.Errorf("ParseRemote(%q) ok = %v, want %v", c.in, ok, c.ok)
|
|
continue
|
|
}
|
|
// Field values only matter on success.
|
|
if ok && (host != c.host || owner != c.owner || repo != c.repo) {
|
|
t.Errorf("ParseRemote(%q) = (%q,%q,%q), want (%q,%q,%q)",
|
|
c.in, host, owner, repo, c.host, c.owner, c.repo)
|
|
}
|
|
}
|
|
}
|