File: gen_extraversion

package info (click to toggle)
swupdate 2025.12%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 10,004 kB
  • sloc: ansic: 66,621; python: 6,291; makefile: 791; sh: 538; javascript: 229
file content (26 lines) | stat: -rwxr-xr-x 681 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env sh
#
# Copyright (C) 2024, Daniel Braunwarth <oss@braunwarth.dev>
#
# SPDX-License-Identifier: GPL-2.0-or-later

EXTRA_VERSION=""

# Check if we are in a git repository
if [ -z "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
	exit 0
fi

# If we are on an untagged commit, append the short commit hash
if [ -z "$(git describe --tags --exact-match 2>/dev/null)" ]; then
	EXTRA_VERSION="${EXTRA_VERSION}-$(git rev-parse --short HEAD)"
fi

# If the working directory is dirty, append -dirty
if [ -n "$(git --no-optional-locks status -uno --porcelain 2>/dev/null)" ]; then
	EXTRA_VERSION="${EXTRA_VERSION}-dirty"
fi

printf "%s" "${EXTRA_VERSION#-}"

exit 0