diff --git a/internal/topdata/parts_manifest.go b/internal/topdata/parts_manifest.go index 5c97731..725a95a 100644 --- a/internal/topdata/parts_manifest.go +++ b/internal/topdata/parts_manifest.go @@ -18,7 +18,7 @@ import ( const ( defaultSowAssetsRepoOwner = "ShadowsOverWestgate" defaultSowAssetsRepoName = "sow-assets" - defaultGiteaBaseURL = "https://gitea.westgate.pw" + defaultGiteaBaseURL = "https://git.westgate.pw" partsManifestReleaseTag = "parts-manifest-current" partsManifestAssetName = "sow-parts-manifest.json" partsManifestCacheFileName = "sow-parts-manifest.json" @@ -148,7 +148,7 @@ func parseRepoSpec(raw string) (giteaRepoSpec, bool) { func normalizeGiteaHTTPHost(host string) string { host = strings.TrimSpace(host) if strings.HasPrefix(host, "git-ssh.") { - return "gitea." + strings.TrimPrefix(host, "git-ssh.") + return "git." + strings.TrimPrefix(host, "git-ssh.") } return host } diff --git a/internal/topdata/parts_manifest_test.go b/internal/topdata/parts_manifest_test.go index aa5424c..565d966 100644 --- a/internal/topdata/parts_manifest_test.go +++ b/internal/topdata/parts_manifest_test.go @@ -7,7 +7,7 @@ func TestParseRepoSpecNormalizesWestgateSSHHostToPublicGiteaHost(t *testing.T) { if !ok { t.Fatal("expected SSH remote to parse") } - if spec.BaseURL != "https://gitea.westgate.pw" { + if spec.BaseURL != "https://git.westgate.pw" { t.Fatalf("expected public Gitea base URL, got %q", spec.BaseURL) } if spec.Owner != "ShadowsOverWestgate" || spec.Repo != "sow-module" { diff --git a/internal/topdata/stub_test.go b/internal/topdata/stub_test.go new file mode 100644 index 0000000..9ffc3a9 --- /dev/null +++ b/internal/topdata/stub_test.go @@ -0,0 +1,35 @@ +package topdata + +import ( + "net/http" + "net/http/httptest" + "testing" +) + +// stubEmptyPartsManifest points the released-parts-manifest fetch at a local +// httptest server that serves an empty (but structurally valid) manifest, so a +// build/compare test exercises native build behaviour without reaching the live +// Gitea host. Use it in tests that build the non-optional `parts` consumer but +// do not depend on any released part rows. +// +// It is per-test (t.Setenv) on purpose: a package-global SOW_ASSETS_SERVER_URL +// would override the git-remote-derived server that other tests configure. +func stubEmptyPartsManifest(t *testing.T) { + t.Helper() + var srv *httptest.Server + srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/api/v1/repos/ShadowsOverWestgate/sow-assets/releases/tags/parts-manifest-current": + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"assets":[{"name":"sow-parts-manifest.json","browser_download_url":"` + srv.URL + `/dl/sow-parts-manifest.json"}]}`)) + case "/dl/sow-parts-manifest.json": + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"repo":"ShadowsOverWestgate/sow-assets","ref":"main","categories":{"belt":[],"bicep":[],"chest":[],"foot":[],"forearm":[],"leg":[],"neck":[],"pelvis":[],"robe":[],"shin":[],"shoulder":[]}}`)) + default: + http.NotFound(w, r) + } + })) + t.Cleanup(srv.Close) + t.Setenv("SOW_ASSETS_SERVER_URL", srv.URL) + t.Setenv("SOW_ASSETS_REPO", "ShadowsOverWestgate/sow-assets") +} diff --git a/internal/topdata/topdata_test.go b/internal/topdata/topdata_test.go index 6f038e7..9fcbe7f 100644 --- a/internal/topdata/topdata_test.go +++ b/internal/topdata/topdata_test.go @@ -2499,6 +2499,7 @@ func TestBuildReferenceAndCompareReference(t *testing.T) { func TestCompareReferenceHandlesMixedModeOutputListMismatch(t *testing.T) { root := testProjectRoot(t) + stubEmptyPartsManifest(t) mkdirAll(t, filepath.Join(root, "topdata", "data", "parts")) writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n") writeFile(t, filepath.Join(root, "topdata", "data", "parts", "belt.json"), `{ @@ -2834,6 +2835,7 @@ func TestBuildAppliesNonTLKOverrides(t *testing.T) { func TestBuildFallsBackWhenProjectMigrationIsIncomplete(t *testing.T) { root := testProjectRoot(t) + stubEmptyPartsManifest(t) mkdirAll(t, filepath.Join(root, "topdata", "data", "parts")) writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n") writeFile(t, filepath.Join(root, "topdata", "data", "parts", "belt.json"), `{ @@ -13470,7 +13472,7 @@ func TestBuildNativeRejectsGitRepoTopDataAssetsOverride(t *testing.T) { writeFile(t, filepath.Join(root, "reference", "build.py"), "print('ok')\n") proj := testProject(root) - proj.Config.TopData.Assets = "ssh://git@gitea.westgate.pw:2222/ShadowsOverWestgate/sow-assets.git" + proj.Config.TopData.Assets = "ssh://git@git.westgate.pw:2222/ShadowsOverWestgate/sow-assets.git" _, err := BuildNative(proj, nil) if err == nil || !strings.Contains(err.Error(), "no longer supports git repo specs") {