SHARE
TWEET

Untitled

a guest Sep 3rd, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Commit folder changes to subversion
  2. .
  3. ├── autocommit.sh
  4. ├── dailysnapshot/
  5. └── workingcopy/
  6.    
  7. #!/bin/bash
  8. SNAPSHOT=`cd $1;pwd`
  9. WORKINGDIR=`cd $2;pwd`
  10. USERNAME="$3"
  11. PASSWORD="$4"
  12.  
  13. function CheckModifiedAndNew() {    
  14.     cd $1
  15.     for f in $(find .)
  16.     do
  17.     if [ -a $f ]; then
  18.     f=${f:2}
  19.         if [[ -n $f ]]; then
  20.             SnapshotFile="$1/$f"
  21.             WorkingFile="$2/$f"        
  22.             if [[ -f $WorkingFile ]];then
  23.                 if cmp $SnapshotFile $WorkingFile &> /dev/null; then
  24.                     # 2 files are identical
  25.                     echo &> /dev/null "" #do nothing here
  26.                 else
  27.                     echo "[Modified]  $WorkingFile"
  28.                     cp -f $SnapshotFile $WorkingFile
  29.                 fi
  30.             else
  31.                 cp -f $SnapshotFile $WorkingFile
  32.                 echo "[Added]     $WorkingFile"
  33.                 svn add $WorkingFile
  34.             fi
  35.         fi
  36.     fi
  37.     done
  38. }
  39.  
  40. function CheckRemove() {
  41.     cd $2
  42.     for f in $(find .)
  43.     do
  44.     if [ -a $f ]; then
  45.         f=${f:2}
  46.         if [[ -n $f ]]; then
  47.             SnapshotFile="$1/$f"
  48.             WorkingFile="$2/$f"      
  49.             if [[ -f $SnapshotFile ]];then
  50.                 echo &> /dev/null "" #do nothing here
  51.             else
  52.                 echo "[Removed]   $WorkingFile"
  53.                 svn remove $WorkingFile
  54.             fi
  55.         fi
  56.     fi
  57.     done
  58. }
  59.  
  60. function CommitAllChanges() {
  61.     cd $1
  62.     svn commit . --message="daily auto commit" --username=$USERNAME
  63.                                                --password=$PASSWORD
  64.                                                --non-interactive
  65.                                                --no-auth-cache                                              
  66. }
  67.  
  68. CheckModifiedAndNew $SNAPSHOT $WORKINGDIR
  69.  
  70. CheckRemove $SNAPSHOT $WORKINGDIR
  71.  
  72. CommitAllChanges $WORKINGDIR
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top