From 724878757e79bb1cc750f329959ecb7c0f0c5668 Mon Sep 17 00:00:00 2001 From: Jingwen Owen Ou Date: Mon, 10 Jun 2013 17:10:40 -0700 Subject: [PATCH] Add fork stub --- commands/commands.go | 1 + commands/fork.go | 29 +++++++++++++++++++++++++++++ github/github.go | 11 +++++++++++ 3 files changed, 41 insertions(+) create mode 100644 commands/fork.go diff --git a/commands/commands.go b/commands/commands.go index 3c8412f3..8aca1566 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -41,6 +41,7 @@ func (c *Command) List() bool { var All = []*Command{ cmdPull, + cmdFork, cmdCi, cmdBrowse, cmdCompare, diff --git a/commands/fork.go b/commands/fork.go new file mode 100644 index 00000000..6669741d --- /dev/null +++ b/commands/fork.go @@ -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) + + +} diff --git a/github/github.go b/github/github.go index eeacda1f..b72e8c08 100644 --- a/github/github.go +++ b/github/github.go @@ -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 { project := gh.Project return octokat.Repo{project.Name, project.Owner}