Skip to content

Instantly share code, notes, and snippets.

@aiya000
Last active December 25, 2020 03:45
Show Gist options
  • Save aiya000/9aa5f5ee2ec43ef2de7b641ab7473c33 to your computer and use it in GitHub Desktop.
Save aiya000/9aa5f5ee2ec43ef2de7b641ab7473c33 to your computer and use it in GitHub Desktop.
#!/bin/bash
root_dir=$(git rev-parse --show-toplevel)
remote_latest_branch=$(bash -c "$root_dir/scripts/get-root-branch.sh")
current_branch=$(git branch --show-current)
unpushed_files=$(git diff --stat "$remote_latest_branch..$current_branch" --name-only)
# Example usage: textlint for markdown
unpushed_markdown_files=$(echo "$unpushed_files" | grep '\.md$')
if ! npx textlint --config "$root_dir/.textlintrc" "$unpushed_markdown_files" ; then
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment