Ajout commande vlog et coloration de vs.
authorgobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Sun, 19 Aug 2012 01:10:45 +0000 (01:10 +0000)
committergobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Sun, 19 Aug 2012 01:10:45 +0000 (01:10 +0000)
stage2/hv-utilities/vlog [new file with mode: 0755]
stage2/hv-utilities/vs

diff --git a/stage2/hv-utilities/vlog b/stage2/hv-utilities/vlog
new file mode 100755 (executable)
index 0000000..8e22a64
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+print_usage()
+{
+    echo "$(basename $0) -- log for version control (svn or git)."
+    echo "Usage: $(basename $0) [OPTIONS...]"
+}
+
+if [ "x${1}" = "x--help" ]; then
+    print_usage
+    exit 1
+fi
+
+SVN_LOG_REV_INFO_COLOR=$(echo -e '\033[1;31m')  # Red
+SVN_LOG_SEPARATION_COLOR=$(echo -e '\033[1;32m')    # Green
+NORMAL=$(echo -e '\033[0m')
+
+if git diff 1> /dev/null 2>&1; then
+    git log "$@"
+elif svn diff 1> /dev/null 2>&1; then
+    # Colore les lignes --------- en vert
+    # Colore en rouge les infos de la rĂ©vision
+    svn log "$@" | sed -e "s/^-\+$/${SVN_LOG_SEPARATION_COLOR}\0${NORMAL}/" \
+        -e "s/^r[0-9]\+.\+$/${SVN_LOG_REV_INFO_COLOR}\0${NORMAL}/" | less -RFX
+else
+    echo "Not a GIT or Subversion repository"
+    exit 1
+fi
index e3eafe4..b5312b1 100755 (executable)
@@ -11,10 +11,22 @@ if [ "x${1}" = "x--help" ]; then
     exit 1
 fi
 
+SVN_ST_UNKNOWN_COLOR=$(echo -e '\033[1;34m')  # Blue
+SVN_ST_DELETED_COLOR=$(echo -e '\033[0;31m')  # Red
+SVN_ST_MISSING_COLOR=$(echo -e '\033[1;31m')  # Red
+SVN_ST_ADDED_COLOR=$(echo -e '\033[1;32m')    # Green
+SVN_ST_MODIFIED_COLOR=$(echo -e '\033[1;33m') # Yellow
+NORMAL=$(echo -e '\033[0m')
+
 if git diff 1> /dev/null 2>&1; then
     git status "$@"
 elif svn diff 1> /dev/null 2>&1; then
-    svn status "$@"
+    svn status --ignore-externals "$@" | grep -v "^X" | \
+        sed -e "s/^\?.*$/${SVN_ST_UNKNOWN_COLOR}\0${NORMAL}/" \
+        -e "s/^!.*$/${SVN_ST_MISSING_COLOR}\0${NORMAL}/" \
+        -e "s/^A.*$/${SVN_ST_ADDED_COLOR}\0${NORMAL}/" \
+        -e "s/^M.*$/${SVN_ST_MODIFIED_COLOR}\0${NORMAL}/" \
+        -e "s/^D.*$/${SVN_ST_DELETED_COLOR}\0${NORMAL}/"
 else
     echo "Not a GIT or Subversion repository"
     exit 1