Skip to content

Instantly share code, notes, and snippets.

@loic
Created June 19, 2014 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loic/313430836d20006916c4 to your computer and use it in GitHub Desktop.
Save loic/313430836d20006916c4 to your computer and use it in GitHub Desktop.
diff --git a/django/utils/version.py b/django/utils/version.py
index c680dbd..90a41ad 100644
--- a/django/utils/version.py
+++ b/django/utils/version.py
@@ -57,6 +57,10 @@ def get_git_changeset():
This value isn't guaranteed to be unique, but collisions are very unlikely,
so it's sufficient for generating the development version numbers.
"""
+ # FIXME: Replace with @lru_cache when we upgrade the docs server to PY2.7+.
+ if hasattr(get_git_changeset, 'cache'):
+ return get_git_changeset.cache
+
repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
git_log = subprocess.Popen('git log --pretty=format:%ct --quiet -1 HEAD',
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
@@ -65,5 +69,9 @@ def get_git_changeset():
try:
timestamp = datetime.datetime.utcfromtimestamp(int(timestamp))
except ValueError:
- return None
- return timestamp.strftime('%Y%m%d%H%M%S')
+ changeset = None
+ else:
+ changeset = timestamp.strftime('%Y%m%d%H%M%S')
+
+ get_git_changeset.cache = changeset
+ return changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment