Documentation ¶
Index ¶
- Constants
- Variables
- func CommitTemplate(typ int, scope, subject, body, footer string, isHideEmoji bool) (string, error)
- func ListUserOrganizations() (string, error)
- func TransferRepository(newOwner, owner, repoName string) (res string, err error)
- type MessageTemplate
- type MsgType
- type Organizations
- type Transfer
Constants ¶
View Source
const ( ReturnErr = iota ReturnBack ReturnComplete )
Variables ¶
View Source
var Cmd = &cli.Command{ Category: "GitHub", Name: "gh-mozhu", Aliases: []string{"ghext"}, Usage: "A little toolkit using GitHub API", Commands: []*cli.Command{ { Name: "install", Usage: "Install this", Action: func(_ *cli.Context) (err error) { binName := path.Base(os.Args[0]) if !strings.HasPrefix(binName, "gh-") { err = fmt.Errorf("extension name [%s] is error", binName) return } newPath := path.Join(ghConfig.DataDir(), "extensions", binName, binName) logger.Debug("gh extensions dir: ", newPath) err = utils.CopyFile(newPath, os.Args[0]) if err != nil { return } logger.SuccessF("Installed: %s", newPath) return }, }, { Name: "orgs", Usage: "List organizations for the authenticated user", Action: func(*cli.Context) (err error) { res, err := ListUserOrganizations() if err != nil { return } fmt.Println(res) return }, }, { Name: "transfer", Usage: "Transfer a repository", Flags: []cli.Flag{ &cli.StringFlag{ Name: "owner", Aliases: []string{"o"}, Usage: "The account owner of the repository", Required: true, }, &cli.StringFlag{ Name: "repo", Aliases: []string{"r"}, Usage: "The name of the repository", Required: true, }, &cli.StringFlag{ Name: "new-owner", Aliases: []string{"new", "n"}, Usage: "The username/organization whitch will be transferred to.", Required: true, }, }, Action: func(c *cli.Context) (err error) { res, err := TransferRepository(c.String("new-owner"), c.String("owner"), c.String("repo")) if err != nil { return } logger.Success(res) return }, }, }, }
Functions ¶
func CommitTemplate ¶
func ListUserOrganizations ¶
func TransferRepository ¶
Types ¶
type MessageTemplate ¶
type Organizations ¶
type Organizations []struct { Login string `json:"login"` }
type Transfer ¶
type Transfer struct {
NewOwner string `json:"new_owner"`
}
Transfer a repository
https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#transfer-a-repository
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/transfer \ -d '{"new_owner":"github","team_ids":[12,345],"new_name":"octorepo"}'
Click to show internal directories.
Click to hide internal directories.