File: get-version-from-git

package info (click to toggle)
linuxcnc 1%3A2.9.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 285,604 kB
  • sloc: python: 202,568; ansic: 109,036; cpp: 99,239; tcl: 16,054; xml: 10,631; sh: 10,303; makefile: 1,255; javascript: 138; sql: 72; asm: 15
file content (30 lines) | stat: -rwxr-xr-x 938 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
25
26
27
28
29
30
#!/bin/bash

if [ ! -z "$EMC2_HOME" ]; then
    source $EMC2_HOME/scripts/githelper.sh
else
    source $(git rev-parse --show-toplevel)/scripts/githelper.sh
fi

githelper $1

if [ "$DEB_COMPONENT" = "scratch" ]; then

    DESCRIBE=$(git describe --tags --exact-match 2>/dev/null)
    if [ -n "$DESCRIBE" ]; then
        echo "$DESCRIBE"
    else
        DESCRIBE=$(git describe --tags 2>/dev/null)
        if [ -n "$DESCRIBE" ]; then
            echo "$DESCRIBE"
        else
            BR=$(printf '%s' "$GIT_BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^-.+:~a-z0-9]/-/g; s/-{2,}/-/g; s/^-//; s/-$//')
            echo "v$(git show HEAD:VERSION | cut -d ' ' -f 1)~${BR:-head}~$(git show --pretty=format:%h HEAD | head -1)"
        fi
    fi
else
    # known branches get the "describe" of the most recent signed git tag,
    # or of the most recent unsigned tag if no signed tags are found
    git describe --match "$GIT_TAG"
fi