forked from anton-johansson/useful-bash-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy-to-dbupdate
executable file
·63 lines (52 loc) · 1.26 KB
/
copy-to-dbupdate
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
55
56
57
58
59
60
61
62
#!/bin/bash
#
# Script that is used to copy an SQL file to the DBUpdate repository.
#
# Variables
file="$(realpath $1)"
dev=false
stable=false
# Error checks
if [[ ! -f $file ]]; then
echo "Not a file..."
exit 1
fi
if [[ ! "$file" =~ \.sql$ ]]; then
echo "Not an SQL file..."
exit 1
fi
# Full dbupdate checkout out or partial?
if [[ -d $HOME/Projects/DBUpdate/Main ]]; then
fullcheckout=/Main/Repository
fi
# Check which branch(es) to push to
if [[ $file == *"/Dev/"* ]] || [[ $file == *"/Main/"* ]]; then
dev=true
elif [[ $file == *"/Stable/"* ]] || [[ $file == *"/Releases/2.6/2.6.x/"* ]]; then
stable=true
elif [[ $file == *"/Viskan/Kod/"* ]]; then
dev=true
stable=true
else
echo "Not a proper ETM code tree..."
exit 1
fi
type=StoredProcedures
parent=`dirname $file`
parent=`basename $parent`
shopt -s nocasematch
if [[ "$parent" =~ "tables" ]]; then
type=Structure
fi
if [[ "$parent" =~ "(reports|develop)" ]]; then
type=Scripts
fi
# Copy the file to ETM Development
if $dev; then
cp $file "$HOME/Projects/DBUpdate$fullcheckout/Ramos Main/$type/$(basename $file)"
fi
# Copy the file to ETM Stable
if $stable; then
cp $file "$HOME/Projects/DBUpdate$fullcheckout/Ramos 2.6/$type/$(basename $file)"
fi
svn status $HOME/Projects/DBUpdate$fullcheckout