#!/bin/bash -l
-# NB 12.03.19 echo DEBUG: pre-commit $* 1>&2
-# NB 12.03.19 [ -d www/dbq/ ] && (cd www/dbq/ && minify_dir) | while read -r f; do
-# NB 12.03.19 echo "Minify $f"
-# NB 12.03.19 git add "$f"
-# NB 12.03.19 done
-
echo "Run $0"
if which minify > /dev/null; then
MINIFY=""
[ -z "$MINIFY" ] && minify --help 2>&1 | grep -q '\-\-css ' && MINIFY="ext"
[ -z "$MINIFY" ] && minify --help 2>&1 | grep -q '\-\-output ' && MINIFY="out"
- [ -z "$MINIFY" ] || git status --porcelain|sed -E 's/^ *(\?\?|[A-Z]) +//' | while read file; do
+ [ -z "$MINIFY" ] || git diff --name-only | while read file; do
ext=""
case "$file" in
*.min.*) continue ;;
+++ /dev/null
-#!/bin/bash
-#################################################################################
-#
-# nb-repo-install
-#
-#################################################################################
-
-################################################################################
-#
-# Checks and globals
-#
-################################################################################
-
-# Ensure this script is run from the root of the repository
-REPO_ROOT="$(git rev-parse --show-toplevel)"
-[ -n "$REPO_ROOT" ] || exit
-cd "$REPO_ROOT" || exit
-
-CURRENT_USER="$(whoami)"
-FILE_USER="$(stat --format '%U' "$REPO_ROOT")"
-if [ "$CURRENT_USER" != "$FILE_USER" ]
-then
- echo "Wrong user: $CURRENT_USER != $FILE_USER repo=$REPO_ROOT"
- #exec sudo -u "$FILE_USER" "$0"
- #su "$FILE_USER" -c "$0"
- exit -1
-fi
-
-REPO_NAME="$(basename -s .git $(git remote get-url origin))"
-[ -n "$REPO_NAME" ] || exit
-
-################################################################################
-#
-# Functions
-#
-#################################################################################
-usage() {
-echo "
-=head1 NAME
-
-${NAME}
-
-=head1 SYNOPSIS
-
-Git pull repos
-
- -nop, --no-post Don't post stats infos
- -c, --cleanup Clean .git dir
- -v, --verbose Print verbose mode
- -d, --debug Print debug messages
- -h, --help Print this help (alternatives: --man, --help2man)
-"
-}
-
-#################################################################################
-#
-# Args
-#
-#################################################################################
-CLEANUP=0
-PULL=0
-DEBUG=0
-VERBOSE=0
-while [ $# -gt 0 ]; do
-
- case "$1" in
- --cleanup|-c) CLEANUP=1 ;;
- --pull|-pull) PULL=1 ;;
-
- -*help|-h) usage | pod2text --width 250; exit 0 ;;
- --man) usage | pod2man | man -l -; exit 0 ;;
- --help2man) usage | pod2man; exit 0 ;;
-
- --verbose|-v) VERBOSE=$(($VERBOSE+1)) ;;
-
- --debug|-d) DEBUG=$(($DEBUG+1)) ;;
-
- *) echo "Unknow option: $1 at $0!"; exit -1; ;;
-
- esac
- shift
-
-done
-
-#################################################################################
-#
-# Main
-#
-#################################################################################
-exec {F_INDENT1}> >(sed 's/^/ /')
-exec {F_INDENT2}> >(sed 's/^/ /')
-trap 'exec {F_INDENT1}>&-; exec {F_INDENT2}>&-;' EXIT
-
-if [ "$PULL" = "1" ]; then
-
-#V=1
-#echo ${V:-2}
-#(date;false) >&$F_INDENT2; exit
-
-#----------------------------------------------------------
-# Git pull
-#
-REPO_BRANCH=$(git branch --show-current) || exit
-[ -n "$REPO_BRANCH" ] || exit
-
-if [ -r ~/.ssh/agent.sh ]
-then
- . ~/.ssh/agent.sh || exit
-fi
-#git_conn_check || exit
-
-echo ">Pull $REPO_NAME branch=$REPO_BRANCH user=$(whoami) path=$REPO_ROOT"
-git pull >&$F_INDENT1 || exit
-if [ "$CLEANUP" = "1" ]
-then
- echo " >git gc cleanup"
- git gc >&$F_INDENT1 || exit
-fi
-#echo
-
-fi # PULL
-#----------------------------------------------------------
-# Git hooks
-#
-echo " >git-setup-hooks.sh"
-git-setup-hooks.sh >&$F_INDENT2 || exit
-
-#----------------------------------------------------------
-# *-install
-#
-if [ -x bin/$REPO_NAME-install ]
-then
- echo " >$REPO_NAME-install"
- bin/$REPO_NAME-install >&$F_INDENT2 || exit
-fi
-
-#----------------------------------------------------------
-# git status
-#
-echo " >git status"
-git status --short
--- /dev/null
+#!/bin/bash
+#################################################################################
+#
+# nb-repo-update
+#
+#################################################################################
+
+################################################################################
+#
+# Checks and globals
+#
+################################################################################
+
+# Ensure this script is run from the root of the repository
+REPO_ROOT="$(git rev-parse --show-toplevel)"
+[ -n "$REPO_ROOT" ] || exit
+cd "$REPO_ROOT" || exit
+
+CURRENT_USER="$(whoami)"
+FILE_USER="$(stat --format '%U' "$REPO_ROOT")"
+if [ "$CURRENT_USER" != "$FILE_USER" ]
+then
+ echo "Wrong user: $CURRENT_USER != $FILE_USER repo=$REPO_ROOT"
+ #exec sudo -u "$FILE_USER" "$0"
+ #su "$FILE_USER" -c "$0"
+ exit -1
+fi
+
+REPO_NAME="$(basename -s .git $(git remote get-url origin))"
+[ -n "$REPO_NAME" ] || exit
+
+################################################################################
+#
+# Functions
+#
+#################################################################################
+usage() {
+echo "
+=head1 NAME
+
+${NAME}
+
+=head1 SYNOPSIS
+
+Git pull repos
+
+ -nop, --no-post Don't post stats infos
+ -c, --cleanup Clean .git dir
+ -v, --verbose Print verbose mode
+ -d, --debug Print debug messages
+ -h, --help Print this help (alternatives: --man, --help2man)
+"
+}
+
+#################################################################################
+#
+# Args
+#
+#################################################################################
+CLEANUP=0
+PULL=0
+DEBUG=0
+VERBOSE=0
+while [ $# -gt 0 ]; do
+
+ case "$1" in
+ --cleanup|-c) CLEANUP=1 ;;
+ --pull|-pull) PULL=1 ;;
+
+ -*help|-h) usage | pod2text --width 250; exit 0 ;;
+ --man) usage | pod2man | man -l -; exit 0 ;;
+ --help2man) usage | pod2man; exit 0 ;;
+
+ --verbose|-v) VERBOSE=$(($VERBOSE+1)) ;;
+
+ --debug|-d) DEBUG=$(($DEBUG+1)) ;;
+
+ *) echo "Unknow option: $1 at $0!"; exit -1; ;;
+
+ esac
+ shift
+
+done
+
+#################################################################################
+#
+# Main
+#
+#################################################################################
+exec {F_INDENT1}> >(sed 's/^/ /')
+exec {F_INDENT2}> >(sed -e 's/\r/\n/g' -e 's/^ *//' -e 's/^/ /')
+trap 'exec {F_INDENT1}>&-; exec {F_INDENT2}>&-;' EXIT
+
+if [ "$PULL" = "1" ]; then
+
+#V=1
+#echo ${V:-2}
+#(date;false) >&$F_INDENT2; exit
+
+#----------------------------------------------------------
+# Git pull
+#
+REPO_BRANCH=$(git branch --show-current) || exit
+[ -n "$REPO_BRANCH" ] || exit
+
+if [ -r ~/.ssh/agent.sh ]
+then
+ . ~/.ssh/agent.sh || exit
+fi
+#git_conn_check || exit
+
+echo ">Pull $REPO_NAME branch=$REPO_BRANCH user=$(whoami) path=$REPO_ROOT"
+git pull >&$F_INDENT1 || exit
+if [ "$CLEANUP" = "1" ]
+then
+ echo " >git gc cleanup"
+ #export GIT_FLUSH=0
+ git gc >&$F_INDENT2 2>&1 || exit
+ #script --return --quiet --flush --log-out /dev/null --command 'git gc' >&$F_INDENT2 2>&1 || exit
+fi
+#echo
+
+fi # PULL
+#----------------------------------------------------------
+# Git hooks
+#
+echo " >git-setup-hooks.sh"
+git-setup-hooks.sh >&$F_INDENT2 || exit
+
+#----------------------------------------------------------
+# *-install
+#
+if [ -x bin/$REPO_NAME-install ]
+then
+ echo " >$REPO_NAME-install"
+ bin/$REPO_NAME-install >&$F_INDENT2 || exit
+fi
+
+#----------------------------------------------------------
+# git status
+#
+echo " >git status"
+git status --short
DEBUG=0
CLEANUP=0
POST_INFO=1
-PULL=0
+PULL=1
#################################################################################
#
# Args
opt="--pull"
[ "$CLEANUP" = "1" ] && opt="$opt --cleanup"
opt="${opt# *}"
- exec_user $user "nb-repo-install $opt" #>&$F_INDENT 2>&1
+ exec_user $user "nb-repo-update $opt" #>&$F_INDENT 2>&1
ex_repo=$?
[ "$ex_repo" = "0" ] || ex=$ex_repo
#echo $ex_repo