Skip to content

Commit

Permalink
Patch VersionInfo.cs during build on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
James Nugent committed Dec 18, 2013
1 parent c48808e commit 6d8c4fb
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ function revertVersionFiles() {
done
}

function revertVersionInfo() {
files=$( find . -name "VersionInfo.cs" )

for file in $files
do
git checkout $file
echo "Reverted $file"
done
}

function err() {
revertVersionFiles
echo "FAILED. See earlier messages"
Expand Down Expand Up @@ -257,11 +267,44 @@ function patchVersionFiles {
done
}

function patchVersionInfo {
branchName=`git rev-parse --abbrev-ref HEAD`
commitHash=`git log -n1 --pretty=format:"%H" HEAD`
commitTimestamp=`git log -n1 --pretty=format:"%aD" HEAD`

newVersion="public static readonly string Version = \"$VERSIONSTRING\";"
newBranch="public static readonly string Branch = \"$branchName\";"
newCommitHash="public static readonly string Hashtag = \"$commitHash\";"
newTimestamp="public static readonly string Timestamp = \"$commitTimestamp\";"

versionPattern="public static readonly string Version .*$"
branchPattern="public static readonly string Branch .*$"
commitHashPattern="public static readonly string Hashtag .*$"
timestampPattern="public static readonly string Timestamp .*$"

files=$( find . -name "VersionInfo.cs" )

for file in $files
do
tempfile="$file.tmp"
sed -e "s/$versionPattern/$newVersion/" \
-e "s/$branchPattern/$newBranch/" \
-e "s/$commitHashPattern/$newCommitHash/" \
-e "s/$timestampPattern/$newTimestamp/" \
$file > $tempfile

mv $tempfile $file
echo "Patched $file with version information"
done
}

function buildEventStore {
patchVersionFiles
patchVersionInfo
rm -rf bin/
xbuild src/EventStore/EventStore.sln /p:Platform="Any CPU" /p:Configuration="$CONFIGURATION" || err
revertVersionFiles
revertVersionInfo
}

function cleanAll {
Expand Down

0 comments on commit 6d8c4fb

Please sign in to comment.