-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-publish
More file actions
executable file
·67 lines (59 loc) · 1.3 KB
/
git-publish
File metadata and controls
executable file
·67 lines (59 loc) · 1.3 KB
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
#!/usr/bin/env bash
set -eu
branch=$(git branch --show-current)
args=""
# Functions
function addArgument
{
args="$args $@"
}
function getMergeRequestDetails
{
if [ -z "$branch" ]
then
echo "[Error] You are currently not on a branch. Aborting..."
exit 1
fi
temp="--push-option merge_request.create"
if echo $branch | grep -q '^feature/'
then
name=${branch#feature/}
if echo $name | grep -q '^[[:digit:]]*$'
then
title="Merge request for #$name"
description="This MR will implement #$name."
else
title="Merge request for feature \"$name\""
description="This MR will implement feature \"$name\"."
fi
temp="$temp --push-option merge_request.title='$title'"
temp="$temp --push-option merge_request.description='$description'"
fi
echo $temp
}
# Begin script
while test $# -gt 0
do
value="$1"
case "$value" in
-c|--create)
addArgument $(getMergeRequestDetails)
;;
-d|--draft)
addArgument "--push-option merge_request.draft"
;;
-cd|-dc)
addArgument $(getMergeRequestDetails)
addArgument "--push-option merge_request.draft"
;;
-m|--merge-when-pipeline-succeeds)
addArgument "--push-option merge_request.merge_when_pipeline_succeeds"
;;
*)
addArgument "$value"
;;
esac
shift
done
command="git push --set-upstream origin $branch $args"
eval $command