Skip to content

Commit 1d17d32

Browse files
committed
Merge branch 'feature/merge-request-labels'
accepting mr labels with --label
2 parents dcbc310 + 451e822 commit 1d17d32

File tree

12 files changed

+115
-34
lines changed

12 files changed

+115
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ gclit-sync
3232

3333
* Make more changes...
3434

35-
* Deliver the fature (commits pending changes, creates merge request if project url is from gitlab, syncs with target branch [e.g.: master], pushes changes, merges changes back to target branch if project url is from github, delivers runrun task):
35+
* Deliver the feature (commits pending changes, creates merge request if project url is from gitlab, syncs with target branch [e.g.: master], pushes changes, merges changes back to target branch if project url is from github, delivers runrun task):
3636
```
3737
gclit-deliver
3838
```

db.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ function db() {
2727
fi
2828
}
2929

30+
function db_dump() {
31+
cat $LOCAL_DB
32+
}
33+
3034
if [[ -n "$1" && $(MYNAME) == $CALLER ]]; then
3135
if [[ "$1" == -r ]]; then
3236
less $LOCAL_DB

deliver.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,25 @@ if [[ ! -n "$name" ]]; then
2929
exit 1
3030
fi
3131

32+
if [[ "$PWD" != $(db CURR_FEATURE_DIR) ]]; then
33+
err "feature '$name' was started on another repo:"
34+
db CURR_FEATURE_DIR
35+
exit 1
36+
fi
37+
3238
git checkout $name
3339

34-
info "${name}'s conclusion message:"
35-
if [[ -n "$message" ]]; then
36-
echo "$message"
37-
else
40+
while [[ ! -n "$message" ]]; do
41+
info "${name}'s conclusion message:"
3842
read message
39-
fi
43+
done
44+
debug "delivery message: '$message'"
4045

4146
echo "$(date)" > v
4247

4348
$MYDIR/commit.sh "$message"
4449
if [[ $mr == true && $(project_url) == *gitlab* ]]; then
45-
$MYDIR/merge-request.sh "$message" false
50+
$MYDIR/merge-request.sh "$@"
4651
fi
4752
$MYDIR/sync.sh
4853
$MYDIR/push.sh "$message"

feature.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ if [[ ! -n "$(curr_branch)" ]]; then
2020
fi
2121

2222
if [[ "$1" != '-'* ]]; then
23+
# name was passed directlty as first arg with no prefix
2324
name="$1"; shift
2425
fi
2526

2627
project_id="$(db CURR_PROJECT_ID)"
28+
label=gclit
2729

2830
while test $# -gt 0
2931
do
@@ -38,6 +40,10 @@ do
3840

3941
project_id=$(prompt_project_id "$name_or_id")
4042
;;
43+
--label)
44+
shift
45+
label="$1"
46+
;;
4147
-*)
4248
echo "bad option '$1'"
4349
exit 1
@@ -61,7 +67,9 @@ if [[ ! -n "$project_name" ]]; then
6167
exit 1
6268
fi
6369

64-
info "will start '$name' on project '$project_name', proceed?"
70+
info "will start '$name' on project '$project_name'"
71+
info "project URL: $(project_url)"
72+
echo "<enter> to proceed, CTRL+C to abort"
6573
read anyKey
6674

6775
if [[ "$(curr_branch)" != "$name" ]]; then

jprop.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
3-
cat /dev/stdin | python -c "import sys, json; print json.load(sys.stdin)$1"
2+
export PYTHONIOENCODING=utf-8
3+
cat /dev/stdin | python -c "import sys, json; print json.load(sys.stdin)$1"

log.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function log() {
4747
fi
4848

4949
if [[ $level == DEBUG && $(debugging) == on || $level != DEBUG ]]; then
50-
echo "$indicator $(now.sh -dt) - ${FUNCNAME[2]}@${BASH_LINENO[1]}/$level: $@"
50+
echo "$indicator $(now.sh -t) - ${FUNCNAME[2]}@${BASH_LINENO[1]}/$level: $@"
5151
fi
5252
echo "$MYSELF - $indicator $(now.sh -dt) - ${FUNCNAME[2]}@${BASH_LINENO[1]}/$level: $@" >> $logf
5353
}

merge-request.sh

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,39 @@ source $MYDIR/env
99
source $MYDIR/log.sh
1010
source $MYDIR/db.sh
1111

12-
message="$1"
13-
wip="${2:-true}"
14-
detail="${3:-auto generated by gclit}"
12+
wip=false
13+
description="auto generated by gclit"
14+
15+
if [[ "$1" != '-'* ]]; then
16+
# message was passed directlty as first arg with no prefix
17+
message="$1"; shift
18+
fi
19+
20+
while test $# -gt 0
21+
do
22+
case "$1" in
23+
--message|-m)
24+
shift
25+
message="$1"
26+
;;
27+
--wip)
28+
wip=true
29+
;;
30+
--label)
31+
shift
32+
label="$1"
33+
;;
34+
--description|-d)
35+
shift
36+
description="$1"
37+
;;
38+
-*)
39+
echo "bad option '$1'"
40+
exit 1
41+
;;
42+
esac
43+
shift
44+
done
1545

1646
if [[ ! -n "$(curr_branch)" ]]; then
1747
err "you have to be inside the repository directory"
@@ -30,15 +60,19 @@ if [[ ! -n "$name" ]]; then
3060
exit 1
3161
fi
3262

33-
info "creating request to merge back to $target ..."
63+
while [[ ! -n "$label" ]]; do
64+
info "choose a label:"
65+
read label
66+
done
67+
68+
info "#$label - creating request to merge back to $target ..."
3469
git checkout $name
3570

36-
info "${name}'s merge request message:"
37-
if [[ -n "$message" ]]; then
38-
echo "$message"
39-
else
71+
while [[ ! -n "$message" ]]; do
72+
info "${name}'s MR message:"
4073
read message
41-
fi
74+
done
75+
debug "MR message: '$message'"
4276

4377
if [[ $wip == true ]]; then
4478
message="[WIP] $message"
@@ -51,6 +85,7 @@ git push \
5185
-o merge_request.target=$target \
5286
-o merge_request.remove_source_branch \
5387
-o merge_request.title="$message" \
54-
-o merge_request.description="$detail"
88+
-o merge_request.description="$description" \
89+
-o merge_request.label="$label"
5590

56-
$MYDIR/rr-comment.sh "opened merge request to $target"
91+
$MYDIR/rr-comment.sh "opened MR to $target"

rr-curr-project.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ source $MYDIR/db.sh
1111

1212
json=$($MYDIR/runrun.sh GET "tasks?user_id=$(rr_user_id)&is_working_on=true")
1313
if [[ -n "$json" && "$json" != '[]' ]]; then
14-
p_name=$(echo "$json" | $MYDIR/jprop.sh "[0]['project_name']")
14+
# TODO abstrair pra não ter que duplicar e chamar no pause
1515
p_id=$(echo "$json" | $MYDIR/jprop.sh "[0]['project_id']")
16-
17-
t_name=$(echo "$json" | $MYDIR/jprop.sh "[0]['title']")
18-
t_id=$(echo "$json" | $MYDIR/jprop.sh "[0]['id']")
19-
t_type=$(echo "$json" | $MYDIR/jprop.sh "[0]['type_id']")
20-
2116
db CURR_PROJECT_ID "${p_id}"
17+
p_name=$(echo "$json" | $MYDIR/jprop.sh "[0]['project_name']")
2218
db CURR_PROJECT_NAME "${p_name}"
2319

20+
t_id=$(echo "$json" | $MYDIR/jprop.sh "[0]['id']")
2421
db CURR_TASK_ID "${t_id}"
22+
t_name=$(echo "$json" | $MYDIR/jprop.sh "[0]['title']")
2523
db CURR_TASK_NAME "${t_name}"
24+
t_type=$(echo "$json" | $MYDIR/jprop.sh "[0]['type_id']")
2625
db CURR_TASK_TYPE "${t_type}"
2726

2827
t_team=$(echo "$json" | $MYDIR/jprop.sh "[0]['team_id']")

rr-pause.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@ source $MYDIR/env
99
source $MYDIR/log.sh
1010
source $MYDIR/db.sh
1111

12-
id="$(db CURR_TASK_ID)"
12+
id="$1"
13+
if [[ ! -n "$id" ]]; then
14+
id="$(db CURR_TASK_ID)"
15+
fi
1316
name="$(db CURR_TASK_NAME)"
1417

18+
if [[ $(nan "$id") == true ]]; then
19+
err "arg 1 must be the task id"
20+
fi
21+
1522
if [[ $(nan "$id") == true ]]; then
1623
info "no tasks were running"
1724
exit 0
1825
fi
1926

20-
info "pausing '$name' ..."
27+
info "pausing task #$id ..."
2128

2229
json=$($MYDIR/runrun.sh POST "tasks/$id/pause")
2330
if [[ "$json" == *'already paused'* ]]; then

rr-play.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ if [[ ! -n "$id" ]]; then
1515
fi
1616

1717
if [[ $(nan "$id") == true ]]; then
18-
err "arg 1 must be the task id, showing results for '$id'..."
19-
$MYDIR/rr-find-task.sh "$id"
20-
info "choose one an try again"
18+
err "arg 1 must be the task id"
19+
if [[ -n "$id" ]]; then
20+
info "showing results for '$id'..."
21+
$MYDIR/rr-find-task.sh "$id"
22+
fi
23+
24+
info "choose one and try again"
2125
exit 1
2226
fi
2327

0 commit comments

Comments
 (0)