mirror of
https://github.com/paulirish/git-open.git
synced 2026-09-10 07:26:15 -04:00
feat: support forge-specific branch URL formats
Handle branch URLs for Gitea, Forgejo, Codeberg, and Gogs. Update docs and tests accordingly.
This commit is contained in:
parent
63c0e77aaf
commit
394a9c7145
|
|
@ -127,11 +127,15 @@ git-open can automatically guess the corresponding repository page for remotes
|
|||
- GitLab custom hosted (see below)
|
||||
- bitbucket.org
|
||||
- Atlassian Bitbucket Server (formerly _Atlassian Stash_)
|
||||
- Gitea, Forgejo, Codeberg, and Gogs (see below)
|
||||
- Visual Studio Team Services
|
||||
- Team Foundation Server (on-premises)
|
||||
- AWS Code Commit
|
||||
- cnb.cool
|
||||
|
||||
For Gitea, Forgejo, Codeberg, and Gogs instances, set `open.[gitdomain].forge`
|
||||
to the matching forge name so `git-open` uses the appropriate branch URL format.
|
||||
|
||||
## Configuration
|
||||
|
||||
See the [man page](git-open.1.md) for more information on how to configure `git-open`.
|
||||
|
|
@ -199,4 +203,3 @@ Copyright Jason McCreary & Paul Irish. Licensed under MIT.
|
|||
- **2016-07-23** - Readme: fix oh-my-zsh install instructions
|
||||
- **2016-07-22** - 1.1.0 shipped. update and add linters for package.json, readme.
|
||||
- **2016-07-11** - Readme formatting and installation instructions updated. Changelog started
|
||||
|
||||
|
|
|
|||
16
git-open
16
git-open
|
|
@ -191,11 +191,17 @@ else
|
|||
# Make # and % characters url friendly
|
||||
# github.com/paulirish/git-open/pull/24
|
||||
remote_ref=${remote_ref//%/%25} remote_ref=${remote_ref//#/%23}
|
||||
if [[ $forge == 'gitea' ]]; then
|
||||
providerBranchRef="/src/branch/$remote_ref"
|
||||
else
|
||||
providerBranchRef="/tree/$remote_ref"
|
||||
fi
|
||||
case "$forge" in
|
||||
gitea|forgejo|codeberg)
|
||||
providerBranchRef="/src/branch/$remote_ref"
|
||||
;;
|
||||
gogs)
|
||||
providerBranchRef="/src/$remote_ref"
|
||||
;;
|
||||
*)
|
||||
providerBranchRef="/tree/$remote_ref"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ "$domain" == 'bitbucket.org' ]]; then
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ on the following git hosting services:
|
|||
- GitLab CE/EE (self hosted GitLab, see `CONFIGURATION`)
|
||||
- bitbucket.org
|
||||
- Atlassian Bitbucket Server (formerly _Atlassian Stash_)
|
||||
- Gitea, Forgejo, Codeberg, and Gogs (see `CONFIGURATION`)
|
||||
- Visual Studio Team Services
|
||||
- Team Foundation Server (on-premises)
|
||||
|
||||
|
|
@ -118,17 +119,19 @@ git config open.default.remote upstream
|
|||
This is equivalent to always typing `git open upstream`.
|
||||
|
||||
|
||||
### Gitea options
|
||||
### Forge options
|
||||
|
||||
To configure Gitea support you need to set the following option.
|
||||
To configure Gitea, Forgejo, Codeberg or Gogs support you need to set the following option.
|
||||
|
||||
`open.[gitdomain].forge`
|
||||
The git forge present at the git domain. This only needs to be set for Gitea because it uses another branch URL format.
|
||||
The git forge present at the git domain. This only needs to be set for hosts that do not use the default `/tree/<branch>` branch URL format.
|
||||
|
||||
**Example**
|
||||
|
||||
```sh
|
||||
git config [--global] "open.https://gitea.internal.biz.forge" "gitea"
|
||||
git config [--global] "open.https://codeberg.org.forge" "codeberg"
|
||||
git config [--global] "open.http://localhost:3000.forge" "gogs"
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -558,6 +558,42 @@ setup() {
|
|||
assert_output "https://gitlab.example.com/user/repo/issues/10"
|
||||
}
|
||||
|
||||
##
|
||||
## Gitea / Forgejo / Codeberg / Gogs
|
||||
##
|
||||
|
||||
@test "forge: codeberg branch" {
|
||||
git remote set-url origin "git@codeberg.org:user/repo.git"
|
||||
git config --local "open.https://codeberg.org.forge" "codeberg"
|
||||
git checkout -B "mybranch"
|
||||
run ../git-open
|
||||
assert_output "https://codeberg.org/user/repo/src/branch/mybranch"
|
||||
}
|
||||
|
||||
@test "forge: gitea branch" {
|
||||
git remote set-url origin "git@gitea.example.com:user/repo.git"
|
||||
git config --local "open.https://gitea.example.com.forge" "gitea"
|
||||
git checkout -B "mybranch"
|
||||
run ../git-open
|
||||
assert_output "https://gitea.example.com/user/repo/src/branch/mybranch"
|
||||
}
|
||||
|
||||
@test "forge: forgejo branch" {
|
||||
git remote set-url origin "git@forgejo.example.com:user/repo.git"
|
||||
git config --local "open.https://forgejo.example.com.forge" "forgejo"
|
||||
git checkout -B "mybranch"
|
||||
run ../git-open
|
||||
assert_output "https://forgejo.example.com/user/repo/src/branch/mybranch"
|
||||
}
|
||||
|
||||
@test "forge: gogs branch" {
|
||||
git remote set-url origin "http://localhost:3000/user/repo.git"
|
||||
git config --local "open.http://localhost:3000.forge" "gogs"
|
||||
git checkout -B "mybranch"
|
||||
run ../git-open
|
||||
assert_output "http://localhost:3000/user/repo/src/mybranch"
|
||||
}
|
||||
|
||||
##
|
||||
## Visual Studio Team Services
|
||||
##
|
||||
|
|
|
|||
Loading…
Reference in a new issue