Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* "hardcode" the committer date in version number * see: #1

  • Loading branch information...
commit c72661de2e358370bf5e7a7ad575f12e0ec7f75c 1 parent e671699
Jens Diemer authored
1  .gitattributes
... ...
@@ -0,0 +1 @@
  1
+django_tools/__init__.py filter=dater
4  README.creole
Source Rendered
@@ -124,8 +124,10 @@ to:
124 124
 
125 125
 == history
126 126
 
  127
+* v0.24.3
  128
+** "Hardcode" the version string date attachment via [[https://github.com/jedie/python-code-snippets/tree/master/CodeSnippets/git|gitattribute filter script]] to fix [[https://github.com/jedie/django-tools/issues/1|a reported issues]] with [[https://github.com/pypa/pip/issues/145|pip requirements file bug]]. 
127 129
 * v0.24.2
128  
-** Split [[https://github.com/jedie/django-tools/blob/master/django_tools/models.py|UpdateInfoBaseModel()]]: So you can only set "createtime", "lastupdatetime" or "createby", "lastupdateby" or both types (This is backward compatible) 
  130
+** Split [[https://github.com/jedie/django-tools/blob/master/django_tools/models.py|UpdateInfoBaseModel()]]: So you can only set "createtime", "lastupdatetime" or "createby", "lastupdateby" or both types (This is backwards compatible)
129 131
 * v0.24.1
130 132
 ** Bugfix: UsergroupsModelField() and add unittests for it
131 133
 ** Add "normal users" in UsergroupsModelField()
66  django_tools/__init__.py
... ...
@@ -1,61 +1,25 @@
1 1
 # coding: utf-8
2 2
 
3  
-import os
4  
-import time
5  
-import warnings
6  
-import subprocess
  3
+"""
  4
+    we add the committer date to the version number by a .gitattributes filter
  5
+    
  6
+    more info about this here:
  7
+    https://github.com/jedie/python-code-snippets/tree/master/CodeSnippets/git/#readme
  8
+"""
7 9
 
8 10
 
9  
-__version__ = (0, 24, 2)
  11
+import re
10 12
 
11 13
 
  14
+__version__ = (0, 24, 3)
  15
+
  16
+
  17
+COMMITTER_DATE = "$date$" # set by .gitattributes filter
  18
+DATE_REGEX = re.compile(r"\$date:(.*?)\$")
  19
+
  20
+__version__ += (DATE_REGEX.findall(COMMITTER_DATE)[0],)
12 21
 VERSION_STRING = '.'.join(str(part) for part in __version__)
13 22
 
14  
-#VERBOSE = True
15  
-VERBOSE = False
16  
-
17  
-def _error(msg):
18  
-    if VERBOSE:
19  
-        warnings.warn(msg)
20  
-    return ""
21  
-
22  
-def get_commit_timestamp(path=None):
23  
-    if path is None:
24  
-        path = os.path.abspath(os.path.dirname(__file__))
25  
-
26  
-    try:
27  
-        process = subprocess.Popen(
28  
-            # %ct: committer date, UNIX timestamp  
29  
-            ["/usr/bin/git", "log", "--pretty=format:%ct", "-1", "HEAD"],
30  
-            shell=False, cwd=path,
31  
-            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
32  
-        )
33  
-    except Exception, err:
34  
-        return _error("Can't get git hash: %s" % err)
35  
-
36  
-    process.wait()
37  
-    returncode = process.returncode
38  
-    if returncode != 0:
39  
-        return _error(
40  
-            "Can't get git hash, returncode was: %r"
41  
-            " - git stdout: %r"
42  
-            " - git stderr: %r"
43  
-            % (returncode, process.stdout.readline(), process.stderr.readline())
44  
-        )
45  
-
46  
-    output = process.stdout.readline().strip()
47  
-    try:
48  
-        timestamp = int(output)
49  
-    except Exception, err:
50  
-        return _error("git log output is not a number, output was: %r" % output)
51  
-
52  
-    try:
53  
-        return time.strftime(".%m%d", time.gmtime(timestamp))
54  
-    except Exception, err:
55  
-        return _error("can't convert %r to time string: %s" % (timestamp, err))
56  
-
57  
-
58  
-VERSION_STRING += get_commit_timestamp()
59 23
 
60 24
 if __name__ == "__main__":
61  
-    print VERSION_STRING
  25
+    print "django-tools v%s" % VERSION_STRING
6  setup.py
@@ -14,6 +14,12 @@
14 14
 
15 15
 from setuptools import setup, find_packages
16 16
 
  17
+if "sdist" in sys.argv or "--version" in sys.argv:
  18
+    # update the version string via gitattribute filter
  19
+    import subprocess
  20
+    subprocess.call(["rm", "django_tools/__init__.py"])
  21
+    subprocess.call(["/usr/bin/git", "checkout", "django_tools/__init__.py"])
  22
+
17 23
 from django_tools import VERSION_STRING
18 24
 
19 25
 

0 notes on commit c72661d

Please sign in to comment.
Something went wrong with that request. Please try again.