Skip to content

Commit

Permalink
*New* g.gitDescribe() - fetch {tag}{distance}{commit}
Browse files Browse the repository at this point in the history
This is my first contribution to a core module. Please inspect and verify.

Leo build: 20171112224958
  • Loading branch information
maphew committed Nov 13, 2017
1 parent e1129da commit d4a890b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions leo/core/commit_timestamp.json
Original file line number Diff line number Diff line change
@@ -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"
}
16 changes: 16 additions & 0 deletions leo/core/leoGlobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
'''
Expand Down

0 comments on commit d4a890b

Please sign in to comment.