Skip to content

Commit 70d63fb

Browse files
committed
Add: Add version.sh
1 parent 1f2ab68 commit 70d63fb

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

version.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2018 coord.e
4+
#
5+
# This file is part of servoarray.
6+
#
7+
# servoarray is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# servoarray is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with servoarray. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
# This script prints semver-compatible version string calculated from current state of git
21+
22+
set -euo pipefail
23+
24+
cd "$(dirname "$0")"
25+
26+
function detailed() {
27+
local annotated=$(git describe --tags --abbrev=0 2> /dev/null)
28+
local description=$(git describe --always)
29+
local replaced=${description/${annotated}-/${annotated}+}
30+
local semver=${replaced#v}
31+
echo $semver
32+
}
33+
34+
function simple() {
35+
local annotated=$(git describe --tags --abbrev=0 2> /dev/null)
36+
echo ${annotated#v}
37+
}
38+
39+
${1:-detailed}

0 commit comments

Comments
 (0)