mirror of
https://github.com/paulirish/git-open.git
synced 2026-09-10 07:26:15 -04:00
commit
08fa2abd7e
10
git-open
10
git-open
|
|
@ -16,6 +16,7 @@ git open [remote] [branch]
|
|||
https://github.com/paulirish/git-open/
|
||||
|
||||
Available options are
|
||||
c,commit! open current commit
|
||||
i,issue! open issues page
|
||||
p,print! just print the url
|
||||
"
|
||||
|
|
@ -25,12 +26,14 @@ p,print! just print the url
|
|||
SUBDIRECTORY_OK='Yes' . "$(git --exec-path)/git-sh-setup"
|
||||
|
||||
# Defaults
|
||||
is_commit=0
|
||||
is_issue=0
|
||||
protocol="https"
|
||||
print_only=0
|
||||
|
||||
while test $# != 0; do
|
||||
case "$1" in
|
||||
--commit) is_commit=1;;
|
||||
--issue) is_issue=1;;
|
||||
--print) print_only=1;;
|
||||
--) shift; break ;;
|
||||
|
|
@ -227,8 +230,11 @@ fi
|
|||
|
||||
openurl="$protocol://$domain/$urlpath"
|
||||
|
||||
# simplify URL for master
|
||||
if [[ $remote_ref != "master" ]]; then
|
||||
if (( is_commit )); then
|
||||
sha=$(git rev-parse HEAD)
|
||||
openurl="$openurl/commit/$sha"
|
||||
elif [[ $remote_ref != "master" ]]; then
|
||||
# simplify URL for master
|
||||
openurl="$openurl$providerBranchRef"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git open` [--issue] [remote-name] [branch-name]
|
||||
`git open` [--issue] [--commit] [remote-name] [branch-name]
|
||||
|
||||
|
||||
## DESCRIPTION
|
||||
|
|
@ -14,6 +14,10 @@ git hosting services are supported.
|
|||
|
||||
## OPTIONS
|
||||
|
||||
`-c`, `--commit`
|
||||
Open the current commit. See `EXAMPLES` for more information.
|
||||
Only tested with GitHub & GitLab.
|
||||
|
||||
`-i`, `--issue`
|
||||
Open the current issue. When the name of the current branch matches the right pattern,
|
||||
it will open the webpage with that issue. See `EXAMPLES` for more information.
|
||||
|
|
@ -58,6 +62,14 @@ git open --print
|
|||
|
||||
It prints the URL https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/
|
||||
|
||||
```sh
|
||||
git open --commit
|
||||
```
|
||||
|
||||
Supposing that the current sha is `2ddc8d4548d0cee3d714dcf0068dbec5b168a9b2`, it opens
|
||||
https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/commit/2ddc8d4548d0cee3d714dcf0068dbec5b168a9b2
|
||||
|
||||
|
||||
## SUPPORTED GIT HOSTING SERVICES
|
||||
|
||||
git-open can automatically guess the corresponding repository page for remotes
|
||||
|
|
|
|||
|
|
@ -160,6 +160,13 @@ setup() {
|
|||
assert_output "https://github.com/paulirish/git-open/issues/38"
|
||||
}
|
||||
|
||||
@test "gh: git open --commit" {
|
||||
git remote set-url origin "github.com:paulirish/git-open.git"
|
||||
sha=$(git rev-parse HEAD)
|
||||
run ../git-open "--commit"
|
||||
assert_output "https://github.com/paulirish/git-open/commit/${sha}"
|
||||
}
|
||||
|
||||
@test "gh: gist" {
|
||||
git remote set-url origin "git@gist.github.com:2d84a6db1b41b4020685.git"
|
||||
run ../git-open
|
||||
|
|
|
|||
Loading…
Reference in a new issue