RenameRepo renames the repository on GitHub and returns the renamed repository
(client *Client, repo ghrepo.Interface, newRepoName string)
| 643 | |
| 644 | // RenameRepo renames the repository on GitHub and returns the renamed repository |
| 645 | func RenameRepo(client *Client, repo ghrepo.Interface, newRepoName string) (*Repository, error) { |
| 646 | input := map[string]string{"name": newRepoName} |
| 647 | body := &bytes.Buffer{} |
| 648 | enc := json.NewEncoder(body) |
| 649 | if err := enc.Encode(input); err != nil { |
| 650 | return nil, err |
| 651 | } |
| 652 | |
| 653 | path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName()) |
| 654 | if err != nil { |
| 655 | return nil, err |
| 656 | } |
| 657 | |
| 658 | result := repositoryV3{} |
| 659 | err = client.REST(repo.RepoHost(), http.MethodPatch, path.String(), body, &result) |
| 660 | if err != nil { |
| 661 | return nil, err |
| 662 | } |
| 663 | |
| 664 | return &Repository{ |
| 665 | ID: result.NodeID, |
| 666 | Name: result.Name, |
| 667 | CreatedAt: result.CreatedAt, |
| 668 | Owner: RepositoryOwner{ |
| 669 | Login: result.Owner.Login, |
| 670 | }, |
| 671 | ViewerPermission: "WRITE", |
| 672 | hostname: repo.RepoHost(), |
| 673 | }, nil |
| 674 | } |
| 675 | |
| 676 | func LastCommit(client *Client, repo ghrepo.Interface) (*Commit, error) { |
| 677 | var responseData struct { |