[rtems-testing commit] Update to add initial support for git.

Joel Sherrill joel at rtems.org
Sat Jan 14 08:18:59 UTC 2012


Module:    rtems-testing
Branch:    master
Commit:    e6a5d7715e71d896ec389867f14829f3fb832429
Changeset: http://git.rtems.org/rtems-testing/commit/?id=e6a5d7715e71d896ec389867f14829f3fb832429

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Sat Jan 14 02:18:10 2012 -0600

Update to add initial support for git.

---

 ChangeLog                         |    5 ++
 README                            |    2 +-
 cvs-helpers/Makefile              |    4 +-
 cvs-helpers/{cvscommit => commit} |   90 +++++++++++++++++++++++---------
 cvs-helpers/mkChangeLogList       |  105 +++++++++++++++++++++++++------------
 5 files changed, 145 insertions(+), 61 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index afc1c1a..6ad82ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-14	Joel Sherrill <joel.sherrill at oarcorp.com>
+
+	* README, cvs-helpers/Makefile, cvs-helpers/mkChangeLogList,
+	cvs-helpers/mkChangeLogList: Update to add initial support for git.
+
 2011-08-21	Jie Liu <lj8175 at gmail.com>
 
 	* gcc/rtems_gcj_init.c: New file for rtems/gcj testing.
diff --git a/README b/README
index 0fbecd4..7c38109 100644
--- a/README
+++ b/README
@@ -4,7 +4,7 @@
 
 This package contains a collection of scripts and support files
 that support running the GCC (http://gcc.gnu.org) testsuite for
-C, C++, Ada.
+C, C++, Ada, FORTRAN, GCJ, Go, and Objective-C.
 
 This testing environment is used on the GCC Compile Farm as well
 as at OAR.
diff --git a/cvs-helpers/Makefile b/cvs-helpers/Makefile
index 318d782..6afcd0a 100644
--- a/cvs-helpers/Makefile
+++ b/cvs-helpers/Makefile
@@ -1,9 +1,9 @@
 #
-#  $Id$
+#  $Id: Makefile,v 1.3 2010/06/21 12:37:03 joel Exp $
 #
 
 INSTALL_DIR=../bin
-SCRIPTS=commit-with-changelog-diff cvscommit mkChangeLogList prepend mktest
+SCRIPTS=commit-with-changelog-diff commit mkChangeLogList prepend mktest
 
 all: prep ${SCRIPTS} install
 
diff --git a/cvs-helpers/cvscommit b/cvs-helpers/commit
similarity index 63%
rename from cvs-helpers/cvscommit
rename to cvs-helpers/commit
index 7c00fca..8d32ebc 100755
--- a/cvs-helpers/cvscommit
+++ b/cvs-helpers/commit
@@ -1,13 +1,11 @@
 #! /bin/sh
 #
-#   Do a cvs diff from the current directory and put the file names
-#   in suitable format for use in a ChangeLog.
+#  Recurse from current directory assisting in generating ChangeLog entries
+#  and committing files to the Source Code Repository.
 #
-#   TODO:  No outstanding isses.
+#   TODO:  
+#     + Currently supports CVS and git. Could add svn
 #
-#  $Id$
-#
-
 
 progname=${0##*/}
 usage()
@@ -27,8 +25,13 @@ usage()
   exit 1
 }
 
-if [ ! -d CVS ] ; then
-  echo There is no CVS directory in the current directory.
+# Determine VCS in use
+if [ -d .git ] ; then
+  VCS=git
+elif [ -d CVS ] ; then
+  VCS=cvs
+else
+  echo "This does not look like a checkout from a VCS I understand."
   exit 1
 fi
 
@@ -63,19 +66,33 @@ shift #shiftcount
 
 args=$*
 
-# done parsing arguments, now work 
-if [ "X${CVSROOT}" = "X" ] ; then
-  CVS=cvs
-else
-  CVS="cvs -d ${CVSROOT}"
-fi
-
-CVS="${CVS}"
-
+# find ChangeLogs and print them by depth
+get_subdirs()
+{
+  find . -name ChangeLog | while read f
+  do
+    case $1 in
+      */*/*/*/*/*/*/*/*/*) d=9 ;;
+      */*/*/*/*/*/*/*/*) d=8 ;;
+      */*/*/*/*/*/*/*) d=7 ;;
+      */*/*/*/*/*/*) d=6 ;;
+      */*/*/*/*/*) d=5 ;;
+      */*/*/*/*) d=4 ;;
+      */*/*/*) d=3 ;;
+      */*/*) d=2 ;;
+      */*) d=1 ;;
+      *) d=0 ;;
+    esac
+    echo ${d} ${f}
+  done | sort -n -r | cut -d' ' -f2- | while read f
+  do
+    dirname $f
+  done
+}
 if [ ${localdir} = "yes" ] ; then
   subdirs="."
 else
-  subdirs="* ."
+  subdirs=`get_subdirs`
 fi
 
 # Make sure we have user information
@@ -89,20 +106,43 @@ fi
 
 commit()
 {
-  ${CVS} up ChangeLog
-  if [ $? -eq 0 ] ; then
-    prepend ${changefile}
-    cvs commit -F ${changefile}
+  if [ $? -ne 0 ] ; then
+    return
   fi
+
+  prepend ${changefile}
+
+  # Specify VCS support directory
+  case ${VCS} in
+    cvs)
+      ${CVS} up ChangeLog
+      cvs commit -F ${changefile}
+      ;;
+    git)
+      echo "git commit -F ${changefile}"
+      git commit -a -F ${changefile}
+      ;;
+    *) echo "${VCS} to be implemented" ;  exit 1 ;;
+  esac
 }
 
+# Specify VCS support directory
+case ${VCS} in
+  cvs) VCSDIR=CVS ;;
+  git) VCSDIR=.git ;;
+  *)
+    echo "${VCS} to be implemented"
+    exit 1
+    ;;
+esac
+
 for ddir in ${subdirs} ; do
-  test "${ddir}" = "CVS" && continue
+  test "${ddir}" = "${VCSDIR}" && continue
   test "${ddir}" = "autom4te.cache" && continue
   test "${ddir}" = "install" && continue
   if [ -d "${ddir}" ]; then
-    if [ ! -d "${ddir}/CVS" ] ; then
-      echo "WARNING - ${ddir} is not in CVS"
+    if [ ! -d "${ddir}/${VCSDIR}" ] ; then
+      echo "WARNING - ${ddir} is not in .git"
       continue
     fi
     test -f "${ddir}/ChangeLog" || continue
diff --git a/cvs-helpers/mkChangeLogList b/cvs-helpers/mkChangeLogList
index 2344609..5d9fe9c 100755
--- a/cvs-helpers/mkChangeLogList
+++ b/cvs-helpers/mkChangeLogList
@@ -1,11 +1,11 @@
 #! /bin/sh
 #
-#   Do a cvs diff from the current directory and put the file names
+#   Use git from the current directory and put the file names
 #   in suitable format for use in a ChangeLog.
 #
-#   TODO:  No outstanding isses.
+#   TODO:  Initial conversion from cvs
 #
-#  $Id$
+#  $Id: mkChangeLogList,v 1.6 2011/01/04 19:53:53 joel Exp $
 #
 
 mklog_()
@@ -29,13 +29,13 @@ usage()
 
 print_name="no"
 user=$LOGNAME
-cvs_local_arg=""
+git_local_arg=""
 basedir=.
 while getopts d:lnM:m:p:c:u:U: OPT
 do
   case "$OPT" in 
     d) basedir=$OPTARG ;;
-    l) cvs_local_arg="-l" ;;
+    l) git_local_arg="-l" ;;
     n) print_name="yes" ;;
     p) prnum=$OPTARG ;;
     c) coverity_num=$OPTARG ;;
@@ -52,34 +52,50 @@ shift #shiftcount
 
 args=$*
 
-cvsarg="${cvs_local_arg} ${basedir}"
+dirarg="${basedir}"
 
-if [ -d .svn ] ; then
-  CVS=svn
+# Determine VCS in use
+if [ -d .git ] ; then
+  VCS=git
 elif [ -d CVS ] ; then
-  cmd=cvs
-  # done parsing arguments, now work 
-  if [ "X${CVSROOT}" = "X" ] ; then
-    CVS=${cmd}
-  else
-    CVS="${cmd} -d ${CVSROOT}"
-  fi
+  VCS=cvs
 else
-  echo "This does not look like a CVS or SVN checkout."
+  echo "This does not look like a checkout from a VCS I understand."
   exit 1
 fi
 
-CVS="${CVS}"
-
 if [ ! -r ChangeLog ] ; then
   ( echo "There is no ChangeLog in this directory." ;
     echo "Where are you putting the entry?" )>/dev/stderr
   exit 1
 fi
 
-files_modded=`${CVS} diff ${cvsarg} 2>&1 | grep ^Index | wc -l`
-files_added=`${CVS} diff ${cvsarg} 2>&1 | grep "is a new entry, no " | wc -l`
-files_deleted=`${CVS} diff ${cvsarg} 2>&1 | grep " was removed, no " | wc -l`
+case ${VCS} in
+  cvs)
+    # done parsing arguments, now work 
+    if [ "X${CVSROOT}" = "X" ] ; then
+      CVS=cvs
+    else
+      CVS="cvs -d ${CVSROOT}"
+    fi
+    CVS="${CVS}"
+
+    files_modded=`${CVS} diff ${dirarg} 2>&1 | grep ^Index | wc -l`
+    files_added=`${CVS} diff ${dirarg} 2>&1 | grep "is a new entry, no " | wc -l`
+    files_deleted=`${CVS} diff ${dirarg} 2>&1 | grep " was removed, no " | wc -l`
+    ;;
+  git)
+    files_modded=`git status ${dirarg} 2>&1 | grep "modified: " | wc -l`
+    files_added=`git status ${dirarg} 2>&1 | grep "new file: " | wc -l`
+    files_deleted=0
+    #files_deleted=`${CVS} diff ${dirarg} 2>&1 | grep " was removed, no " | wc -l`
+    ;;
+  *)
+    echo "${VCS} to be implemented"
+    exit 1
+    ;;
+esac
+
 files_changed=`expr ${files_modded} + ${files_added} + ${files_deleted}`
 if test ${files_changed} -eq 0 ; then
   exit 0
@@ -111,19 +127,42 @@ if test "X${coverity_num}" != "X" ; then
   echo "	Coverity Id ${coverity_num}"
 fi
 
-# Generate list of modified files
-${CVS} diff ${cvsarg} 2>/dev/null | grep ^Index | mklog_ ${message}
-
-# Generate list of deleted files
-test ${files_added} -gt 1 && plural=s
-${CVS} diff ${cvsarg} 2>&1 | grep "is a new entry, no comparison" | \
-  sed -e 's/^.*: //' -e 's/ is a .*$//' | mklog_ "New file${plural}."
+case ${VCS} in
+  cvs)
+    # Generate list of modified files
+    ${CVS} diff ${dirarg} 2>/dev/null | grep ^Index | mklog_ ${message}
+
+    # Generate list of deleted files
+    test ${files_added} -gt 1 && plural=s
+    ${CVS} diff ${dirarg} 2>&1 | grep "is a new entry, no comparison" | \
+      sed -e 's/^.*: //' -e 's/ is a .*$//' | mklog_ "New file${plural}."
+
+    # Generate list of removed files
+    ${CVS} diff ${dirarg} 2>&1 | grep "was removed, no comparison" | \
+      sed -e 's/^.*: //' -e 's/ was removed, no comparison.*$//' | \
+      mklog_ Removed.
+    ;;
+  git)
+    # Generate list of modified files
+    git status 2>&1 | grep "modified: " | mklog_ ${message}
+
+    # Generate list of deleted files
+    test ${files_added} -gt 1 && plural=s
+    git status 2>&1 | grep "new file: " | \
+      sed -e 's/^.*: //' -e 's/ is a .*$//' | mklog_ "New file${plural}."
+
+    # Generate list of removed files
+    #${CVS} diff ${dirarg} 2>&1 | grep "was removed, no comparison" | \
+    #  sed -e 's/^.*: //' -e 's/ was removed, no comparison.*$//' | \
+    #  mklog_ Removed.
+    ;;
+  *)
+    echo "${VCS} to be implemented"
+    exit 1
+    ;;
+esac
 
-# Generate list of removed files
-${CVS} diff ${cvsarg} 2>&1 | grep "was removed, no comparison" | \
-  sed -e 's/^.*: //' -e 's/ was removed, no comparison.*$//' | \
-  mklog_ Removed.
 echo
 
-rm -f XXX
+# rm -f XXX
 exit 0




More information about the vc mailing list