0

Every SVN project in folders tags, and trunk has version.txt file with current number of the version. I need some advice on how to write a pre-commit script that would check if the version.txt in trunk was modifed to higher version than it is in tag.

1 Answers1

2

Try this has-changed-since-last-tag script:

#!/bin/bash  
file=${1:?Which file?}

# get latest tag
tag=$(git describe --abbrev=0)

# get content of file from the latest tag
fileFromTag=$(git show $tag:$file)

# compare current file with file from latest tag
! diff <(echo "$fileFromTag") $file > /dev/null

It will return with exit code 0 if the content of given file changed compared to last tag. If it didn't change, it returns 1.

hnicke
  • 602
  • 4
  • 7