diff --git a/pkg/cmd/repo/rename/rename.go b/pkg/cmd/repo/rename/rename.go index 225a4a39f..6d073941b 100644 --- a/pkg/cmd/repo/rename/rename.go +++ b/pkg/cmd/repo/rename/rename.go @@ -77,12 +77,11 @@ func renameRun(opts *RenameOptions) error { if err != nil { return fmt.Errorf("argument error: %w", err) } - - fields := []string{"name", "owner", "id"} - repoDetails, err := api.FetchRepository(apiClient, repo, fields) - if err != nil { - return err - } + // fields := []string{"name", "owner", "id"} + // repoDetails, err := api.FetchRepository(apiClient, repo, fields) + // if err != nil { + // return err + // } input := renameRepo{ Owner: repo.RepoOwner(), @@ -90,7 +89,7 @@ func renameRun(opts *RenameOptions) error { Name: newRepoName, } - err = runRename(apiClient, repo.RepoHost(), repoDetails, input) + err = runRename(apiClient, repo.RepoHost(), input) if err != nil { return fmt.Errorf("API called failed: %s, please check your parameters", err.Error()) } @@ -102,8 +101,8 @@ func renameRun(opts *RenameOptions) error { return nil } -func runRename(apiClient *api.Client, hostname string, repoDetails *api.Repository, input renameRepo) error { - path := fmt.Sprintf("repos/%s/%s", repoDetails.Owner.Login, repoDetails.Name) +func runRename(apiClient *api.Client, hostname string, input renameRepo) error { + path := fmt.Sprintf("repos/%s/%s", input.Owner, input.Repository) body := &bytes.Buffer{} enc := json.NewEncoder(body) diff --git a/pkg/cmd/repo/rename/rename_test.go b/pkg/cmd/repo/rename/rename_test.go index 42c9a1479..750ac1e3d 100644 --- a/pkg/cmd/repo/rename/rename_test.go +++ b/pkg/cmd/repo/rename/rename_test.go @@ -85,20 +85,6 @@ func TestRenameRun(t *testing.T) { }, wantOut: "✓ Renamed repository OWNER/NEW_REPO\n", httpStubs: func(reg *httpmock.Registry) { - reg.Register( - httpmock.GraphQL(`query RepositoryInfo\b`), - httpmock.StringResponse(` - { - "data": { - "repository": { - "id": "THE-ID", - "name": "REPO", - "owner": { - "login": "OWNER" - } - } - } - }`)) reg.Register( httpmock.REST("PATCH", "repos/OWNER/REPO"), httpmock.StatusStringResponse(204, "{}")) @@ -108,26 +94,12 @@ func TestRenameRun(t *testing.T) { { name: "owner repo change name notty", opts: RenameOptions{ - oldRepoName: "OWNER/REPO", + oldRepoName: "NON_OWNER/REPO", newRepoName: "NEW_REPO", }, httpStubs: func(reg *httpmock.Registry) { reg.Register( - httpmock.GraphQL(`query RepositoryInfo\b`), - httpmock.StringResponse(` - { - "data": { - "repository": { - "id": "THE-ID", - "name": "REPO", - "owner": { - "login": "OWNER" - } - } - } - }`)) - reg.Register( - httpmock.REST("PATCH", "repos/OWNER/REPO"), + httpmock.REST("PATCH", "repos/NON_OWNER/REPO"), httpmock.StatusStringResponse(200, "{}")) }, stdoutTTY: false,