Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check integrity script #557

Merged
merged 2 commits into from
Jul 30, 2016
Merged
Changes from 1 commit
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
50 changes: 50 additions & 0 deletions check_integrity.sh
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps change this to "either doesn't exist or is not executable".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reviewing the file now. I'll be posting a patch in a few minutes, and I'll address that.

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine it will take two days before someone posts an issue about ./check_integrity git-awzm-command not working. We could perhaps $cmd=${1#git-} or something.

}

test $# == 0 && err "Please give your command name"
for name in "$@"; do
[[ "$name" == "rscp" || "$name" == "line-summary" ]] && continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we echo out a message saying that we ignore these if someone tries to check them?

check "$name"
done
echo 'All is done'