You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by sa...@apache.org on 2016/05/19 22:32:59 UTC
incubator-airflow git commit: Make enhancements to VersionView
Repository: incubator-airflow
Updated Branches:
refs/heads/master 5e40d9858 -> aedb667d5
Make enhancements to VersionView
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/aedb667d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/aedb667d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/aedb667d
Branch: refs/heads/master
Commit: aedb667d50e512655a590ec2af03504947dd9acb
Parents: 5e40d98
Author: Siddharth Anand <sa...@agari.com>
Authored: Thu May 19 18:49:08 2016 +0000
Committer: Siddharth Anand <sa...@agari.com>
Committed: Thu May 19 19:25:35 2016 +0000
----------------------------------------------------------------------
airflow/www/views.py | 2 +-
setup.py | 63 ++++++++++++++++++++++++++---------------------
2 files changed, 36 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/aedb667d/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 3a0e285..bcd390c 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -2307,7 +2307,7 @@ class VersionView(wwwutils.SuperUserMixin, LoggingMixin, BaseView):
# Get the Git repo and git hash
git_version = None
try:
- with open("airflow/git_version") as f:
+ with open(os.path.join(*[settings.AIRFLOW_HOME, 'airflow', 'git_version'])) as f:
git_version = f.readline()
except Exception as e:
self.logger.error(e)
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/aedb667d/setup.py
----------------------------------------------------------------------
diff --git a/setup.py b/setup.py
index 43fefd8..fd1d537 100644
--- a/setup.py
+++ b/setup.py
@@ -39,41 +39,48 @@ class CleanCommand(Command):
def git_version(version):
+ """
+ Return a version to identify the state of the underlying git repo. The version will
+ indicate whether the head of the current git-backed working directory is tied to a
+ release tag or not : it will indicate the former with a 'release:{version}' prefix
+ and the latter with a 'dev0' prefix. Following the prefix will be a sha of the current
+ branch head. Finally, a "dirty" suffix is appended to indicate that uncommitted changes
+ are present.
+ """
+ repo = None
try:
import git
+ repo = git.Repo('.git')
except ImportError:
logger.warn('gitpython not found: Cannot compute the git version.')
return ''
- try:
- repo = git.Repo('.git')
- except ImportError:
+ except Exception as e:
logger.warn('Git repo not found: Cannot compute the git version.')
return ''
- sha = repo.head.commit.hexsha
- if repo.is_dirty():
- return '.dev0+{sha}.dirty'.format(sha=sha)
- # commit is clean
- # is it release of `version` ?
- try:
- tag = repo.git.describe(
- match='[0-9]*', exact_match=True,
- tags=True, dirty=True)
- assert tag == version, (tag, version)
- return '.release:{version}+{sha}'.format(version=version,
- sha=sha)
- except git.GitCommandError:
- return '.dev0+{sha}'.format(sha=sha)
-
-
-def write_version(filename=os.path.join('airflow', 'git_version')):
- cnt = """%(git_revision)s"""
- text = cnt % {'git_revision':
- git_version(version)}
- try:
- with open(filename, 'w') as a:
- a.write(text)
- except Exception as e:
- logger.error(e)
+ if repo:
+ sha = repo.head.commit.hexsha
+ if repo.is_dirty():
+ return '.dev0+{sha}.dirty'.format(sha=sha)
+ # commit is clean
+ # is it release of `version` ?
+ try:
+ tag = repo.git.describe(
+ match='[0-9]*', exact_match=True,
+ tags=True, dirty=True)
+ assert tag == version, (tag, version)
+ return '.release:{version}+{sha}'.format(version=version,
+ sha=sha)
+ except git.GitCommandError:
+ return '.dev0+{sha}'.format(sha=sha)
+ else:
+ return 'no_git_version'
+
+
+def write_version(filename=os.path.join(*['airflow',
+ 'git_version'])):
+ text = "{}".format(git_version(version))
+ with open(filename, 'w') as a:
+ a.write(text)
async = [