File: repo_version.bash

package info (click to toggle)
quickplot 1.0.1~rc-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,520 kB
  • sloc: ansic: 16,758; sh: 11,416; makefile: 337
file content (30 lines) | stat: -rwxr-xr-x 486 bytes parent folder | download | duplicates (2)
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 test -z "$2" ; then
  echo "Usage: $0 REPO_VERSION_FILE SRC_DIR"
  exit 1
fi

cd "$2" || exit 1

mod=
ret="$(git log --oneline | wc -l)"
if git status -s | egrep -q '*M ' ; then
    mod=M # the source has modifications
fi

if [ "$ret" = "0" ] ; then
  if [ -d "$2/.git" ] ; then
    echo "unknown"
  else
    cat "$1"
  fi
elif [ "$ret" = "Unversioned directory" ] ; then
  if [ -f "$1" ] ; then
    cat "$1"
  else
    echo "Unknown"
  fi
else
  echo "${ret}${mod}"
fi