home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / cvs-1.8.7-src.tgz / tar.out / fsf / cvs / contrib / cvscheck.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1996-09-28  |  2KB  |  85 lines

  1. #! /bin/sh
  2. # $Id: cvscheck.sh,v 1.1 1995/07/10 02:26:29 kfogel Exp $
  3. #
  4. # cvscheck - identify files added, changed, or removed 
  5. #            in CVS working directory
  6. #
  7. # Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
  8. # This program should be run in a working directory that has been
  9. # checked out using CVS.  It identifies files that have been added,
  10. # changed, or removed in the working directory, but not "cvs
  11. # committed".  It also determines whether the files have been "cvs
  12. # added" or "cvs removed".  For directories, it is only practical to
  13. # determine whether they have been added.
  14.  
  15. name=cvscheck
  16. changes=0
  17.  
  18. # If we can't run CVS commands in this directory
  19. cvs status . > /dev/null 2>&1
  20. if [ $? != 0 ] ; then
  21.  
  22.     # Bail out
  23.     echo "$name: there is no version here; bailing out" 1>&2
  24.     exit 1
  25. fi
  26.  
  27. # Identify files added to working directory
  28. for file in .* * ; do
  29.  
  30.     # Skip '.' and '..'
  31.     if [ $file = '.' -o $file = '..' ] ; then
  32.     continue
  33.     fi
  34.  
  35.     # If a regular file
  36.     if [ -f $file ] ; then
  37.     if cvs status $file | grep -s '^From:[     ]*New file' ; then
  38.         echo "file added:      $file - not CVS committed"
  39.         changes=`expr $changes + 1`
  40.     elif cvs status $file | grep -s '^From:[     ]*no entry for' ; then
  41.         echo "file added:      $file - not CVS added, not CVS committed"
  42.         changes=`expr $changes + 1`
  43.     fi
  44.  
  45.     # Else if a directory
  46.     elif [ -d $file -a $file != CVS.adm ] ; then
  47.  
  48.     # Move into it
  49.     cd $file
  50.  
  51.     # If CVS commands don't work inside
  52.     cvs status . > /dev/null 2>&1
  53.     if [ $? != 0 ] ; then
  54.         echo "directory added: $file - not CVS added"
  55.         changes=`expr $changes + 1`
  56.     fi
  57.  
  58.     # Move back up
  59.     cd ..
  60.     fi
  61. done
  62.  
  63. # Identify changed files
  64. changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
  65. for file in $changedfiles ; do
  66.     echo "file changed:    $file - not CVS committed"
  67.     changes=`expr $changes + 1`
  68. done
  69.  
  70. # Identify files removed from working directory
  71. removedfiles=`cvs status | egrep '^File:[     ]*no file' | awk '{print $4}'`
  72.  
  73. # Determine whether each file has been cvs removed
  74. for file in $removedfiles ; do
  75.     if cvs status $file | grep -s '^From:[     ]*-' ; then
  76.     echo "file removed:    $file - not CVS committed"
  77.     else
  78.     echo "file removed:    $file - not CVS removed, not CVS committed"
  79.     fi
  80.     changes=`expr $changes + 1`
  81. done
  82.  
  83. exit $changes
  84.