mirror of
https://gitea.com/gitea/tea.git
synced 2024-11-24 03:21:36 +01:00
Merge branch 'fork_repos' of ssh://root360_github/root360-AndreasUlm/tea into merge_all
This commit is contained in:
commit
16ba6125e4
45
cmd/repos.go
45
cmd/repos.go
@ -21,6 +21,7 @@ var CmdRepos = cli.Command{
|
||||
Action: runReposList,
|
||||
Subcommands: []cli.Command{
|
||||
CmdReposList,
|
||||
CmdReposFork,
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
@ -124,6 +125,50 @@ func runReposList(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CmdReposFork represents a sub command of issues to list issues
|
||||
var CmdReposFork = cli.Command{
|
||||
Name: "fork",
|
||||
Usage: "fork repository",
|
||||
Description: `fork repository`,
|
||||
Action: runReposFork,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "login, l",
|
||||
Usage: "Indicate one login, optional when inside a gitea repository",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repo, r",
|
||||
Usage: "Indicate one repo, optional when inside a gitea repository",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "org",
|
||||
Usage: "Organization to fork the repository for (optional, default = logged in user)",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func runReposFork(ctx *cli.Context) error {
|
||||
login, owner, repo := initCommand(ctx)
|
||||
forkOptions := gitea.CreateForkOption{}
|
||||
if org := ctx.String("org"); org != "" {
|
||||
forkOptions = gitea.CreateForkOption{
|
||||
Organization: &org,
|
||||
}
|
||||
}
|
||||
|
||||
_, err := login.Client().CreateFork(owner, repo, forkOptions)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
user, _ := login.Client().GetMyUserInfo()
|
||||
|
||||
fmt.Printf("Forked '%s/%s' to '%s/%s'\n", owner, repo, user.UserName, repo)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initCommandLoginOnly(ctx *cli.Context) *Login {
|
||||
err := loadConfig(yamlConfigPath)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user