aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--patchwork/__init__.py24
-rw-r--r--patchwork/context_processors.py6
-rw-r--r--patchwork/settings/base.py2
-rw-r--r--patchwork/templates/patchwork/about.html2
-rw-r--r--patchwork/version.py63
-rw-r--r--templates/base.html2
-rw-r--r--tools/docker/Dockerfile2
7 files changed, 98 insertions, 3 deletions
diff --git a/patchwork/__init__.py b/patchwork/__init__.py
index e69de29..f82d711 100644
--- a/patchwork/__init__.py
+++ b/patchwork/__init__.py
@@ -0,0 +1,24 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2016 Stephen Finucane <stephen@that.guru>
+#
+# This file is part of the Patchwork package.
+#
+# Patchwork is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Patchwork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Patchwork; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from patchwork.version import get_latest_version
+
+VERSION = (2, 0, 0, 'alpha', 0)
+
+__version__ = get_latest_version(VERSION)
diff --git a/patchwork/context_processors.py b/patchwork/context_processors.py
index 8f1de9e..b021b31 100644
--- a/patchwork/context_processors.py
+++ b/patchwork/context_processors.py
@@ -19,6 +19,12 @@
from django.contrib.sites.models import Site
+import patchwork
+
def site(request):
return {'site': Site.objects.get_current()}
+
+
+def version(request):
+ return {'version': patchwork.__version__}
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 6737350..180a469 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -70,6 +70,7 @@ if django.VERSION >= (1, 8):
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'patchwork.context_processors.site',
+ 'patchwork.context_processors.version',
],
},
},
@@ -85,6 +86,7 @@ else:
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'patchwork.context_processors.site',
+ 'patchwork.context_processors.version',
]
diff --git a/patchwork/templates/patchwork/about.html b/patchwork/templates/patchwork/about.html
index e087f7c..f602c13 100644
--- a/patchwork/templates/patchwork/about.html
+++ b/patchwork/templates/patchwork/about.html
@@ -21,7 +21,7 @@
</div>
<ul class="list-group">
<li class="list-group-item">
- <p>2.0.0-pre</p>
+ <p>{{ version }}</p>
</li>
</ul>
</div>
diff --git a/patchwork/version.py b/patchwork/version.py
new file mode 100644
index 0000000..212d8d3
--- /dev/null
+++ b/patchwork/version.py
@@ -0,0 +1,63 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2016 Stephen Finucane <stephen@that.guru>
+#
+# This file is part of the Patchwork package.
+#
+# Patchwork is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Patchwork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Patchwork; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import subprocess
+import os
+
+
+ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ os.pardir)
+
+
+def get_latest_version(version):
+ """Returns the most recent version available.
+
+ This is either the hard-coded version or, if using Git, the version
+ per the most recent Git tag.
+ """
+ git_version = format_git_version(get_raw_git_version())
+ str_version = format_version(version)
+
+ return git_version or str_version
+
+
+def format_version(version):
+ """Format version tuple."""
+ return '.'.join(['.'.join([str(x) for x in version[:3]]),
+ '-'.join([str(x) for x in version[3:]])])
+
+
+def format_git_version(version):
+ """Returns a version based on Git tags."""
+ if '-' in version: # after tag
+ # convert version-N-githash to version.postN-githash
+ return version.replace('-', '.post', 1)
+ else: # at tag
+ return version
+
+
+def get_raw_git_version():
+ """Returns the raw git version via 'git-describe'."""
+ try:
+ git_version = subprocess.check_output(['git', 'describe'],
+ cwd=ROOT_DIR)
+ except (OSError, FileNotFoundError):
+ return ''
+
+ return git_version.strip().decode('utf-8')
diff --git a/templates/base.html b/templates/base.html
index 8045b51..d0f59b4 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -113,7 +113,7 @@
</div>
<div id="footer">
<a href="http://jk.ozlabs.org/projects/patchwork/">patchwork</a>
- patch tracking system | <a
+ patch tracking system | version {{version}} | <a
href="{% url 'about' %}">about patchwork</a>
</div>
</body>
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 883d43a..ff05707 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -21,7 +21,7 @@ RUN apt-get update -qq && \
python3.5-dev python3-pip python3-setuptools python3-wheel \
python3.4-dev findutils=4.4.2-7 \
libmysqlclient-dev mysql-client curl unzip xvfb chromium-chromedriver \
- chromium-browser build-essential && \
+ chromium-browser build-essential git && \
ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/
# User