You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB

  1. #!/bin/sh
  2. #
  3. # Bumps the micro version according to the number of commits on this branch
  4. #
  5. # To have git run this script on commit, create a "pre-commit" text file in
  6. # .git/hooks/ with the following content:
  7. # #!/bin/sh
  8. # if [ -x ./_pre-commit.sh ]; then
  9. # . ./_pre-commit.sh
  10. # fi
  11. type -P sed &>/dev/null || { echo "sed command not found. Aborting." >&2; exit 1; }
  12. type -P git &>/dev/null || { echo "git command not found. Aborting." >&2; exit 1; }
  13. if [ -x ./_detect-amend.sh ]; then
  14. . ./_detect-amend.sh
  15. fi
  16. TAGVER=`git rev-list HEAD --count`
  17. # adjust so that we match the github commit count
  18. ((TAGVER++))
  19. # there may be a better way to prevent improper micro on amend. For now the detection
  20. # of a .amend file in the current directory will do
  21. if [ -f ./.amend ]; then
  22. ((TAGVER--))
  23. git tag -d "b$TAGVER"
  24. rm ./.amend;
  25. fi
  26. echo "setting micro to $TAGVER"
  27. echo $TAGVER > .tag
  28. cat > cmd.sed <<\_EOF
  29. s/^\([ \t]*\)*\(FILE\|PRODUCT\)VERSION\([ \t]*\)\([0-9]*\),\([0-9]*\),[0-9]*,\(.*\)/\1\2VERSION\3\4,\5,@@TAGVER@@,\6/
  30. s/^\([ \t]*\)VALUE\([ \t]*\)"\(File\|Product\)Version",\([ \t]*\)"\(.*\)\..*"[ \t]*/\1VALUE\2"\3Version",\4"\5.@@TAGVER@@"/
  31. s/^\(.*\)"Rufus \(.*\)\..*"\(.*\)/\1"Rufus \2.@@TAGVER@@"\3/
  32. s/^\([ \t]*\)Version="\([0-9]*\)\.\([0-9]*\)\.[0-9]*\.\([0-9]*\)"\(.*\)/\1Version="\2.\3.@@TAGVER@@.\4"\5/
  33. _EOF
  34. # First run sed to substitute our variable in the sed command file
  35. sed -i -e "s/@@TAGVER@@/$TAGVER/g" cmd.sed
  36. # Run sed to update the nano version
  37. sed -b -i -f cmd.sed src/rufus.rc
  38. # NB: we need to run git add else the modified files may be ignored
  39. git add src/rufus.rc
  40. rm cmd.sed