[GRASS-SVN] r38279 - grass-addons/tools

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 6 05:50:45 EDT 2009


Author: hamish
Date: 2009-07-06 05:50:45 -0400 (Mon, 06 Jul 2009)
New Revision: 38279

Added:
   grass-addons/tools/module_svn_propset.sh
Log:
helper script to set svn props automatically

Added: grass-addons/tools/module_svn_propset.sh
===================================================================
--- grass-addons/tools/module_svn_propset.sh	                        (rev 0)
+++ grass-addons/tools/module_svn_propset.sh	2009-07-06 09:50:45 UTC (rev 38279)
@@ -0,0 +1,149 @@
+#!/bin/sh
+############################################################################
+#
+# TOOL:         module_svn_propset.sh
+# AUTHOR:       Hamish Bowman, Dunedin, New Zealand
+# PURPOSE:      Looks at the files you pass it, tries to set svn props
+#		automatically for the ones it knows
+# COPYRIGHT:    (c) 2009 Hamish Bowman, and the GRASS Development Team
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+#############################################################################
+
+if [ $# -lt 1 ] ; then
+    echo "USAGE:  module_svn_propset.sh file1 [file2 file3 *.html]"
+    echo
+    exit 1
+fi
+
+if [ ! -x "`which svn`" ] ; then
+    echo "ERROR: Subversion not found, install it first" 1>&2
+    exit 1
+fi
+
+########
+
+# will only set if previously empty
+set_native_eol()
+{
+   if [ `svn proplist "$1" | grep -c 'svn:eol-style'` -eq 0 ] ; then
+      svn propset svn:eol-style "native" "$1"
+
+   fi
+}
+
+# will only set if previously empty
+set_mime_type()
+{
+   if [ `svn proplist "$1" | grep -c 'svn:mime-type'` -eq 0 ] ; then
+      svn propset svn:mime-type "$2" "$1"
+   fi
+}
+
+# will only set if previously empty
+set_exe()
+{
+   if [ `svn proplist "$1" | grep -c 'svn:executable'` -eq 0 ] ; then
+      svn propset svn:executable "ON" "$1"
+   fi
+}
+
+# will only set if previously empty
+set_keywords()
+{
+   if [ `svn proplist "$1" | grep -c 'svn:keywords'` -eq 0 ] ; then
+      svn propset svn:keywords "Author Date Id" "$1"
+   fi
+}
+
+
+########
+
+
+apply_html()
+{
+   set_keywords "$1"
+   set_mime_type "$1" text/html
+   set_native_eol "$1"
+}
+
+apply_makefile()
+{
+   set_mime_type "$1" text/x-makefile
+   set_native_eol "$1"
+}
+
+apply_shell_script()
+{
+   set_mime_type "$1" text/x-sh
+   set_native_eol "$1"
+   set_exe "$1"
+}
+
+apply_python_script()
+{
+   set_mime_type "$1" text/x-python
+   set_native_eol "$1"
+   #? set_exe "$1"
+}
+
+apply_C_code()
+{
+   set_mime_type "$1" text/x-csrc
+   set_native_eol "$1"
+}
+
+apply_Cpp_code()
+{
+   set_mime_type "$1" "text/x-c++src"
+   set_native_eol "$1"
+}
+
+apply_image()
+{
+   set_mime_type "$1" "image/$2"
+}
+
+
+########
+
+
+for FILE in $* ; do
+
+  if [ ! -e "$FILE" ] ; then
+     echo "ERROR: file not found <$FILE>"
+     continue
+  fi
+
+  FILE_UNKNOWN=0
+  FILE_SUFFIX=`echo "$FILE" | sed -e 's/^.*\.//'`
+  case "$FILE_SUFFIX" in
+    c)
+	apply_C_code "$FILE"
+	;;
+    py)
+	apply_python_script "$FILE"
+	
+	;;
+    html)
+	apply_html "$FILE"
+	;;
+    sh)
+	apply_shell_script "$FILE"
+	;;
+    png | jpeg | gif)
+	apply_image "$1" "$FILE_SUFFIX"
+	;;
+    *)
+	if [ "$FILE" = "Makefile" ] ; then
+	   apply_makefile "$FILE"
+	elif [ `file "$FILE" | grep -c "Bourne shell script"` -eq 1 ] ; then
+	   apply_shell_script "$FILE"
+	else
+	    echo "WARNING: unknown file type <$FILE>"
+	fi
+	;;
+  esac
+done


Property changes on: grass-addons/tools/module_svn_propset.sh
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/x-sh
Added: svn:eol-style
   + native



More information about the grass-commit mailing list