-
Notifications
You must be signed in to change notification settings - Fork 23
/
merge_request.sh
executable file
·59 lines (37 loc) · 1.24 KB
/
merge_request.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
sh cleanBranch.sh
git merge master
PROJECT_NAME=${PWD##*/}
ORIGIN_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ ! $(which gitlab) ]]; then
sudo npm install -g gitlab
fi
JSON_RESULT=$(gitlab projects --filter "item.path=='$PROJECT_NAME'")
echo "var ret = $JSON_RESULT; console.log(ret[0].id);" > "p.js"
PROJECT_ID=$(node p.js)
rm "p.js"
URL=$(gitlab url)
if [ ${#URL} -le 0 ]
then
echo "请安装cli-gitlab,并填写gitlab地址"
exit 1
fi
TOKEN=$(gitlab token)
if [ ${#TOKEN} -le 0 ]
then
echo "请填写gitlab token"
exit 1
fi
echo "请输入merge信息"
read TITLE
TARGET_BRANCH='master'
echo "target branch is '$TARGET_BRANCH'"
CURRENT_POD_VERSION=$(cat $PROJECT_NAME.podspec | grep 's.version' | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
BRANCH="FeatureNewVersion@$CURRENT_POD_VERSION"
echo $BRANCH
git checkout -b $BRANCH
git push --set-upstream origin $BRANCH
# MERGE_REQUEST_URL=${URL}"/api/v3/projects/$PROJECT_ID/merge_requests"
# MERGE_REQUEST_PARAM="-F id=$PROJECT_ID -F source_branch=$BRANCH -F target_branch=$TARGET_BRANCH -F assignee_id=9 -F title=$TITLE"
# curl -X POST -H "PRIVATE-TOKEN: ${TOKEN}" $MERGE_REQUEST_PARAM $MERGE_REQUEST_URL
gitlab addMergeRequest $PROJECT_ID $BRANCH $TARGET_BRANCH 9 $TITLE
git checkout $ORIGIN_BRANCH