@@ -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,11 +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
96
- echo " $diff "
103
+ echo " Copying diffs between rustfmt and feature branch to $OUTPUT_DIR /$1 /diff.txt"
104
+ echo " $diff " >> $OUTPUT_DIR /$1 /diff.txt
97
105
return 1
98
106
fi
99
107
}
@@ -160,11 +168,27 @@ function check_repo() {
160
168
cd $WORKDIR
161
169
}
162
170
171
+ # Zip up all the diff changes detected by the script
172
+ #
173
+ # Globlas:
174
+ # $OUTPUT_DIR: Output directory where all `*diif.txt` files are written to. Set in `main`.
175
+ # $CURRENT_DIR: The directory where the script was run from. Set in `main`.
176
+ function zip_up_diffs() {
177
+ cd $OUTPUT_DIR
178
+
179
+ # Just to clean things up we'll make sure to remove empty files and directories
180
+ find . -type f -empty -delete
181
+ find . -type d -empty -delete
182
+ zip -q -r $CURRENT_DIR /diff-check .
183
+ }
184
+
163
185
function main() {
186
+ CURRENT_DIR=$( pwd)
164
187
tmp_dir=$( mktemp -d -t rustfmt-XXXXXXXX)
165
188
echo Created tmp_dir $tmp_dir
166
189
167
190
compile_rustfmt $tmp_dir
191
+ OUTPUT_DIR=$( mktemp -d -t diff-output-XXX)
168
192
169
193
# run checks
170
194
check_repo " https://github.com/rust-lang/rust.git" rust-lang-rust
@@ -191,9 +215,12 @@ function main() {
191
215
check_repo " https://github.com/actix/actix.git" actix
192
216
check_repo " https://github.com/denoland/deno.git" denoland_deno
193
217
218
+ zip_up_diffs
219
+
194
220
# cleanup temp dir
195
- echo removing tmp_dir $tmp_dir
221
+ echo removing tmp_dir $tmp_dir and $OUTPUT_DIR
196
222
rm -rf $tmp_dir
223
+ rm -rf $OUTPUT_DIR
197
224
198
225
# figure out the exit code
199
226
for status in ${STATUSES[@]}
0 commit comments