poe

Уређивач .po фајлова
git clone https://git.sr.ht/~strahinja/poe
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

makeversion (1227B)


      1 #!/bin/sh -x
      2 # vim: set ft=bash:
      3 FALLBACKVER=${FALLBACKVER:-unknown}
      4 
      5 if [ -d .got ] && command -v got >/dev/null 2>&1; then
      6 	lastcommit=$(got log |
      7 		awk '/^commit/ {print substr($2,1,7); exit}')
      8 	got tag -l |
      9 		awk -v lastcommit="$lastcommit" '
     10 		/^object: commit/ {
     11 			if (!lasttagcom)
     12 			{
     13 				lasttagcom = substr($3,1,9)
     14 			}
     15 			next
     16 		}
     17 		/^tag/ {
     18 			if (!ver)
     19 			{
     20 				sub(/^v/,"",$2)
     21 				ver = $2
     22 			}
     23 			next
     24 		}
     25 		END {
     26 			printf "%s", ver
     27 			if (lastcommit != lasttagcom)
     28 			{
     29 				printf "-g%s", lastcommit
     30 			}
     31 			printf "\n"
     32 		}' >version.new
     33 elif [ -d .git ] && command -v git >/dev/null 2>&1; then
     34 	LC_ALL=C
     35 	export LC_ALL
     36 	user=$(unalias ls >/dev/null 2>&1 || true; \
     37 		command ls -ld . | awk '{print $3}')
     38 	e_user=$(id -un)
     39 	if [ "$e_user" = "$user" ]; then
     40 		git describe 2>/dev/null | sed 's/^v//' >version.new
     41 	else
     42 		su "${user}" -c 'git describe' 2>/dev/null |
     43 			sed 's/^v//' >version.new
     44 	fi
     45 else
     46 	printf "%s\n" "$FALLBACKVER" >version.new
     47 fi
     48 
     49 if [ -f version ]; then
     50 	if diff version version.new >/dev/null; then
     51 		rm version.new
     52 	else
     53 		mv version.new version
     54 		touch .rebuild
     55 	fi
     56 else
     57 	mv version.new version
     58 	touch .rebuild
     59 fi
     60 if [ "$1" = "-l" ]; then
     61 	printf "VERSION=\"%s\"\n" "$(cat version)"
     62 fi