Skip to content

Commit

Permalink
Merge pull request harness#182 from vito/git-deploy-use-branch
Browse files Browse the repository at this point in the history
git deploy pushes to given branch (default master)
  • Loading branch information
bradrydzewski committed Mar 12, 2014
2 parents d406aab + 5ce081b commit 2241b5b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/plugin/deploy/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@ func (g *Git) Write(f *buildfile.Buildfile) {
// add target as a git remote
f.WriteCmd(fmt.Sprintf("git remote add deploy %s", g.Target))

destinationBranch := g.Branch
if destinationBranch == "" {
destinationBranch = "master"
}

switch g.Force {
case true:
// this is useful when the there are artifacts generated
// by the build script, such as less files converted to css,
// that need to be deployed to git remote.
f.WriteCmd(fmt.Sprintf("git add -A"))
f.WriteCmd(fmt.Sprintf("git commit -m 'add build artifacts'"))
f.WriteCmd(fmt.Sprintf("git push deploy $COMMIT:master --force"))
f.WriteCmd(fmt.Sprintf("git push deploy $COMMIT:%s --force", destinationBranch))
case false:
// otherwise we just do a standard git push
f.WriteCmd(fmt.Sprintf("git push deploy $COMMIT:master"))
f.WriteCmd(fmt.Sprintf("git push deploy $COMMIT:%s", destinationBranch))
}
}

0 comments on commit 2241b5b

Please sign in to comment.