зеркало из https://github.com/mislav/hub.git
Add fork stub
This commit is contained in:
Родитель
6d59bc2356
Коммит
724878757e
|
@ -41,6 +41,7 @@ func (c *Command) List() bool {
|
||||||
|
|
||||||
var All = []*Command{
|
var All = []*Command{
|
||||||
cmdPull,
|
cmdPull,
|
||||||
|
cmdFork,
|
||||||
cmdCi,
|
cmdCi,
|
||||||
cmdBrowse,
|
cmdBrowse,
|
||||||
cmdCompare,
|
cmdCompare,
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jingweno/gh/github"
|
||||||
|
)
|
||||||
|
|
||||||
|
var cmdFork = &Command{
|
||||||
|
Run: fork,
|
||||||
|
Usage: "fork [--no-remote]",
|
||||||
|
Short: "Make a fork of a remote repository on GitHub and add as remote",
|
||||||
|
Long: `Forks the original project (referenced by "origin" remote) on GitHub and
|
||||||
|
adds a new remote for it under your username.
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
|
||||||
|
var flagForkNoRemote bool
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdFork.Flag.BoolVar(&flagForkNoRemote, "no-remote", false, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func fork(cmd *Command, args []string) {
|
||||||
|
gh := github.New()
|
||||||
|
project := gh.Project
|
||||||
|
|
||||||
|
err := gh.ForkRepository(project.Name, project.Owner)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -51,6 +51,17 @@ func (gh *GitHub) CiStatus(sha string) (*octokat.Status, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gh *GitHub) ForkRepository(name, owner string) error {
|
||||||
|
client := gh.client()
|
||||||
|
_, err := client.Repository(octokat.Repo{name, owner})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (gh *GitHub) repo() octokat.Repo {
|
func (gh *GitHub) repo() octokat.Repo {
|
||||||
project := gh.Project
|
project := gh.Project
|
||||||
return octokat.Repo{project.Name, project.Owner}
|
return octokat.Repo{project.Name, project.Owner}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче