mirror of https://github.com/perkeep/perkeep.git
devcam: add -branch option to review mode
Change-Id: I0c7d78bcb2ef357368db93751a8bb7a7977e528f
This commit is contained in:
parent
ef8c2d3a40
commit
94461e25ca
|
@ -35,11 +35,15 @@ var (
|
|||
hookFile = filepath.FromSlash(".git/hooks/commit-msg")
|
||||
)
|
||||
|
||||
type reviewCmd struct{}
|
||||
type reviewCmd struct {
|
||||
releaseBranch string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cmdmain.RegisterMode("review", func(flags *flag.FlagSet) cmdmain.CommandRunner {
|
||||
return new(reviewCmd)
|
||||
cmd := &reviewCmd{}
|
||||
flags.StringVar(&cmd.releaseBranch, "branch", "", "Alternative release branch to push to. Defaults to master branch.")
|
||||
return cmd
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -57,7 +61,7 @@ func (c *reviewCmd) RunCommand(args []string) error {
|
|||
}
|
||||
goToCamliRoot()
|
||||
c.checkHook()
|
||||
gitPush()
|
||||
c.gitPush()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -113,9 +117,14 @@ func (c *reviewCmd) checkHook() {
|
|||
}
|
||||
}
|
||||
|
||||
func gitPush() {
|
||||
cmd := exec.Command("git",
|
||||
[]string{"push", "https://camlistore.googlesource.com/camlistore", "HEAD:refs/for/master"}...)
|
||||
func (c *reviewCmd) gitPush() {
|
||||
args := []string{"push", "origin"}
|
||||
if c.releaseBranch != "" {
|
||||
args = append(args, "HEAD:refs/for/releases/"+c.releaseBranch)
|
||||
} else {
|
||||
args = append(args, "HEAD:refs/for/master")
|
||||
}
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd.Stdout = cmdmain.Stdout
|
||||
cmd.Stderr = cmdmain.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue