-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin-deploy.sh
More file actions
54 lines (40 loc) · 1.18 KB
/
plugin-deploy.sh
File metadata and controls
54 lines (40 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/Desktop/my-plugins/svn/$DIR_NAME/$BRANCH
SVN_USERNAME=svn_username_here #your WordPress.org svn user
# make sure we're deploying from the right dir
if [ ! -d "$SRC_DIR/.git" ]; then
echo "$SRC_DIR doesn't seem to be a git repository"
exit
fi
# make sure the destination dir exists
svn mkdir $DEST_DIR 2> /dev/null
svn add $DEST_DIR 2> /dev/null
# delete everything except .svn dirs
for file in $(find $DEST_DIR/* -not -path "*.svn*")
do
rm $file 2>/dev/null
done
# copy everything over from git, except hidden files (except .htaccess)
rsync -r --exclude='*.git*' --include='*.htaccess*' $SRC_DIR/ $DEST_DIR
cd $DEST_DIR
# check .svnignore
for file in $(cat "$SRC_DIR/.svnignore" 2>/dev/null)
do
rm $file -rf
done
# check .distignore
for file in $(cat "$SRC_DIR/.distignore" 2>/dev/null)
do
rm -rf $file
done
# svn addremove
svn stat | grep '^\?' | awk '{print $2}' | xargs svn add > /dev/null 2>&1
svn stat | grep '^\!' | awk '{print $2}' | xargs svn rm > /dev/null 2>&1
svn stat
svn ci -m "$MSG" --username $SVN_USERNAME