From 281dad270e02218c56c742759451ed66c6903dc2 Mon Sep 17 00:00:00 2001 From: Sandro Date: Tue, 2 May 2023 20:29:10 +0200 Subject: [PATCH] Add gitea support (#184) --- git-open | 7 ++++++- git-open.1.md | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/git-open b/git-open index bc3d121..a7aec6e 100755 --- a/git-open +++ b/git-open @@ -168,6 +168,7 @@ function getConfig() { domain=$(getConfig "domain") protocol=$(getConfig "protocol") +forge=$(getConfig "forge") # Remote ref to open remote_ref=${upstream_branch:-${branch:-$(git describe --tags --exact-match 2>/dev/null || git rev-parse HEAD)}} @@ -183,7 +184,11 @@ else # Make # and % characters url friendly # github.com/paulirish/git-open/pull/24 remote_ref=${remote_ref//%/%25} remote_ref=${remote_ref//#/%23} - providerBranchRef="/tree/$remote_ref" + if [[ $forge == 'gitea' ]]; then + providerBranchRef="/src/branch/$remote_ref" + else + providerBranchRef="/tree/$remote_ref" + fi fi if [[ "$domain" == 'bitbucket.org' ]]; then diff --git a/git-open.1.md b/git-open.1.md index 5c63db3..504669a 100644 --- a/git-open.1.md +++ b/git-open.1.md @@ -118,6 +118,20 @@ git config open.default.remote upstream This is equivalent to always typing `git open upstream`. +### Gitea options + +To configure Gitea 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. + +**Example** + +```sh +git config [--global] "open.https://gitea.internal.biz.forge" "gitea" +``` + + ### GitLab options To configure GitLab support (or other unique hosting situations) you may need to set some options.