Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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 changes: 11 additions & 5 deletions git-open
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions git-open.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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"
```


Expand Down
36 changes: 36 additions & 0 deletions test/git-open.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
##
Expand Down
Loading