|
3 | 3 | set -e |
4 | 4 |
|
5 | 5 | function print_usage() { |
6 | | - echo "usage check_diff REMOTE_REPO FEATURE_BRANCH [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]" |
| 6 | + echo "usage check_diff REMOTE_REPO FEATURE_BRANCH STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]" |
7 | 7 | } |
8 | 8 |
|
9 | 9 | if [ $# -le 1 ]; then |
|
13 | 13 |
|
14 | 14 | REMOTE_REPO=$1 |
15 | 15 | FEATURE_BRANCH=$2 |
16 | | -OPTIONAL_COMMIT_HASH=$3 |
17 | | -OPTIONAL_RUSTFMT_CONFIGS=$4 |
| 16 | +# Can still be overridden by style edition configuration in `OPTIONAL_RUSTFMT_CONFIGS`. This is a |
| 17 | +# separate arg mostly to make sure it's not forgotten when manually dispatching the Diff Check |
| 18 | +# workflow. |
| 19 | +STYLE_EDITION=$3 |
| 20 | +OPTIONAL_COMMIT_HASH=$4 |
| 21 | +OPTIONAL_RUSTFMT_CONFIGS=$5 |
18 | 22 |
|
19 | 23 | # OUTPUT array used to collect all the status of running diffs on various repos |
20 | 24 | STATUSES=() |
@@ -44,13 +48,19 @@ function init_submodules() { |
44 | 48 | # $3: Any additional configuration options to pass to rustfmt |
45 | 49 | # |
46 | 50 | # Globals: |
47 | | -# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4 |
| 51 | +# $STYLE_EDITION: Style edition; can be overridden by style edition specified in |
| 52 | +# `$OPTIONAL_RUSTFMT_CONFIGS`. |
| 53 | +# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script |
48 | 54 | function create_diff() { |
49 | 55 | local config; |
| 56 | + # Unconditionally set |
| 57 | + config="--config=error_on_line_overflow=false,error_on_unformatted=false" |
| 58 | + # Can still be overridden by later `style_edition` configurations in |
| 59 | + # `$OPTIONAL_RUSTFMT_CONFIGS`. |
| 60 | + config="$config,style_edition=$STYLE_EDITION" |
| 61 | + |
50 | 62 | if [ -z "$3" ]; then |
51 | | - config="--config=error_on_line_overflow=false,error_on_unformatted=false" |
52 | | - else |
53 | | - config="--config=error_on_line_overflow=false,error_on_unformatted=false,$OPTIONAL_RUSTFMT_CONFIGS" |
| 63 | + config="$config,$OPTIONAL_RUSTFMT_CONFIGS" |
54 | 64 | fi |
55 | 65 |
|
56 | 66 | for i in `find . | grep "\.rs$"` |
@@ -191,6 +201,8 @@ function log_inputs() { |
191 | 201 | echo "$REMOTE_REPO" |
192 | 202 | echo "Feature branch:" |
193 | 203 | echo "$FEATURE_BRANCH" |
| 204 | + echo "Style edition:" |
| 205 | + echo "$STYLE_EDITION" |
194 | 206 | echo "(Optional) Commit hash:" |
195 | 207 | echo "$OPTIONAL_COMMIT_HASH" |
196 | 208 | echo "(Optional) Rustfmt configs:" |
|
0 commit comments