Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit c72661de2e358370bf5e7a7ad575f12e0ec7f75c 1 parent e671699
Jens Diemer authored
1  .gitattributes
View
@@ -0,0 +1 @@
+django_tools/__init__.py filter=dater
4 README.creole
View
@@ -124,8 +124,10 @@ to:
== history
+* v0.24.3
+** "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]].
* v0.24.2
-** 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)
+** 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)
* v0.24.1
** Bugfix: UsergroupsModelField() and add unittests for it
** Add "normal users" in UsergroupsModelField()
66 django_tools/__init__.py
View
@@ -1,61 +1,25 @@
# coding: utf-8
-import os
-import time
-import warnings
-import subprocess
+"""
+ we add the committer date to the version number by a .gitattributes filter
+
+ more info about this here:
+ https://github.com/jedie/python-code-snippets/tree/master/CodeSnippets/git/#readme
+"""
-__version__ = (0, 24, 2)
+import re
+__version__ = (0, 24, 3)
+
+
+COMMITTER_DATE = "$date$" # set by .gitattributes filter
+DATE_REGEX = re.compile(r"\$date:(.*?)\$")
+
+__version__ += (DATE_REGEX.findall(COMMITTER_DATE)[0],)
VERSION_STRING = '.'.join(str(part) for part in __version__)
-#VERBOSE = True
-VERBOSE = False
-
-def _error(msg):
- if VERBOSE:
- warnings.warn(msg)
- return ""
-
-def get_commit_timestamp(path=None):
- if path is None:
- path = os.path.abspath(os.path.dirname(__file__))
-
- try:
- process = subprocess.Popen(
- # %ct: committer date, UNIX timestamp
- ["/usr/bin/git", "log", "--pretty=format:%ct", "-1", "HEAD"],
- shell=False, cwd=path,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- )
- except Exception, err:
- return _error("Can't get git hash: %s" % err)
-
- process.wait()
- returncode = process.returncode
- if returncode != 0:
- return _error(
- "Can't get git hash, returncode was: %r"
- " - git stdout: %r"
- " - git stderr: %r"
- % (returncode, process.stdout.readline(), process.stderr.readline())
- )
-
- output = process.stdout.readline().strip()
- try:
- timestamp = int(output)
- except Exception, err:
- return _error("git log output is not a number, output was: %r" % output)
-
- try:
- return time.strftime(".%m%d", time.gmtime(timestamp))
- except Exception, err:
- return _error("can't convert %r to time string: %s" % (timestamp, err))
-
-
-VERSION_STRING += get_commit_timestamp()
if __name__ == "__main__":
- print VERSION_STRING
+ print "django-tools v%s" % VERSION_STRING
6 setup.py
View
@@ -14,6 +14,12 @@
from setuptools import setup, find_packages
+if "sdist" in sys.argv or "--version" in sys.argv:
+ # update the version string via gitattribute filter
+ import subprocess
+ subprocess.call(["rm", "django_tools/__init__.py"])
+ subprocess.call(["/usr/bin/git", "checkout", "django_tools/__init__.py"])
+
from django_tools import VERSION_STRING
Please sign in to comment.
Something went wrong with that request. Please try again.