21
21
# you've written is kosher to CI
22
22
#
23
23
# Usage:
24
- # restyle-diff.sh [ref]
24
+ # restyle-diff.sh [-d] [ ref]
25
25
#
26
26
# if unspecified, ref defaults to upstream/master (or master)
27
+ # -d sets container's log level to DEBUG, if unspecified the default log level will remain (info level)
27
28
#
28
29
29
30
here=${0%/* }
@@ -33,20 +34,55 @@ set -e
33
34
CHIP_ROOT=$( cd " $here /../.." && pwd)
34
35
cd " $CHIP_ROOT "
35
36
36
- restyle-paths () {
37
- if hash restyle-path 2> /dev/null; then
38
- echo " $@ " | xargs restyle-path
37
+ docker_run () {
38
+ if [ -t 0 ]; then
39
+ exec docker run --tty " $@ "
40
+
39
41
else
40
- url=https://github.com/restyled-io/restyler/raw/main/bin/restyle-path
41
- echo " $@ " | xargs sh <( curl --location --proto " =https " --tlsv1.2 " $url " -sSf )
42
+ exec docker run " $@ "
43
+
42
44
fi
43
45
}
44
46
45
- ref=" $1 "
47
+ restyle-paths () {
48
+
49
+ image=restyled/restyler:edge
50
+
51
+ for path in " $@ " ; do
52
+ (
53
+ docker_run --tty --interactive --rm \
54
+ --env LOG_LEVEL \
55
+ --env LOG_DESTINATION \
56
+ --env LOG_FORMAT \
57
+ --env LOG_COLOR \
58
+ --env HOST_DIRECTORY=" $PWD " \
59
+ --env UNRESTRICTED=1 \
60
+ --volume " $PWD " :/code \
61
+ --volume /tmp:/tmp \
62
+ --volume /var/run/docker.sock:/var/run/docker.sock \
63
+ --entrypoint restyle-path \
64
+ " $image " " $path "
65
+ )
66
+ done
67
+ }
68
+
69
+ while [[ $# -gt 0 ]]; do
70
+ case " $1 " in
71
+ -d)
72
+ export LOG_LEVEL=" DEBUG"
73
+ shift
74
+ ;;
75
+ * )
76
+ ref=" $1 "
77
+ shift
78
+ ;;
79
+ esac
80
+ done
81
+
46
82
if [[ -z " $ref " ]]; then
47
83
ref=" master"
48
84
git remote | grep -qxF upstream && ref=" upstream/master"
49
85
fi
50
86
51
- declare -a paths=( " $( git diff --ignore-submodules --name-only --merge-base " $ref " ) " )
87
+ mapfile -t paths < <( git diff --ignore-submodules --name-only --merge-base " $ref " )
52
88
restyle-paths " ${paths[@]} "
0 commit comments