Skip to content

Commit

Permalink
Add check integrity script
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander committed Jul 28, 2016
1 parent 0c8abf8 commit f60f127
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions check_integrity.sh
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

err() {
echo "$1"
exit 1
}

check_bash_script() {
local cmd="git-$1"
test -x "bin/$cmd" || err "bin/$cmd is either non-existent or unexecutable"
shebang=$(head -n 1 "bin/$cmd")
test "$shebang" == "#!/usr/bin/env bash" || \
err "start git-$1 with '#!/usr/bin/env bash'"
}

check_documentation() {
local cmd="git-$1"
test -f "man/$cmd.md" || err "man/$cmd.md required"
test -f "man/$cmd.1" || err "man/$cmd.1 required"
test -f "man/$cmd.html" || err "man/$cmd.html required"
}

check_Commands_page() {
local whitelist=('bug' 'chore' 'feature' 'refactor')
for cmd in ${whitelist[*]}; do
test "$1" == "$cmd" && return
done
grep "\- \[\`git $1\`\](#git-$1)" Commands.md > /dev/null && \
grep "^## git $1" Commands.md > /dev/null || \
err "Update Commands.md with git-$1 is required"
}

check_completion() {
grep "$1:" etc/git-extras-completion.zsh > /dev/null || \
err "Update git-extras-completion.zsh with git-$1 is required"
}

check() {
check_bash_script "$1"
check_documentation "$1"
check_Commands_page "$1"
check_completion "$1"
}

test $# == 0 && err "Please give your command name"
for name in "$@"; do
[[ "$name" == "rscp" || "$name" == "line-summary" ]] && continue
check "$name"
done
echo 'All is done'

0 comments on commit f60f127

Please sign in to comment.