Skip to content

Commit

Permalink
HEAD independent version script
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Mar 5, 2016
1 parent a2bfc2c commit f0ff15f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ Currently, the `@compat` macro supports the following syntaxes:

## Developer tips

If you're adding additional compatibility code to this package, the [`bin/version.sh` script is useful for extracting the version number from a git commit SHA. For example, from the git repository of `julia`, run something like this:
If you're adding additional compatibility code to this package, the [`bin/version.sh`](https://github.com/JuliaLang/Compat.jl/blob/master/bin/version.sh) script is useful for extracting the version number from a git commit SHA. For example, from the git repository of `julia`, run something like this:

```sh
bash $ /path/to/Compat/bin/version.sh a378b60fe483130d0d30206deb8ba662e93944da
0.5.0-dev+2023
```

This prints a number `XXXX`, and you can then test whether Julia
is at least this version by `VERSION >= v"0.Y.0-dev+XXXX"` (assuming
it is a commit from the 0.Y development cycle).
This prints a version number corresponding to the specified commit of the form
`X.Y.Z-aaa+NNNN`, and you can then test whether Julia
is at least this version by `VERSION >= v"X.Y.Z-aaa+NNNN"`.
12 changes: 9 additions & 3 deletions bin/version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash
last_tag=$(git describe --tags --abbrev=0)
ver=$(cat VERSION)
nb=$(git rev-list $1 ^$last_tag | wc -l | sed -e 's/[^[:digit:]]//g')

# Need to be run from a julia repo clone
# First argument (Optional) is a ref to the commit

gitref=${1:-HEAD}

last_tag=$(git describe --tags --abbrev=0 "$gitref")
ver=$(git show "$gitref:VERSION")
nb=$(git rev-list --count "$gitref" "^$last_tag")
echo "$ver+$nb"

0 comments on commit f0ff15f

Please sign in to comment.