From d698bf4e1b2033245d39af85bb5876500c3fbfde Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Mon, 10 Jul 2023 11:07:49 -0400 Subject: [PATCH] use the `branch_name` as the default for the optional commit hash There was an issue with the script when passing optional rustfmt configs without specifying a commit hash. Because these optional values are passed via positional arguments the configs ($4) would be used in place of the commit hash ($3). Now that we set a default value for the optional commit hash we avoid this problem. --- .github/workflows/check_diff.yml | 2 +- ci/check_diff.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_diff.yml b/.github/workflows/check_diff.yml index 8bfb5834519c..2f2beb769159 100644 --- a/.github/workflows/check_diff.yml +++ b/.github/workflows/check_diff.yml @@ -30,4 +30,4 @@ jobs: rustup target add x86_64-unknown-linux-gnu - name: check diff - run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.event.inputs.commit_hash }} ${{ github.event.inputs.rustfmt_configs }} + run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.event.inputs.commit_hash || github.event.inputs.branch_name }} ${{ github.event.inputs.rustfmt_configs }} diff --git a/ci/check_diff.sh b/ci/check_diff.sh index a685c2e108e6..50c58b1f4925 100755 --- a/ci/check_diff.sh +++ b/ci/check_diff.sh @@ -115,7 +115,7 @@ function compile_rustfmt() { git fetch feature $FEATURE_BRANCH cargo build --release --bin rustfmt && cp target/release/rustfmt $1/rustfmt - if [ -z "$OPTIONAL_COMMIT_HASH" ]; then + if [ -z "$OPTIONAL_COMMIT_HASH" ] || [ "$FEATURE_BRANCH" = "$OPTIONAL_COMMIT_HASH" ]; then git switch $FEATURE_BRANCH else git switch $OPTIONAL_COMMIT_HASH --detach