-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync_upm.sh
executable file
·83 lines (70 loc) · 981 Bytes
/
sync_upm.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
# Constants
UPM_ROOT="Assets"
IGNORES=""
THIS_SCRIPT=`basename $0`
TARGET_DIR="Runtime"
BRANCH_NAME="upm"
create_tag()
{
local tags=$(git tag)
for t in $tags
do
echo $t
local n="${t##*.}"
echo $n
echo `expr $n + 1`
done
}
create_branch()
{
local branch=$(git branch | grep $1)
if [[ $branch == $1 ]]
then
git branch -D $1
fi
git subtree split --prefix=$UPM_ROOT --branch $1
git checkout $1
}
should_move()
{
if [[ `basename $1` == $THIS_SCRIPT ]]
then
return 0
fi
if [[ `basename $1` == $TARGET_DIR ]]
then
return 0
fi
if [[ -d $1 ]]
then
return 1
else
return 1
fi
}
reorganize_files()
{
if [ -e $TARGET_DIR ]
then
rm -r $TARGET_DIR
fi
mkdir $TARGET_DIR
for f in ./*
do
should_move $f
if [ $? -ne 0 ]
then
mv $f $TARGET_DIR
fi
done
}
main()
{
create_branch $BRANCH_NAME
# reorganize_files
create_tag
}
main
echo Press any key to continue
read -n 1