|
47 | 47 | echo "::notice::Parsing base ref '$FROM'"
|
48 | 48 | # If we do have the base ref, it can be a branch name, so we want to
|
49 | 49 | # parse it. This will be a pass through for a SHA
|
50 |
| - FROM="$(git show-ref --hash "$FROM" | tail -n1)" |
| 50 | + # via the event context, and we should try to find the default |
| 51 | + # branch instead (see below) |
| 52 | + if ! git show-ref --hash "$FROM" &>/dev/null; then |
| 53 | + # No such ref, so we try the next step |
| 54 | + FROM="" |
| 55 | + else |
| 56 | + FROM="$(git show-ref --hash "$FROM" | tail -n1)" |
| 57 | + fi |
51 | 58 | fi
|
52 | 59 | fi
|
53 | 60 | # If we don't have a base ref, we try to find the history to the default
|
@@ -80,12 +87,20 @@ runs:
|
80 | 87 | echo "::warning::Could not find commit range for commitlint"
|
81 | 88 | echo "::notice::Checking 20 most recent commit messages."
|
82 | 89 | fi
|
83 |
| - commitlint --config "${{ inputs.config-file }}" \ |
| 90 | + CONFIG_FILE="${{ inputs.config-file }}" |
| 91 | + if [[ -n "$CONFIG_FILE" ]]; then |
| 92 | + CONFIG_FILE="--config $CONFIG_FILE" |
| 93 | + fi |
| 94 | + echo "::notice::Running commitlint" |
| 95 | + commitlint \ |
| 96 | + $CONFIG_FILE \ |
84 | 97 | --verbose \
|
85 | 98 | --color \
|
86 | 99 | --from "$FROM" \
|
87 | 100 | --to HEAD
|
88 | 101 | - name: Restore commitlint config
|
89 |
| - if: always() && hashFiles(inputs.config-file) != '' && inputs.turo-conventional-commit |
| 102 | + if: always() && hashFiles(inputs.config-file) != '' && inputs.turo-conventional-commit == 'true' |
90 | 103 | shell: bash
|
91 |
| - run: git checkout -- "${{ inputs.config-file }}" || true |
| 104 | + run: | |
| 105 | + # Restore the commitlint config file if we wrote it |
| 106 | + git checkout -- "${{ inputs.config-file }}" &>/dev/null || true |
0 commit comments