-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetpatch
88 lines (69 loc) · 1.82 KB
/
getpatch
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
84
85
86
87
88
#!/usr/bin/env bash
currentdir=$(pwd)
patchURL=https://raw.githubusercontent.com/silverwolfg11/PatchStrap/master/patch
repoLink=""
repoFolder=""
repoBranch=""
mergeTool=""
patchAuthor=""
if [ $# -gt 1 ]; then
# Argument Parsing
for i in "$@"
do
case $i in
-rl=*|--repo-link=*)
repoLink="${i#*=}"
shift # past argument=value
;;
-rf=*|--repo-folder=*)
repoFolder="${i#*=}"
shift # past argument=value
;;
-bn=*|--branch-name=*)
repoBranch="${i#*=}"
shift # past argument=value
;;
-mt=*|--merge-tool=*)
mergeTool="${i#*=}"
shift # past argument with no value
;;
-pa=*|--patch-author=*)
patchAuthor="${i#*=}"
# Add a space for the patch author
if [ ! -z "$patchAuthor" ]; then
patchAuthor="${patchAuthor/</ <}"
fi
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
else
read -p "Type the repo link: " repoLink
read -p "Type the repo folder: " repoFolder
read -p "Type the repo branch: " repoBranch
fi
if [ -f "patch" ]; then
echo "Removing current patch file!"
rm "patch"
fi
echo "Fetching latest patch file!"
curl $patchURL >> patch
echo "Filling in fields!"
sed -i '4d' "patch"
sed -i "4i repolink=\"$repoLink\"" "patch"
sed -i '6d' "patch"
sed -i "6i repofolder=\"$repoFolder\"" "patch"
sed -i '7d' "patch"
sed -i "7i patchAuthor=\"$patchAuthor\"" "patch"
if [ ! -z "$repoBranch" ]; then
sed -i '5d' "patch"
sed -i "5i branchName=\"$repoBranch\"" "patch"
fi
if [ ! -z "$mergeTool" ]; then
sed -i '8d' "patch"
sed -i "8i mergeTool=\"$mergeTool\"" "patch"
fi
./patch deletebootstrap