From d4a890b491bbbb03212f71d5a5e00af0a139a8e7 Mon Sep 17 00:00:00 2001 From: Matt Wilkie Date: Sun, 12 Nov 2017 22:50:00 -0800 Subject: [PATCH] *New* g.gitDescribe() - fetch {tag}{distance}{commit} This is my first contribution to a core module. Please inspect and verify. Leo build: 20171112224958 --- leo/core/commit_timestamp.json | 4 ++-- leo/core/leoGlobals.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/leo/core/commit_timestamp.json b/leo/core/commit_timestamp.json index 2ac66d9a1a..0516ae3b53 100644 --- a/leo/core/commit_timestamp.json +++ b/leo/core/commit_timestamp.json @@ -1,4 +1,4 @@ { - "asctime": "Sat Nov 11 15:30:29 PST 2017", - "timestamp": "20171111153029" + "asctime": "Sun, Nov 12, 2017 10:49:58 PM", + "timestamp": "20171112224958" } diff --git a/leo/core/leoGlobals.py b/leo/core/leoGlobals.py index 7834d2ae81..a1f1747a2e 100644 --- a/leo/core/leoGlobals.py +++ b/leo/core/leoGlobals.py @@ -4257,6 +4257,22 @@ def gitCommitNumber(path=None): ''' branch, commit = g.gitInfo(path) return commit +#@+node:maphew.20171112205129.1: *3* g.gitDescribe +def gitDescribe(path=None): + ''' + Return the Git tag, distance-from-tag, and commit hash for the + associated path. If path is None, use the leo-editor directory. + + Given `git describe` cmd line output: `v5.6-55-ge1129da\n` + This function returns ('v5.6', '55', 'e1129da') + ''' + describe = g.execGitCommand('git describe', path) + tag, distance, commit = describe[0].split('-') + #strip leading 'g' from commit hash (it's not part of the hash) + if 'g' in commit[0:]: commit = commit[1:] + commit = commit.rstrip() + + return tag, distance, commit #@+node:ekr.20170414034616.6: *3* g.gitHeadPath def gitHeadPath(path=None): '''