Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ jobs:
git fetch origin "${{ github.base_ref }}" --depth=1
files=$(git diff --name-only "origin/${{ github.base_ref }}..HEAD" -- '*.md')
elif [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]]; then
files=$(git diff-tree --no-commit-id --name-only -r "${{ github.sha }}" -- '*.md')
# A new branch has no "before" commit, and a force-push leaves an unreachable one.
# Lint everything the branch changes since it left main, not just the tip commit.
# main itself has no base to compare against, so lint every tracked file there.
if ! git cat-file -e "${{ github.event.before }}^{commit}" 2>/dev/null; then
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
files=$(git ls-files '*.md')
else
files=$(git diff --name-only "origin/main...${{ github.sha }}" -- '*.md')
fi
else
files=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- '*.md')
fi
Expand Down
Loading