fix(wiki): 修正 API 路径,添加 /open/ 前缀匹配文档
文档指定 wiki API 路径为 /wiki/open/xxx,但代码中遗漏了 /open/ 前缀。 修正所有 wiki 命令的 API 路径: - /wiki/wikiPages → /wiki/open/wikiPages - /wiki/getWiki → /wiki/open/getWiki - /wiki/createWiki → /wiki/open/createWiki - /wiki/updateWiki → /wiki/open/updateWiki - /wiki/deleteWiki → /wiki/open/deleteWiki 同步更新测试文件和变更文档中的路径引用。
This commit is contained in:
parent
13fa90183f
commit
3ca9005ca2
|
|
@ -5,7 +5,7 @@
|
|||
Adds a new `wiki` shortcut group so maintainers and agents can manage a
|
||||
repository's wiki without falling back to Raw API calls. Wiki was listed in the
|
||||
competition guide as a desired capability and previously had no shortcut
|
||||
coverage. The commands wrap GitLink's `/api/wiki/*` and `/api/wikiExport/*`
|
||||
coverage. The commands wrap GitLink's `/api/wiki/open/*` and `/api/wikiExport/*`
|
||||
endpoints, which require the numeric GitLink project ID in addition to
|
||||
owner/repo.
|
||||
|
||||
|
|
@ -13,11 +13,11 @@ owner/repo.
|
|||
|
||||
| Command | Purpose | Endpoint |
|
||||
|---------|---------|----------|
|
||||
| `gitlink-cli wiki +list` | List wiki pages | `GET /wiki/wikiPages` |
|
||||
| `gitlink-cli wiki +view` | View a wiki page | `GET /wiki/getWiki` |
|
||||
| `gitlink-cli wiki +create` | Create a wiki page | `POST /wiki/createWiki` |
|
||||
| `gitlink-cli wiki +update` | Update a wiki page | `PUT /wiki/updateWiki` |
|
||||
| `gitlink-cli wiki +delete` | Delete a wiki page | `DELETE /wiki/deleteWiki` |
|
||||
| `gitlink-cli wiki +list` | List wiki pages | `GET /wiki/open/wikiPages` |
|
||||
| `gitlink-cli wiki +view` | View a wiki page | `GET /wiki/open/getWiki` |
|
||||
| `gitlink-cli wiki +create` | Create a wiki page | `POST /wiki/open/createWiki` |
|
||||
| `gitlink-cli wiki +update` | Update a wiki page | `PUT /wiki/open/updateWiki` |
|
||||
| `gitlink-cli wiki +delete` | Delete a wiki page | `DELETE /wiki/open/deleteWiki` |
|
||||
| `gitlink-cli wiki +export` | Export the wiki | `GET /wikiExport/wikiExport-wrapper` |
|
||||
|
||||
## Behaviour
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func Shortcuts(translators ...*i18n.Translator) []*common.Shortcut {
|
|||
return err
|
||||
}
|
||||
q := baseQuery(ctx, projectID)
|
||||
env, err := ctx.CallAPIWithQuery("GET", "/wiki/wikiPages", q)
|
||||
env, err := ctx.CallAPIWithQuery("GET", "/wiki/open/wikiPages", q)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ func Shortcuts(translators ...*i18n.Translator) []*common.Shortcut {
|
|||
}
|
||||
q := baseQuery(ctx, projectID)
|
||||
q.Set("pageName", page)
|
||||
env, err := ctx.CallAPIWithQuery("GET", "/wiki/getWiki", q)
|
||||
env, err := ctx.CallAPIWithQuery("GET", "/wiki/open/getWiki", q)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -90,14 +90,14 @@ func Shortcuts(translators ...*i18n.Translator) []*common.Shortcut {
|
|||
Description: tr.T("cmd.wiki.create.short"),
|
||||
Long: tr.T("cmd.wiki.create.long"),
|
||||
Flags: writeFlags(),
|
||||
Run: runWrite("POST", "/wiki/createWiki", true),
|
||||
Run: runWrite("POST", "/wiki/open/createWiki", true),
|
||||
},
|
||||
{
|
||||
Name: "update",
|
||||
Description: tr.T("cmd.wiki.update.short"),
|
||||
Long: tr.T("cmd.wiki.update.long"),
|
||||
Flags: writeFlags(),
|
||||
Run: runWrite("PUT", "/wiki/updateWiki", false),
|
||||
Run: runWrite("PUT", "/wiki/open/updateWiki", false),
|
||||
},
|
||||
{
|
||||
Name: "delete",
|
||||
|
|
@ -124,9 +124,9 @@ func Shortcuts(translators ...*i18n.Translator) []*common.Shortcut {
|
|||
"pageName": page,
|
||||
}
|
||||
if ctx.Arg("dry-run") == "true" {
|
||||
return dryRun(ctx, "DELETE", "/wiki/deleteWiki", body)
|
||||
return dryRun(ctx, "DELETE", "/wiki/open/deleteWiki", body)
|
||||
}
|
||||
env, err := ctx.CallAPI("DELETE", "/wiki/deleteWiki", body)
|
||||
env, err := ctx.CallAPI("DELETE", "/wiki/open/deleteWiki", body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func TestWikiListResolvesProjectID(t *testing.T) {
|
|||
case "/alice/demo.json":
|
||||
sawRepo = true
|
||||
writeJSON(w, map[string]interface{}{"id": float64(4242)})
|
||||
case "/wiki/wikiPages.json":
|
||||
case "/wiki/open/wikiPages.json":
|
||||
sawList = true
|
||||
if got := r.URL.Query().Get("projectId"); got != "4242" {
|
||||
t.Fatalf("projectId = %q, want 4242", got)
|
||||
|
|
@ -89,7 +89,7 @@ func TestWikiListResolvesProjectID(t *testing.T) {
|
|||
|
||||
func TestWikiViewExplicitProjectID(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/wiki/getWiki.json" {
|
||||
if r.URL.Path != "/wiki/open/getWiki.json" {
|
||||
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||
}
|
||||
if got := r.URL.Query().Get("pageName"); got != "Home" {
|
||||
|
|
@ -123,7 +123,7 @@ func TestWikiViewMissingPage(t *testing.T) {
|
|||
|
||||
func TestWikiCreateEncodesContent(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/wiki/createWiki.json" {
|
||||
if r.URL.Path != "/wiki/open/createWiki.json" {
|
||||
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||
}
|
||||
body := decodeBody(t, r)
|
||||
|
|
@ -185,7 +185,7 @@ func TestWikiCreateContentFile(t *testing.T) {
|
|||
|
||||
func TestWikiUpdateWithoutContent(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/wiki/updateWiki.json" {
|
||||
if r.URL.Path != "/wiki/open/updateWiki.json" {
|
||||
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||
}
|
||||
body := decodeBody(t, r)
|
||||
|
|
@ -221,7 +221,7 @@ func TestWikiDeleteDryRun(t *testing.T) {
|
|||
|
||||
func TestWikiDelete(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/wiki/deleteWiki.json" {
|
||||
if r.URL.Path != "/wiki/open/deleteWiki.json" {
|
||||
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||
}
|
||||
if r.Method != http.MethodDelete {
|
||||
|
|
|
|||
Loading…
Reference in New Issue