@@ -32,85 +32,47 @@ here=${0%/*}
32
32
33
33
set -e
34
34
35
+ MAX_ARGS=256
36
+ pull_image=0
37
+
35
38
CHIP_ROOT=$( cd " $here /../.." && pwd)
36
39
cd " $CHIP_ROOT "
37
40
38
- docker_run () {
39
- if [ -t 0 ]; then
40
- exec docker run --tty " $@ "
41
-
42
- else
43
- exec docker run " $@ "
44
-
45
- fi
46
- }
47
-
48
41
restyle-paths () {
49
42
image=restyled/restyler:edge
50
- batch_size=4
51
- batch=()
52
-
53
- for path in " $@ " ; do
54
- batch+=(" $path " )
55
- if [[ ${# batch[@]} -eq $batch_size ]]; then
56
- for p in " ${batch[@]} " ; do
57
- (
58
- docker_run \
59
- --env LOG_LEVEL \
60
- --env LOG_DESTINATION \
61
- --env LOG_FORMAT \
62
- --env LOG_COLOR \
63
- --env HOST_DIRECTORY=" $PWD " \
64
- --env UNRESTRICTED=1 \
65
- --volume " $PWD " :/code \
66
- --volume /tmp:/tmp \
67
- --volume /var/run/docker.sock:/var/run/docker.sock \
68
- --entrypoint restyle-path \
69
- " $image " " $p "
70
- ) &
71
- done
72
- wait
73
- batch=()
74
- fi
75
- done
76
-
77
- if [[ ${# batch[@]} -gt 0 ]]; then
78
- for p in " ${batch[@]} " ; do
79
- (
80
- docker_run \
81
- --env LOG_LEVEL \
82
- --env LOG_DESTINATION \
83
- --env LOG_FORMAT \
84
- --env LOG_COLOR \
85
- --env HOST_DIRECTORY=" $PWD " \
86
- --env UNRESTRICTED=1 \
87
- --volume " $PWD " :/code \
88
- --volume /tmp:/tmp \
89
- --volume /var/run/docker.sock:/var/run/docker.sock \
90
- --entrypoint restyle-path \
91
- " $image " " $p "
92
- ) &
93
- done
94
- wait
95
- fi
43
+ (
44
+ docker run \
45
+ --env LOG_LEVEL \
46
+ --env LOG_DESTINATION \
47
+ --env LOG_FORMAT \
48
+ --env LOG_COLOR \
49
+ --env HOST_DIRECTORY=" $PWD " \
50
+ --env UNRESTRICTED=1 \
51
+ --volume " $PWD " :/code \
52
+ --volume /tmp:/tmp \
53
+ --volume /var/run/docker.sock:/var/run/docker.sock \
54
+ --entrypoint restyle-path \
55
+ " $image " " $@ "
56
+ )
96
57
}
97
58
98
- pull_image=0
59
+ # This was added to be able to use xargs to call the function restyle-paths
60
+ export -f restyle-paths
99
61
100
62
while [[ $# -gt 0 ]]; do
101
63
case " $1 " in
102
- -d)
103
- export LOG_LEVEL=" DEBUG"
104
- shift
105
- ;;
106
- -p)
107
- pull_image=1
108
- shift
109
- ;;
110
- * )
111
- ref=" $1 "
112
- shift
113
- ;;
64
+ -d)
65
+ export LOG_LEVEL=" DEBUG"
66
+ shift
67
+ ;;
68
+ -p)
69
+ pull_image=1
70
+ shift
71
+ ;;
72
+ * )
73
+ ref=" $1 "
74
+ shift
75
+ ;;
114
76
esac
115
77
done
116
78
@@ -123,5 +85,6 @@ if [[ $pull_image -eq 1 ]]; then
123
85
docker pull restyled/restyler:edge
124
86
fi
125
87
126
- mapfile -t paths < <( git diff --ignore-submodules --name-only --merge-base " $ref " )
127
- restyle-paths " ${paths[@]} "
88
+ paths=$( git diff --ignore-submodules --name-only --merge-base " $ref " )
89
+
90
+ echo " $paths " | xargs -n $MAX_ARGS bash -c ' restyle-paths "$@"'
0 commit comments