Skip to content

Commit

Permalink
automatize versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Dimov committed Aug 10, 2015
1 parent 7c4a28b commit e23318a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ TestResults
/README.zip
/Dokan
/bluescreenview
/Sshfs/Sshfs/Properties/AssemblyInfo.cs.bak
8 changes: 4 additions & 4 deletions Sshfs/Sshfs/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyDescription("SFTP Filesystem for Windows ™")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("4every1 s.r.o.")]
[assembly: AssemblyProduct("WinSshFS 4every1 edition 1.5.12.7-3-g1cdd8dc")]
[assembly: AssemblyProduct("WinSshFS 4every1 edition 1.5.12.8-0-g42d7342")]
[assembly: AssemblyCopyright("Copyright © 4every1 s.r.o.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand All @@ -31,6 +31,6 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.5.12.7")]
[assembly: AssemblyVersion("1.5.12.7")]
[assembly: AssemblyFileVersion("1.5.12.7")]
// [assembly: AssemblyVersion("1.5.12.8")]
[assembly: AssemblyVersion("1.5.12.8")]
[assembly: AssemblyFileVersion("1.5.12.8")]
2 changes: 2 additions & 0 deletions runversionhook.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"%SYSTEMDRIVE%\Program Files (x86)\Git\bin\bash.exe" --login version.hook.sh
pause
39 changes: 39 additions & 0 deletions version.hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
#Git Post Merge Hook
#---------------------
#Gets the latest tag info from the git repo and updates the AssemblyInfo.cs file with it.
#This file needs to be place in the .git/hooks/ folder and only works when a git pull is
#made which contains changes in the remote repo.

PRODUCT="WinSshFS 4every1 edition"

#get the latest tag info. The 'always' flag will give you a shortened SHA1 if no tag exists.
tag=$(git describe --tags --long)

#tag="A.B.C.D-X-hash"
echo $tag

AI="Sshfs/Sshfs/Properties/AssemblyInfo.cs"

#If no tag has been added only the sha1 will be returned
if [[ $tag=="*.*" ]]
then
IFS='-' read -ra PARTS <<< "$tag"

IFS='.' read -ra TAG <<< "${PARTS[0]}"
#echo "${TAG[2]}"
#echo "${TAG[3]}"

IFS='-' read -ra COMMITS <<< "${PARTS[1]}"
#echo "${COMMITS[0]}"

#This will be the version in the format <major>.<minor>.<build number>.<revision>
version="${TAG[0]}"."${TAG[1]}"."${TAG[2]}"."${TAG[3]}"
echo $version

#Update the AssemblyVersion and AssemblyFileVersion attribute with the 'version'
sed -i.bak "s/\AssemblyVersion(\".*\")/AssemblyVersion(\"$version\")/g" $AI 2>/dev/null
sed -i.bak "s/\AssemblyFileVersion(\".*\")/AssemblyFileVersion(\"$version\")/g" $AI 2>/dev/null
sed -i.bak "s/AssemblyProduct(\".*\")/AssemblyProduct(\"$PRODUCT $tag\")/g" $AI 2>/dev/null
#cat $AI
fi

0 comments on commit e23318a

Please sign in to comment.