Skip to content

Commit

Permalink
git deploy pushes to given branch (default master)
Browse files Browse the repository at this point in the history
Signed-off-by: David Varvel <dvarvel@pivotallabs.com>
  • Loading branch information
Alex Suraci authored and lvarvel committed Mar 12, 2014
1 parent d406aab commit 5ce081b
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 5ce081b

Please sign in to comment.