-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: implement git-browse-ci #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e -o pipefail | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get 128 exit code when no upstream is given after this modification...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be the combination of Changing it to the shorthand version |
||
| 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 | ||
| 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.
| 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>> |
Uh oh!
There was an error while loading. Please reload this page.