From 45c1958d8368084090c0bdd3706cf59a0d15e239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 2 Sep 2014 12:06:02 +0200 Subject: [PATCH] Versioneer now also returns and persists the branch from which OctoPrint was installed Changed version output accordingly to now display "{version} ({branch} branch)" if branch information is available (which should be the case if installation was performed from git). (cherry picked from commit a48b5de) --- src/octoprint/_version.py | 11 +++++++++-- src/octoprint/server/__init__.py | 9 +++++++-- src/octoprint/templates/index.jinja2 | 2 +- versioneer.py | 25 +++++++++++++++++++++---- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/octoprint/_version.py b/src/octoprint/_version.py index 52aefd49..3808a4f8 100644 --- a/src/octoprint/_version.py +++ b/src/octoprint/_version.py @@ -166,7 +166,7 @@ def versions_from_lookup(lookup, root, verbose=False): if dirty: version += "-dirty" full += "-dirty" - return {"version": version, "full": full} + return {"version": version, "full": full, "branch": current_branch} return {} @@ -195,7 +195,14 @@ def versions_from_vcs(tag_prefix, root, verbose=False): full = stdout.strip() if tag.endswith("-dirty"): full += "-dirty" - return {"version": tag, "full": full} + + stdout = run_command(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], + cwd=root) + if stdout is None: + branch = None + else: + branch = stdout.strip() + return {"version": tag, "full": full, "branch": branch} def versions_from_parentdir(parentdir_prefix, root, verbose=False): diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 692bc5f0..3f38b899 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -41,8 +41,12 @@ import octoprint.timelapse import octoprint._version -VERSION = octoprint._version.get_versions()['version'] +versions = octoprint._version.get_versions() +VERSION = versions['version'] +BRANCH = versions['branch'] if 'branch' in versions else None +DISPLAY_VERSION = "%s (%s branch)" % (VERSION, BRANCH) if BRANCH else VERSION +del versions @app.route("/") def index(): @@ -58,6 +62,7 @@ def index(): firstRun=settings().getBoolean(["server", "firstRun"]) and (userManager is None or not userManager.hasBeenCustomized()), debug=debug, version=VERSION, + display_version=DISPLAY_VERSION, stylesheet=settings().get(["devel", "stylesheet"]), gcodeMobileThreshold=settings().get(["gcodeViewer", "mobileSizeThreshold"]), gcodeThreshold=settings().get(["gcodeViewer", "sizeThreshold"]) @@ -126,7 +131,7 @@ class Server(): self._initLogging(self._debug) logger = logging.getLogger(__name__) - logger.info("Starting OctoPrint (%s)" % VERSION) + logger.info("Starting OctoPrint %s" % DISPLAY_VERSION) eventManager = events.eventManager() gcodeManager = gcodefiles.GcodeManager() diff --git a/src/octoprint/templates/index.jinja2 b/src/octoprint/templates/index.jinja2 index 70c30fd6..28d5b4f3 100644 --- a/src/octoprint/templates/index.jinja2 +++ b/src/octoprint/templates/index.jinja2 @@ -597,7 +597,7 @@