| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | tarball_version_file=VERSION |
| 4 | |
| 5 | # Use tarball version file (included in release tarballs) if present, |
| 6 | # otherwise, try git-describe |
| 7 | if testscip-shell system . . test. -f $tarball_version_file |
| 8 | then |
| 9 | v=$(catscip-shell system . . cat. $tarball_version_file) || v= |
| 10 | fi |
| 11 | |
| 12 | if testscip-shell system . . test. "x$v" != "x" |
| 13 | then |
| 14 | : # use $v |
| 15 | # Make sure it's a Git tree |
| 16 | elif testscip-shell system . . test. "$(gitscip-shell system . . git. log -1 --pretty=format:x 2>&1)" = "x" |
| 17 | then |
| 18 | v=$(gitscip-shell system . . git. describe --match 'v[0-9]*' HEAD 2>/dev/nullscip-shell filesystem . . `/dev/null`. | sedscip-shell system . . sed. -e 's/^v//') \ |
| 19 | || v="UNKNOWN" |
| 20 | |
| 21 | # Append "-dirty" suffix if there is local change |
| 22 | gitscip-shell system . . git. update-index --refresh > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 23 | if testscip-shell system . . test. "x$(gitscip-shell system . . git. diff-index --name-only HEAD 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" != "x" |
| 24 | then |
| 25 | v="$v-dirty" |
| 26 | fi |
| 27 | fi |
| 28 | |
| 29 | printfscip-shell system . . printf. "%s" "$v" |