blob: ddd0d1eab8ddd5d2f51d6f16c54658d370489fa4 (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/env bash
#
# Forbid scripts containing a un underscore in their filename,
# (except where this is required, for example Python modules).
#
# This is a just a matter of style and taste; there are no correctness
# implications.
#
# Exceptions are supported, by passing !<FILENAME> or !<GLOB> as argument(s).
set -euo pipefail
# this include stanza is automatically maintained by update-shell-includes
common_dir=$(realpath "$0")
common_dir=$(dirname "$common_dir")
# shellcheck source=maint/common/bash-utils.sh
. "$common_dir"/bash-utils.sh
reject_options
exceptions=()
for arg in "$@"; do
case "$arg" in
!*) exceptions+=("${arg#!}") ;;
*)
fail 'non-option arguments msut be !FILE to allow FILE as an exception'
;;
esac
done
shopt -s nullglob
wrong=()
# git shell escapes things by default, see git-ls-files(1) and git-config(1) core.quotepath
files=$(git ls-files ':maint/*_*')
for f in $files; do
case "$f" in
*.py) ;;
*)
excepted=false
for exception in "${exceptions[@]}"; do
# shellcheck disable=SC2254
case "$f" in
$exception) excepted=true ;;
esac
done
if ! $excepted; then
wrong+=("$f")
fi
;;
esac
done
if [ "${wrong[*]}" != '' ]; then
fail "We would like script names to have hyphens, not underscores
Please rename these files:
${wrong[*]}
"
fi
|