feat(watchpr): poll GitHub PRs alongside Gitea
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline failed
ci/woodpecker/pr/test Pipeline was successful

This commit is contained in:
2026-11-22 01:51:26 +11:00
parent 10d93aaa90
commit 161a33c2ed
11 changed files with 983 additions and 32 deletions
+33
View File
@@ -181,3 +181,36 @@ func TestRemoteHost(t *testing.T) {
}
}
}
func TestParseWatchRef(t *testing.T) {
tests := []struct {
in string
want PRRef
}{
{"unkin/repo#4", PRRef{Owner: "unkin", Repo: "repo", Number: 4}},
{"github:IUCLabs/app#12", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
{"github:IUCLabs/app:12", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
{" https://github.com/IUCLabs/app/pull/12 ", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
{"https://github.com/IUCLabs/app/pull/12/", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
}
for _, tt := range tests {
got, err := ParseWatchRef(tt.in)
if err != nil || got != tt.want {
t.Errorf("ParseWatchRef(%q) = %+v, %v; want %+v", tt.in, got, err, tt.want)
}
}
for _, bad := range []string{
"github:IUCLabs#1", "github:IUCLabs/app#0", "https://github.com/IUCLabs/app/issues/3",
"https://github.com/IUCLabs/app/pull/3/files", "https://github.com/IUCLabs/app/pull/x", "gitlab:o/r#1",
} {
if got, err := ParseWatchRef(bad); err == nil {
t.Errorf("ParseWatchRef(%q) = %+v, want error", bad, got)
}
}
if s := (PRRef{Forge: ForgeGitHub, Owner: "o", Repo: "r", Number: 3}).String(); s != "github:o/r#3" {
t.Errorf("String() = %q", s)
}
if _, err := ParsePRRef("github:o/r#3"); err == nil {
t.Error("ParsePRRef must not accept GitHub refs: Gitea-only tools use it")
}
}