File: autover.sh

package info (click to toggle)
snapraid 13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,656 kB
  • sloc: ansic: 46,018; makefile: 1,004; sh: 154
file content (24 lines) | stat: -rwxr-xr-x 509 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
#

if [ -d .git ]; then
    # Get version from git tags, removing the 'v' prefix
    VERSION=$(git describe --match 'v*' 2>/dev/null | sed 's/^v//')
fi

if [ -f .version ]; then
    # Get version from the .version file
    VERSION=$(cat .version)
fi

if [ -z "$VERSION" ] && [ -d .git ]; then
    # Fall back to short commit hash
    VERSION=0-$(git rev-parse --short HEAD 2>/dev/null)
fi

if [ -z $VERSION ]; then
    # No version, but still use a number
    VERSION="0"
fi

printf '%s' "$VERSION"