-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #959 from pbnj/feat/git-browse-ci
feat: implement git-browse-ci
- Loading branch information
Showing
10 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -o pipefail | ||
if [[ $1 == "" ]] | ||
then | ||
branch=$(git rev-parse --abbrev-ref HEAD &> /dev/null) | ||
remote=$(git config branch."${branch}".remote || echo "origin") | ||
else | ||
remote=$1 | ||
fi | ||
|
||
if [[ $remote == "" ]] | ||
then | ||
echo "Remote not found" | ||
exit 1 | ||
fi | ||
|
||
remote_url=$(git remote get-url "${remote}") | ||
|
||
if [[ $? -ne 0 ]] | ||
then | ||
exit $? | ||
fi | ||
|
||
if [[ $remote_url = git@* ]] | ||
then | ||
url=$(echo "${remote_url}" | sed -E -e 's/:/\//' -e 's/\.git$//' -e 's/.*@(.*)/http:\/\/\1/') | ||
elif [[ $remote_url = http* ]] | ||
then | ||
url=${remote_url%.git} | ||
fi | ||
|
||
if [[ $url =~ github ]] | ||
then | ||
ci_url=${url}/actions | ||
elif [[ $url =~ gitlab ]] | ||
then | ||
ci_url=${url}/-/pipelines | ||
elif [[ $url =~ bitbucket ]] | ||
then | ||
ci_url=${url}/addon/pipelines/home | ||
fi | ||
case "$OSTYPE" in | ||
darwin*) | ||
# MacOS | ||
open "${ci_url}" | ||
;; | ||
msys) | ||
# Git-Bash on Windows | ||
start "${ci_url}" | ||
;; | ||
linux*) | ||
# Handle WSL on Windows | ||
if uname -a | grep -i -q Microsoft | ||
then | ||
powershell.exe -NoProfile start "${ci_url}" | ||
else | ||
xdg-open "${ci_url}" | ||
fi | ||
;; | ||
*) | ||
# fall back to xdg-open for BSDs, etc. | ||
xdg-open "${ci_url}" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.\" generated with Ronn/v0.7.3 | ||
.\" http://github.com/rtomayko/ronn/tree/0.7.3 | ||
. | ||
.TH "GIT\-BROWSE\-CI" "1" "March 2022" "" "Git Extras" | ||
. | ||
.SH "NAME" | ||
\fBgit\-browse\-ci\fR \- | ||
. | ||
.SH "SYNOPSIS" | ||
\fBgit\-browse\-ci\fR [remote_name] | ||
. | ||
.SH "DESCRIPTION" | ||
Opens the current git repository CI page in your default web browser\. | ||
. | ||
.SH "OPTIONS" | ||
<remote_name> | ||
. | ||
.P | ||
The name of the remote you wish to browse to\. Defaults to the first remote if not specified\. | ||
. | ||
.SH "EXAMPLES" | ||
$ git browse\-ci | ||
. | ||
.P | ||
$ git browse\-ci upstream | ||
. | ||
.SH "AUTHOR" | ||
Written by Peter Benjamin <\fIhttps://github\.com/pbnj\fR> | ||
. | ||
.SH "REPORTING BUGS" | ||
<\fIhttps://github\.com/tj/git\-extras/issues\fR> | ||
. | ||
.SH "SEE ALSO" | ||
<\fIhttps://github\.com/tj/git\-extras\fR> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
git-browse-ci(1) -- <View the web page for the current repository> | ||
================================ | ||
|
||
## SYNOPSIS | ||
|
||
`git-browse-ci` [remote_name] | ||
|
||
## DESCRIPTION | ||
|
||
Opens the current git repository CI page in your default web browser. | ||
|
||
## OPTIONS | ||
|
||
<remote_name> | ||
|
||
The name of the remote you wish to browse to. Defaults to | ||
the first remote if not specified. | ||
|
||
## EXAMPLES | ||
|
||
$ git browse-ci | ||
|
||
$ git browse-ci upstream | ||
|
||
## AUTHOR | ||
|
||
Written by Peter Benjamin <<https://github.com/pbnj>> | ||
|
||
## REPORTING BUGS | ||
|
||
<<https://github.com/tj/git-extras/issues>> | ||
|
||
## SEE ALSO | ||
|
||
<<https://github.com/tj/git-extras>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters