@@ -71,6 +71,7 @@ function create_diff() {
71
71
# $RUSFMT_BIN: Path to the rustfmt master binary. Created when running `compile_rustfmt`
72
72
# $FEATURE_BIN: Path to the rustfmt feature binary. Created when running `compile_rustfmt`
73
73
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
74
+ # $OUTPUT_DIR: Path to an output directory for storing the diff files. Set in `main`
74
75
function check_diff() {
75
76
echo " running rustfmt (master) on $1 "
76
77
create_diff $RUSFMT_BIN rustfmt_diff.txt
@@ -89,10 +90,18 @@ function check_diff() {
89
90
--unified=0 --no-index rustfmt_diff.txt feature_diff.txt 2>&1 | tail -n +6 | cut -c 2-
90
91
)
91
92
93
+ # COPY diffs into output dir
94
+ mkdir $OUTPUT_DIR /$1
95
+ echo " Copying diffs to $OUTPUT_DIR /$1 "
96
+ cp rustfmt_diff.txt $OUTPUT_DIR /$1 /rustfmt_diff.txt
97
+ cp feature_diff.txt $OUTPUT_DIR /$1 /feature_diff.txt
98
+
92
99
if [ -z " $diff " ]; then
93
100
echo " no diff detected between rustfmt and the feture branch"
94
101
return 0
95
102
else
103
+ echo " Copying diffs between rustfmt and feature branch to $OUTPUT_DIR /$1 /diff.txt"
104
+ echo " $diff " >> $OUTPUT_DIR /$1 /diff.txt
96
105
echo " $diff "
97
106
return 1
98
107
fi
@@ -160,11 +169,27 @@ function check_repo() {
160
169
cd $WORKDIR
161
170
}
162
171
172
+ # Zip up all the diff changes detected by the script
173
+ #
174
+ # Globlas:
175
+ # $OUTPUT_DIR: Output directory where all `*diif.txt` files are written to. Set in `main`.
176
+ # $CURRENT_DIR: The directory where the script was run from. Set in `main`.
177
+ function zip_up_diffs() {
178
+ cd $OUTPUT_DIR
179
+
180
+ # Just to clean things up we'll make sure to remove empty files and directories
181
+ find . -type f -empty -delete
182
+ find . -type d -empty -delete
183
+ zip -q -r $CURRENT_DIR /diff-check .
184
+ }
185
+
163
186
function main() {
187
+ CURRENT_DIR=$( pwd)
164
188
tmp_dir=$( mktemp -d -t rustfmt-XXXXXXXX)
165
189
echo Created tmp_dir $tmp_dir
166
190
167
191
compile_rustfmt $tmp_dir
192
+ OUTPUT_DIR=$( mktemp -d -t diff-output-XXX)
168
193
169
194
# run checks
170
195
check_repo " https://github.com/rust-lang/rust.git" rust-lang-rust
@@ -191,9 +216,12 @@ function main() {
191
216
check_repo " https://github.com/actix/actix.git" actix
192
217
check_repo " https://github.com/denoland/deno.git" denoland_deno
193
218
219
+ zip_up_diffs
220
+
194
221
# cleanup temp dir
195
- echo removing tmp_dir $tmp_dir
222
+ echo removing tmp_dir $tmp_dir and $OUTPUT_DIR
196
223
rm -rf $tmp_dir
224
+ rm -rf $OUTPUT_DIR
197
225
198
226
# figure out the exit code
199
227
for status in ${STATUSES[@]}
0 commit comments