From c54ff1611e94a8a5285bc0fee04b60617ee350e2 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Tue, 24 Mar 2015 20:09:31 +1100 Subject: [PATCH 1/3] Update INSTALL Fixes /hybridgroup/GitHub-Wikifier/issues/25 --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index cb3bbe0..06b651b 100644 --- a/INSTALL +++ b/INSTALL @@ -1,2 +1,2 @@ -curl https://raw.github.com/hybridgroup/GitHub-Wikifier/master/pre-commit > .git/hooks/pre-commit; +curl https://raw.githubusercontent.com/hybridgroup/GitHub-Wikifier/master/pre-commit > .git/hooks/pre-commit; chmod +x .git/hooks/pre-commit; From e4a8183e820b7fdc5fe01c03223c281a701a3bd4 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Wed, 25 Mar 2015 04:28:54 +1100 Subject: [PATCH 2/3] Fixes #27 Subject in header in _sidebar.md and Home.md should not have .md at the end --- pre-commit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pre-commit b/pre-commit index 895d3cf..97483c1 100755 --- a/pre-commit +++ b/pre-commit @@ -116,8 +116,8 @@ function wikify() { # Directory write if [[ "$depth" -eq "0" ]]; then - echo "$(subject_to_header $@.md)" >> "$subjects/Home.md" - echo "$(subject_to_header $@.md)\n---" > "$@/_sidebar.md" + echo "$(subject_to_header $@)" >> "$subjects/Home.md" + echo "$(subject_to_header $@)\n---" > "$@/_sidebar.md" echo "$@.md" >> /tmp/wikify.txt echo "$@/_sidebar.md" >> /tmp/wikify.txt fi From bc88afa10c25401b2f1fc9518e78f02113937f6c Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sat, 11 Apr 2015 15:48:27 +1000 Subject: [PATCH 3/3] Fixes #30 It also has some logging for filtering files --- pre-commit | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/pre-commit b/pre-commit index 895d3cf..d77a3dd 100755 --- a/pre-commit +++ b/pre-commit @@ -13,13 +13,44 @@ function wikify() { fi } + # to enable log, run + # git config wikify.log true + # + # result: + # [INFO] some info blah blah + # + # to remove logging, + # git config --unset wikify.log + function log_info() { + local should_log=$(git config --get wikify.log) + if [[ -n "$should_log" && "$should_log" = "true" ]]; then + if [[ -n "$2" ]]; then + local log_level="$(echo "$1" | tr 'a-z' 'A-Z')" + local log_message="$2" + echo "[$log_level] $log_message" + else + echo "[INFO] $@" + fi + fi + } + # Filter some files and directories. function continue_if_filtered() { - if [[ "$@" =~ "images$" ]]; then + # $1 filename + # $2 directory + + if [[ "$1" =~ "images$" ]]; then + log_info "$1: images so ignored." + continue + elif [[ ( -n "$2" && $(file "$2/$1" | grep ".*: .* image.*," | sed "s;.*: .*\(image\)[^,]*, .*;\1;") == "image" ) || ( $(file "$1" | grep ".*: .* image.*," | sed "s;.*: .*\(image\)[^,]*, .*;\1;") == "image" ) ]]; then + # check file type and ignore it if it's image + log_info "$1: image so ignored." continue - elif [[ "$@" =~ "(_sidebar|_footer|_header)" ]]; then + elif [[ "$1" =~ "(_sidebar|_footer|_header)" ]]; then + log_info "$1 in (_sidebar|_footer|_header) so ignored." continue - elif [[ "$@" == "." ]]; then + elif [[ "$1" == "." ]]; then + log_info "$1: ignored" continue fi } @@ -123,7 +154,7 @@ function wikify() { fi for file in $(gls_or_ls -l -v $@ | awk '{ print $9 }'); do; - continue_if_filtered $file + continue_if_filtered $file $@ file="$@/$file" if [[ "$(file -ib $file)" =~ "directory" ]]; then