Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Commit folder changes to subversion
- .
- ├── autocommit.sh
- ├── dailysnapshot/
- └── workingcopy/
- #!/bin/bash
- SNAPSHOT=`cd $1;pwd`
- WORKINGDIR=`cd $2;pwd`
- USERNAME="$3"
- PASSWORD="$4"
- function CheckModifiedAndNew() {
- cd $1
- for f in $(find .)
- do
- if [ -a $f ]; then
- f=${f:2}
- if [[ -n $f ]]; then
- SnapshotFile="$1/$f"
- WorkingFile="$2/$f"
- if [[ -f $WorkingFile ]];then
- if cmp $SnapshotFile $WorkingFile &> /dev/null; then
- # 2 files are identical
- echo &> /dev/null "" #do nothing here
- else
- echo "[Modified] $WorkingFile"
- cp -f $SnapshotFile $WorkingFile
- fi
- else
- cp -f $SnapshotFile $WorkingFile
- echo "[Added] $WorkingFile"
- svn add $WorkingFile
- fi
- fi
- fi
- done
- }
- function CheckRemove() {
- cd $2
- for f in $(find .)
- do
- if [ -a $f ]; then
- f=${f:2}
- if [[ -n $f ]]; then
- SnapshotFile="$1/$f"
- WorkingFile="$2/$f"
- if [[ -f $SnapshotFile ]];then
- echo &> /dev/null "" #do nothing here
- else
- echo "[Removed] $WorkingFile"
- svn remove $WorkingFile
- fi
- fi
- fi
- done
- }
- function CommitAllChanges() {
- cd $1
- svn commit . --message="daily auto commit" --username=$USERNAME
- --password=$PASSWORD
- --non-interactive
- --no-auth-cache
- }
- CheckModifiedAndNew $SNAPSHOT $WORKINGDIR
- CheckRemove $SNAPSHOT $WORKINGDIR
- CommitAllChanges $WORKINGDIR
Add Comment
Please, Sign In to add comment