forked from red/red
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-version.r
45 lines (41 loc) · 979 Bytes
/
git-version.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
REBOL [
Title: "Get git version data"
Author: "Will Arp"
File: %git-version.r
Tabs: 4
Rights: "Copyright (C) 2011-2018 Red Foundation. All rights reserved."
License: "BSD-3 - https://github.com/red/red/blob/master/BSD-3-License.txt"
]
context [
out: make string! 1024
err: make string! 1024
git: func [cmd][
clear out
clear err
unless all [
0 = call/output/error join "git " cmd out err
empty? err
][
make error! "Git command not available or failed or not in a Git repo"
]
copy trim/tail out
]
set 'git-version has [temp] [
attempt [
temp: parse git "describe --long" "-"
compose/deep [
context [
branch: (git "rev-parse --abbrev-ref HEAD")
tag: (to issue! temp/1)
ahead: (to integer! temp/2)
date: to-local-date to date! (
to integer! git {log -1 --pretty=format:"%ct"}
)
commit: (to issue! git "rev-parse HEAD")
message: (git "log -1 --pretty=%B")
]
]
]
]
]
git-version