-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathport-changeset.sh
executable file
·86 lines (66 loc) · 1.83 KB
/
port-changeset.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
84
85
86
#!/bin/bash
# name of GitHub commiter
GIT_USER=jbutkus
# remote name, of commiter forked repo
GIT_ORIGIN=origin
# remote name, of master repository
GIT_MASTER=thenly
# name of target repo, on master repo
GIT_PRONAME=all-in-one-event-calendar-pro
# path to repo, to create patch from
PRM_PATH=/var/www/wordpress/wp-content/plugins/all-in-one-event-calendar-premium
# path to repo, to apply patch to
PRO_PATH=/var/www/wordpress_clean/wp-content/plugins/all-in-one-event-calendar-pro
if [[ o"$1" == "o" ]]
then
echo -e "Usage:\n $_ AIOEC-101"
exit 1
fi
feature=$1
cd $PRO_PATH
git checkout develop >/dev/null
git branch | grep "feature/$feature" >/dev/null
if [[ $? -eq 0 ]]
then
git checkout "feature/$feature"
else
git flow feature start "$feature"
if [[ $? -ne 0 ]]
then
echo "Failed to initiate feature branch $feature. Aborting."
exit 2
fi
fi
( cd $PRM_PATH; git diff develop...feature/$feature | perl -pe 's|[ \t]*$||g' ) \
| git apply --exclude .gitignore -
if [[ $? -ne 0 ]]
then
echo "Merge failed. Aborting."
exit 3
fi
files_changed=$( cd $PRM_PATH; git diff --name-only develop...feature/$feature )
for file in $files_changed
do
git add "$file"
done
echo -n "Enter commit/pull message: "
read pullmsg
pullmsg="${pullmsg//\"/\\\"}"
pullmsg="${pullmsg//\'/\\\'}"
pullmsg="feature/$feature\n$pullmsg"
git commit --message="$pullmsg"
if [[ $? -ne 0 ]]
then
echo "Failed to commit result. Aborting."
exit 4
fi
git push -u "$GIT_ORIGIN" "feature/$feature"
if [[ $? -ne 0 ]]
then
echo "Failed to push changeset to origin ($GIT_ORIGIN). Aborting."
exit 4
fi
curl "https://api.github.com/repos/$GIT_MASTER/$GIT_PRONAME/pulls" \
-u $GIT_USER \
-d "{\"title\": \"feature/$feature\", \"body\": \"$pullmsg\", \"head\": \"$GIT_USER:feature/$feature\", \"base\": \"develop\" }"
exit 0