-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0121a76
commit bc503e7
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package graft | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/pinkluz/arcanist/cli" | ||
"github.com/pinkluz/arcanist/lib/git" | ||
) | ||
|
||
type graftCmd struct { | ||
cmd *cobra.Command | ||
|
||
remote string | ||
localBranchName string | ||
} | ||
|
||
func (f *graftCmd) run(cmd *cobra.Command, args []string) { | ||
repo, err := git.OpenRepo() | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
switch len(args) { | ||
case 1: | ||
err := git.Graft(repo, args[0], f.remote, f.localBranchName) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Printf("Grafted '%s' into your local repo", args[0]) | ||
fmt.Println() | ||
default: | ||
cmd.Help() | ||
os.Exit(0) | ||
} | ||
} | ||
|
||
func init() { | ||
graft := &graftCmd{} | ||
graft.cmd = &cobra.Command{ | ||
Use: "graft <branch>", | ||
Short: "Place a branch from a given remote in your local working tree", | ||
Long: `Place a branch in your local working copy from a given upstream so you can work off of it.`, | ||
Args: cobra.MinimumNArgs(1), | ||
Run: graft.run, | ||
} | ||
|
||
graft.cmd.Flags().StringVarP(&graft.remote, "remote", "r", "origin", "The remote to use when grafting") | ||
graft.cmd.Flags().StringVarP(&graft.localBranchName, "local-branch-name", "b", "", "The branch name to gaft onto") | ||
|
||
cli.GetRoot().AddCommand(graft.cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package git | ||
|
||
import ( | ||
gogit "github.com/go-git/go-git/v5" | ||
) | ||
|
||
func Graft(repo *gogit.Repository, branch string, | ||
remote string, localBranchName string) error { | ||
|
||
return nil | ||
} |