This commit is contained in:
Jingwen Owen Ou 2013-06-10 17:10:40 -07:00
Родитель 6d59bc2356
Коммит 724878757e
3 изменённых файлов: 41 добавлений и 0 удалений

Просмотреть файл

@ -41,6 +41,7 @@ func (c *Command) List() bool {
var All = []*Command{ var All = []*Command{
cmdPull, cmdPull,
cmdFork,
cmdCi, cmdCi,
cmdBrowse, cmdBrowse,
cmdCompare, cmdCompare,

29
commands/fork.go Normal file
Просмотреть файл

@ -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}