Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Fixes #1276: Fail deploys with uncommitted changes. #1348

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions phing/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ deploy:
exclude_file: ${blt.root}/phing/files/deploy-exclude.txt
exclude_additions_file: ${repo.root}/blt/deploy-exclude-additions.txt
gitignore_file: ${blt.root}/phing/files/.gitignore
git:
# If true, deploys will fail if there are uncommitted changes.
failOnDirty: true

# File and Directory locations.
docroot.relative: ${repo.root.relative}/docroot
Expand Down
23 changes: 22 additions & 1 deletion phing/tasks/deploy.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
<project name="deploy" default="deploy">

<target name="deploy" description="Builds separate artifact and pushes to git.remotes defined project.yml.">


<!-- Check working tree state. -->
<exec dir="${repo.root}" command="status=$(git status --porcelain); echo ${#status};"
outputProperty="git.status.length" checkreturn="true"/>
<if>
<!-- Length will be a non-zero value if there are uncommitted changes. -->
<not><equals arg1="${git.status.length}" arg2="0"/></not>
<then>
<if>
<!-- Warn that there are uncommitted changes in this deploy. -->
<isfalse value="${deploy.git.failOnDirty}"/>
<then>
<echo level="warning">Deploy is being run with uncommitted changes.</echo>
</then>
<!-- Fail the deploy, the working tree must be clean. -->
<else>
<fail>There are uncommitted changes, commit or stash these changes before deploying.</fail>
</else>
</if>
</then>
</if>

<!-- Build some defaults -->
<exec command="git rev-parse --abbrev-ref HEAD" dir="${repo.root}" outputProperty="branch.current"/>
<exec command="git log --oneline -1" dir="${repo.root}" outputProperty="deploy.commitMsg.last"/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/travis/deploy_branch
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -ev

blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_BUILD_ID}" -Ddeploy.branch="${TRAVIS_BRANCH}-build"
blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_BUILD_ID}" -Ddeploy.branch="${TRAVIS_BRANCH}-build" -Ddeploy.git.failOnDirty=false

set +v
2 changes: 1 addition & 1 deletion scripts/travis/deploy_tag
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -ev

blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_TAG}" -Ddeploy.tag="${TRAVIS_TAG}-build"
blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_TAG}" -Ddeploy.tag="${TRAVIS_TAG}-build" -Ddeploy.git.failOnDirty=false

set +v