File: check_new_strings.sh

package info (click to toggle)
cpu-x 5.4.0-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,304 kB
  • sloc: ansic: 36,860; cpp: 8,094; asm: 7,291; sh: 693; xml: 190; makefile: 11
file content (33 lines) | stat: -rwxr-xr-x 913 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
31
32
33
#!/usr/bin/env bash
# This script is used to check if there are new strings in source files

set -euo pipefail

GIT_DIR="$(git rev-parse --show-toplevel)"
SHA=${GITHUB_SHA:-HEAD~0}
cd "$GIT_DIR" || exit 1

if [[ "$(git show -s --format='%ce' "$SHA")" == "hosted@weblate.org" ]]; then
	echo "Commit by Weblate, nothing to do." > /dev/stderr
	echo "NO_CHANGE"
	exit 0
fi

for file in $(git show --pretty="" --name-only "$SHA"); do
	if [[ "$file" =~ \.(c|h|cpp|hpp)$ ]]; then
		if git show --unified=0 "$SHA" "$file" | grep -E -qw '_\(|N_\('; then
			git --no-pager show "$SHA" "$file" > /dev/stderr
			echo "REGEN"
			exit 0
		fi
	elif [[ "$file" =~ \.(ui)$ ]]; then
		if git show --unified=0 "$SHA" "$file" | grep -E -qw 'translatable="yes"'; then
			git --no-pager show "$SHA" "$file" > /dev/stderr
			echo "REGEN"
			exit 0
		fi
	fi
done

echo "No commit with translation change." > /dev/stderr
echo "NO_CHANGE"