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).
This commit is contained in:
parent
212f40cd1a
commit
a48b5deb29
6 changed files with 43 additions and 13 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -49,7 +49,12 @@ from . import util
|
|||
|
||||
|
||||
UI_API_KEY = ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes)
|
||||
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
|
||||
|
||||
|
||||
def get_available_locale_identifiers(locales):
|
||||
|
|
@ -95,6 +100,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"]),
|
||||
|
|
@ -163,9 +169,7 @@ class Server():
|
|||
self._initLogging(self._debug, self._logConf)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info("Starting OctoPrint (%s)" % VERSION)
|
||||
|
||||
logger.info("Starting OctoPrint (%s)" % VERSION)
|
||||
logger.info("Starting OctoPrint %s" % DISPLAY_VERSION)
|
||||
|
||||
eventManager = events.eventManager()
|
||||
gcodeManager = gcodefiles.GcodeManager()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class PrinterStateConnection(sockjs.tornado.SockJSConnection):
|
|||
self._logger.info("New connection from client: %s" % remoteAddress)
|
||||
|
||||
# connected => update the API key, might be necessary if the client was left open while the server restarted
|
||||
self._emit("connected", {"apikey": octoprint.server.UI_API_KEY, "version": octoprint.server.VERSION})
|
||||
self._emit("connected", {"apikey": octoprint.server.UI_API_KEY, "version": octoprint.server.VERSION, "display_version": octoprint.server.DISPLAY_VERSION})
|
||||
|
||||
self._printer.registerCallback(self)
|
||||
self._gcodeManager.registerCallback(self)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ function DataUpdater(loginStateViewModel, connectionViewModel, printerStateViewM
|
|||
});
|
||||
|
||||
VERSION = data["version"];
|
||||
$("span.version").text(VERSION);
|
||||
DISPLAY_VERSION = data["display_version"];
|
||||
$("span.version").text(DISPLAY_VERSION);
|
||||
|
||||
if ($("#offline_overlay").is(":visible")) {
|
||||
$("#offline_overlay").hide();
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
var UI_API_KEY = "{{ uiApiKey }}";
|
||||
var VERSION = "{{ version }}";
|
||||
var DISPLAY_VERSION = "{{ display_version }}";
|
||||
var LOCALE = "{{ g.locale }}";
|
||||
</script>
|
||||
</head>
|
||||
|
|
@ -589,7 +590,7 @@
|
|||
</div>
|
||||
<div class="footer">
|
||||
<ul class="pull-left muted">
|
||||
<li><small>{{ _('Version') }}: <span class="version">{{ version }}</span></small></li>
|
||||
<li><small>{{ _('Version') }}: <span class="version">{{ display_version }}</span></small></li>
|
||||
</ul>
|
||||
<ul class="pull-right">
|
||||
<li><a href="http://octoprint.org"><i class="icon-home"></i> {{ _('Homepage') }}</a></li>
|
||||
|
|
|
|||
|
|
@ -425,7 +425,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 {}
|
||||
|
||||
|
|
@ -454,7 +454,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):
|
||||
|
|
@ -685,7 +692,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 {}
|
||||
|
||||
|
|
@ -715,7 +722,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):
|
||||
|
|
@ -787,7 +801,10 @@ SHORT_VERSION_PY = """
|
|||
|
||||
version_version = '%(version)s'
|
||||
version_full = '%(full)s'
|
||||
version_branch = %(branch)r
|
||||
def get_versions(default={}, verbose=False):
|
||||
if version_branch:
|
||||
return {'version': version_version, 'full': version_full, 'branch': version_branch}
|
||||
return {'version': version_version, 'full': version_full}
|
||||
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue