]> git.nbdom.net Git - nb.git/commitdiff
nb-update PULL=1
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 10 Oct 2024 08:06:18 +0000 (10:06 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 10 Oct 2024 08:06:18 +0000 (10:06 +0200)
.githooks/pre-commit
bin/nb-repo-install [deleted file]
bin/nb-repo-update [new file with mode: 0755]
bin/nb-update

index 2831fc94a74ba7cd1635bb14f06032659aac2d06..dd52460bb4e27b8a530e34ab8f6bb8cb9cb10e97 100755 (executable)
@@ -1,18 +1,12 @@
 #!/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 ;;
diff --git a/bin/nb-repo-install b/bin/nb-repo-install
deleted file mode 100755 (executable)
index ddfb918..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/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
diff --git a/bin/nb-repo-update b/bin/nb-repo-update
new file mode 100755 (executable)
index 0000000..669bb28
--- /dev/null
@@ -0,0 +1,143 @@
+#!/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
index 3ffc0f6940b1f9da9370b170935cb65b32cc6fe2..3d4809ed6e5d4a7149e4747ae12db592fe68d899 100755 (executable)
@@ -37,7 +37,7 @@ Git pull repos
 DEBUG=0
 CLEANUP=0
 POST_INFO=1
-PULL=0
+PULL=1
 #################################################################################
 #
 # Args
@@ -182,7 +182,7 @@ then
        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