Skip to content

Commit

Permalink
added branch flag for release command
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegin committed Oct 10, 2017
1 parent 8561d34 commit b9a3e8b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion commands/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ var ReleaseCommand = cli.Command{
Name: "release",
Usage: "Releases artifacts to repositories",
Action: release,
Flags: []cli.Flag{
cli.StringFlag{
Name: "branch,b",
Usage: "Branch name to release. Default 'master'.",
},
},
}

func release(c *cli.Context) error {
Expand All @@ -22,10 +28,12 @@ func release(c *cli.Context) error {
return err
}

branch := c.String("branch")

//TODO: Make this configurable
var vcsTool vcstool.VCSTool = &vcstool.GitVCSTool{}
if os.Getenv("TESTRELEASE") == "" {
if err := vcsTool.VerifyRepoState(project); err != nil {
if err := vcsTool.VerifyRepoState(project, branch); err != nil {
return err
}
}
Expand Down
6 changes: 5 additions & 1 deletion vcstool/git_vcstool.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ func (g *GitVCSTool) Tag(project *domain.Project, tagName string) error {
return nil
}

func (g *GitVCSTool) VerifyRepoState(project *domain.Project) error {
func (g *GitVCSTool) VerifyRepoState(project *domain.Project, branch string) error {
remoteName := "origin"
branchName := "master"

if branch != "" {
branchName = branch
}

// Check if on expected branch (e.g. master)
if err := verifyGitState(func(stdout, stderr string) error {
actualBranch := strings.TrimSpace(stdout)
Expand Down
2 changes: 1 addition & 1 deletion vcstool/vsctool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import (
)

type VCSTool interface {
VerifyRepoState(project *domain.Project) error
VerifyRepoState(project *domain.Project, branch string) error
Tag(project *domain.Project, tagname string) error
}

0 comments on commit b9a3e8b

Please sign in to comment.