File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ if [[ $1 == " " ]]
4+ then
5+ branch=$( git rev-parse --abbrev-ref HEAD 2& > /dev/null)
6+ remote=$( git config branch." ${branch} " .remote || echo " origin" )
7+ else
8+ remote=$1
9+ fi
10+
11+ if [[ $remote == " " ]]
12+ then
13+ echo " Remote not found"
14+ exit 1
15+ fi
16+
17+ remote_url=$( git remote get-url " ${remote} " )
18+
19+ if [[ $? -ne 0 ]]
20+ then
21+ exit $?
22+ fi
23+
24+ if [[ $remote_url = git@* ]]
25+ then
26+ url=$( echo " ${remote_url} " | sed -E -e ' s/:/\//' -e ' s/\.git$//' -e ' s/.*@(.*)/http:\/\/\1/' )
27+ elif [[ $remote_url = http* ]]
28+ then
29+ url=${remote_url% .git}
30+ fi
31+
32+ if [[ $url =~ github ]]
33+ then
34+ ci_url=${url} /actions
35+ elif [[ $url =~ gitlab ]]
36+ then
37+ ci_url=${url} /-/pipelines
38+ elif [[ $url =~ bitbucket ]]
39+ then
40+ ci_url=${url} /addon/pipelines/home
41+ fi
42+ case " $OSTYPE " in
43+ darwin* )
44+ # MacOS
45+ open " ${ci_url} "
46+ ;;
47+ msys)
48+ # Git-Bash on Windows
49+ start " ${ci_url} "
50+ ;;
51+ linux* )
52+ # Handle WSL on Windows
53+ if uname -a | grep -i -q Microsoft
54+ then
55+ powershell.exe -NoProfile start " ${ci_url} "
56+ else
57+ xdg-open " ${ci_url} "
58+ fi
59+ ;;
60+ * )
61+ # fall back to xdg-open for BSDs, etc.
62+ xdg-open " ${ci_url} "
63+ ;;
64+ esac
You can’t perform that action at this time.
0 commit comments