Merge pull request #86 from matrix-org/v0.7.1-r2

V0.7.1 r2
pull/87/head v0.7.1-r2
Erik Johnston 2015-02-21 13:51:00 +00:00
commit b33a4cd6cc
2 changed files with 52 additions and 49 deletions

View File

@ -16,4 +16,4 @@
""" This is a reference implementation of a Matrix home server. """ This is a reference implementation of a Matrix home server.
""" """
__version__ = "0.7.1-r1" __version__ = "0.7.1-r2"

View File

@ -210,61 +210,64 @@ class SynapseHomeServer(HomeServer):
def get_version_string(): def get_version_string():
null = open(os.devnull, 'w')
cwd = os.path.dirname(os.path.abspath(__file__))
try: try:
git_branch = subprocess.check_output( null = open(os.devnull, 'w')
['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd = os.path.dirname(os.path.abspath(__file__))
stderr=null, try:
cwd=cwd, git_branch = subprocess.check_output(
).strip() ['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
git_branch = "b=" + git_branch stderr=null,
except subprocess.CalledProcessError: cwd=cwd,
git_branch = "" ).strip()
git_branch = "b=" + git_branch
except subprocess.CalledProcessError:
git_branch = ""
try: try:
git_tag = subprocess.check_output( git_tag = subprocess.check_output(
['git', 'describe', '--exact-match'], ['git', 'describe', '--exact-match'],
stderr=null, stderr=null,
cwd=cwd, cwd=cwd,
).strip() ).strip()
git_tag = "t=" + git_tag git_tag = "t=" + git_tag
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
git_tag = "" git_tag = ""
try: try:
git_commit = subprocess.check_output( git_commit = subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD'], ['git', 'rev-parse', '--short', 'HEAD'],
stderr=null, stderr=null,
cwd=cwd, cwd=cwd,
).strip() ).strip()
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
git_commit = "" git_commit = ""
try: try:
dirty_string = "-this_is_a_dirty_checkout" dirty_string = "-this_is_a_dirty_checkout"
is_dirty = subprocess.check_output( is_dirty = subprocess.check_output(
['git', 'describe', '--dirty=' + dirty_string], ['git', 'describe', '--dirty=' + dirty_string],
stderr=null, stderr=null,
cwd=cwd, cwd=cwd,
).strip().endswith(dirty_string) ).strip().endswith(dirty_string)
git_dirty = "dirty" if is_dirty else "" git_dirty = "dirty" if is_dirty else ""
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
git_dirty = "" git_dirty = ""
if git_branch or git_tag or git_commit or git_dirty: if git_branch or git_tag or git_commit or git_dirty:
git_version = ",".join( git_version = ",".join(
s for s in s for s in
(git_branch, git_tag, git_commit, git_dirty,) (git_branch, git_tag, git_commit, git_dirty,)
if s if s
)
return (
"Synapse/%s (%s)" % (
synapse.__version__, git_version,
) )
).encode("ascii")
return (
"Synapse/%s (%s)" % (
synapse.__version__, git_version,
)
).encode("ascii")
except Exception as e:
logger.warn("Failed to check for git repository: %s", e)
return ("Synapse/%s" % (synapse.__version__,)).encode("ascii") return ("Synapse/%s" % (synapse.__version__,)).encode("ascii")