Browse code

add instructions on how to use unannotated tags for versioning

We also add a patch that can be directly applied to '_version.py'
to make this change. This patch will need to be kept in sync
with '_version.py'.

Joseph Weston authored on 13/08/2018 18:38:42
Showing 2 changed files
... ...
@@ -34,6 +34,18 @@ curl https://raw.githubusercontent.com/jbweston/miniver/master/install-miniver |
34 34
 ```
35 35
 This will grab the latest files from GitHub and set up Miniver for your project.
36 36
 
37
+### I get an `unknown` version!
38
+The version is reported as `unknown` (plus the current git hash) when there are no valid tags
39
+in the git history. You should create an [*annotated tag*](https://git-scm.com/book/en/v2/Git-Basics-Tagging)
40
+so that Miniver reports a reasonable version.
41
+
42
+If your project uses *unannotated tags* for versioning (though this is not the
43
+[recommended way](https://stackoverflow.com/questions/11514075/what-is-the-difference-between-an-annotated-and-unannotated-tag))
44
+then you'll need to run the following in order to modify Miniver's behaviour:
45
+```
46
+curl https://raw.githubusercontent.com/jbweston/miniver/master/unannotated-tags.patch | patch <your_package_directory>/_version.py
47
+```
48
+
37 49
 ### I don't want to type that URL every time I use this
38 50
 You can `pip install miniver`, which will give you the `install-miniver` script.
39 51
 Then you can simply run the following from your project root to use Miniver:
40 52
new file mode 100644
... ...
@@ -0,0 +1,11 @@
1
+Apply this patch to '_version.py' to get Miniver to calculate
2
+the version using unannotated tags in addition to annotated tags
3
+@@ -75,7 +75,7 @@ def get_version_from_git():
4
+     for opts in [['--first-parent'], []]:
5
+         try:
6
+             p = subprocess.Popen(
7
+-                ['git', 'describe', '--long', '--always'] + opts,
8
++                ['git', 'describe', '--long', '--always', '--tags'] + opts,
9
+                 cwd=distr_root,
10
+                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
11
+         except OSError: