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

Conversation

spacewander
Copy link
Collaborator

No description provided.


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.

@nicolaiskogheim
Copy link
Collaborator

I just edited the file, and I'll leave a patch here. These are just suggestions. You can take what you want from it, or just apply it onto the check_integrity branch if you agree with everything.

From bf4ddd8b57d4a2d664416f22080d69160d812ebc Mon Sep 17 00:00:00 2001
From: Nicolai Skogheim <[email protected]>
Date: Thu, 28 Jul 2016 20:33:30 +0200
Subject: [PATCH] Patches and suggestions

---
 check_integrity.sh | 49 +++++++++++++++++++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/check_integrity.sh b/check_integrity.sh
index 982c073..9bec46d 100755
--- a/check_integrity.sh
+++ b/check_integrity.sh
@@ -1,38 +1,51 @@
 #!/usr/bin/env bash

 err() {
-    echo "$1"
+    echo >&2 "$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'"
+
+    test -f "bin/$cmd" \
+        || err "bin/$cmd does not exist"
+
+    test -x "bin/$cmd" \
+        || err "run 'chmod +x bin/$cmd' to make it executable"
+
+    shebang=$(head -n1 "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"
+    test -f "man/$cmd.md" || err "create man/$cmd.md"
+
+    if [ ! -f "man/$cmd.1" ] || [ ! -f "man/$cmd.html" ]
+    then
+        err "Run 'make docs' to create man/$cmd.1 and man/$cmd.html"
+    fi
 }

 check_Commands_page() {
+    # These are special cases. All listed together, so we ignore them
     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"
+
+    grep "\- \[\`git $1\`\](#git-$1)" Commands.md >/dev/null \
+        || err "Add git-$1 in the list of commands in Commands.md"
+
+    grep "^## git $1" Commands.md >/dev/null \
+        || err "add description of git-$1 in Commands.md"
 }

 check_completion() {
     grep "$1:" etc/git-extras-completion.zsh > /dev/null || \
-        err "Update git-extras-completion.zsh with git-$1 is required"
+        err "Add git-$1 to the completion list at the end of etc/git-extras-completion.zsh"
 }

 check() {
@@ -42,9 +55,17 @@ check() {
     check_completion "$1"
 }

-test $# == 0 && err "Please give your command name"
+usage() {
+    echo >&2 "usage: ./check_integrity.sh <command-name> [<command-name2> ...]"
+    exit 0
+}
+
+test $# == 0 && usage
+
 for name in "$@"; do
     [[ "$name" == "rscp" || "$name" == "line-summary" ]] && continue
     check "$name"
 done
-echo 'All is done'
+
+echo 'All done'
+exit 0
-- 
2.9.2


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?

@spacewander
Copy link
Collaborator Author

@nicolaiskogheim
Just update my code. Could you review it again?

@nicolaiskogheim
Copy link
Collaborator

LGTM.

Great work @spacewander! Just merge when you're ready, and we'll add a note in Contributing.md about this script.

@spacewander spacewander merged commit 5bceec4 into tj:master Jul 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants