Skip to content

Commit

Permalink
Add index-to-README
Browse files Browse the repository at this point in the history
  • Loading branch information
RadxaYuntian committed Nov 24, 2023
1 parent b09b0cd commit 2599048
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@
entry: pre_commit_hooks/main.sh disable-sidebar_label
language: script
types: [markdown]
- id: index-to-README
name: Rename index.md to README.md
entry: pre_commit_hooks/main.sh index-to-README
language: script
types: [markdown]
18 changes: 18 additions & 0 deletions pre_commit_hooks/index-to-README.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

check() {
local ret=0

# README.md is the preferred naming to have better integration with GitHub
if [[ "$(basename "$1")" == "index.md" ]]
then
echo "$1: index.md should be named to README.md." >&2
ret=1
if ! $DRY_RUN
then
mv "$1" "$(dirname "$1")/README.md"
fi
fi

return $ret
}

0 comments on commit 2599048

Please sign in to comment.