-
Notifications
You must be signed in to change notification settings - Fork 0
/
links.sh
executable file
·79 lines (68 loc) · 1.9 KB
/
links.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
#!/bin/bash -e
# @installable
MYSELF="$(readlink -f "$0")"
MYDIR="${MYSELF%/*}"
ME=$(basename $MYSELF)
source $MYDIR/env
[[ -f $LOCAL_ENV ]] && source $LOCAL_ENV
source $MYDIR/log.sh
source $MYDIR/db.sh
if [[ ! -f "$(repo_root)/.git/config" ]]; then
err "you have to be inside a repository directory before running this command"
branchd="$(db CURR_FEATURE_DIR)"
if [[ -d "$branchd" ]]; then
info "maybe you want to go to $branchd ?"
fi
exit 1
fi
branch="$(curr_branch)"
project_url=$(project_url)
if [[ ! -n "$branch" ]]; then
err "you have to be inside the repository directory"
branchd="$(db CURR_FEATURE_DIR)"
if [[ -d "$branchd" ]]; then
info "maybe you want to go to $branchd ?"
fi
exit 1
fi
info "project:"
echo "$project_url"
echo ""
if [[ $project_url == *gitlab* ]]; then
info "branch:"
echo "$project_url/-/tree/$branch"
echo ""
info "merge request:"
echo "$project_url/-/merge_requests/new?merge_request%5Bsource_branch%5D=$branch"
else
info "branch:"
echo "$project_url/tree/$branch"
fi
echo ""
if [[ "$branch" == *fix* ]]; then
issue_id=$(echo $branch | cut -d'-' -f2)
if [[ $(nan $issue_id) == true ]]; then
err "couldn't determine issue id from branch name: $branch"
exit 1
fi
info "issue:"
if [[ $project_url == *gitlab* ]]; then
echo "$project_url/-/issues/$issue_id"
else
echo "$project_url/issues/$issue_id"
fi
fi
echo ""
if [[ "$RR_ENABLED" == true ]]; then
info "task:"
task=$($MYDIR/rr-find-task.sh "$branch" 2>/dev/null)
task_id=$(echo "$task" | cut -d'=' -f1)
if [[ $(nan $task_id) == true ]]; then
err "couldn't determine task id from feature: '$branch'. create it with gclit-feature"
exit 1
fi
task_info=$(echo "$task" | cut -d'=' -f2)
echo "https://runrun.it/en-US/tasks/$task_id"
echo "$task_info"
echo ""
fi