challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

get_version.sh (853B)


      1 #!/bin/sh
      2 # Gets the version number from git, or from the contents of .version
      3 VERSION=
      4 if test -f ".version"; then
      5   VERSION=$(cat .version)
      6 fi
      7 if [ -e ./.git ]; then
      8   # With sparse checkouts, we have a .git dir but possibly no tags
      9   gitver=$(git describe --tags 2>/dev/null || echo no-git-version)
     10   if test "$gitver" != "no-git-version"; then
     11     VERSION=${gitver#v}
     12     echo "$VERSION" > .version
     13   fi
     14 fi
     15 if test "x$VERSION" = "x"; then
     16   VERSION="unknown"
     17 fi
     18 case $1 in
     19 "--major")
     20   echo "$VERSION" | sed 's/\(^[0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/g'
     21   ;;
     22 "--minor")
     23   echo "$VERSION" | sed 's/\(^[0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/g'
     24   ;;
     25 "--micro")
     26   echo "$VERSION" | sed 's/\(^[0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/g'
     27   ;;
     28 "--git")
     29   echo "$VERSION" | sed 's/\(^[0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\(.*\)/\4/g'
     30   ;;
     31 *)
     32   echo "$VERSION"
     33 esac