forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide mechanism for configuring submodule aliases
Sometimes Gitea users would like submodules when displayed on the website to have a different alias than what is normally inferred by gitea. This PR provides a mechanism to configure this. Fix go-gitea#15178 Signed-off-by: Andrew Thornton <[email protected]>
- Loading branch information
Showing
6 changed files
with
120 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1145,6 +1145,13 @@ CLONE = 300 | |
PULL = 300 | ||
GC = 60 | ||
|
||
; Submodule aliase | ||
; [git.submodule] | ||
; MAP_NAME_1 = [email protected] | ||
; MAP_VALUE_1 = https://example.com | ||
; MAP_NAME_2 = [email protected]/go-gitea/gitea | ||
; MAP_VALUE_2 = https://gitea.com/gitea/gitea | ||
|
||
[mirror] | ||
; Default interval as a duration between each check | ||
DEFAULT_INTERVAL = 8h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -782,13 +782,20 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef | |
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay. | ||
|
||
## Git - Timeout settings (`git.timeout`) | ||
|
||
- `DEFAUlT`: **360**: Git operations default timeout seconds. | ||
- `MIGRATE`: **600**: Migrate external repositories timeout seconds. | ||
- `MIRROR`: **300**: Mirror external repositories timeout seconds. | ||
- `CLONE`: **300**: Git clone from internal repositories timeout seconds. | ||
- `PULL`: **300**: Git pull from internal repositories timeout seconds. | ||
- `GC`: **60**: Git repository GC timeout seconds. | ||
|
||
## Git - Submodule alias settings (`git.submodule`) | ||
|
||
- List of `MAP_NAME_` and `MAP_VALUE_` pairs that map submodule urls or partial urls to web paths. For example: | ||
- `MAP_NAME_1 = [email protected]` & `MAP_VALUE_1 = https://external` would convert any submodules referring to `[email protected]` to `https://external` | ||
- `MAP_NAME_A = [email protected]:owner/repo` & `MAP_VALUE_A = https://external/externalowner/externalrepo` | ||
|
||
## Metrics (`metrics`) | ||
|
||
- `ENABLED`: **false**: Enables /metrics endpoint for prometheus. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,32 +12,55 @@ import ( | |
|
||
func TestGetRefURL(t *testing.T) { | ||
var kases = []struct { | ||
refURL string | ||
prefixURL string | ||
parentPath string | ||
SSHDomain string | ||
expect string | ||
refURL string | ||
prefixURL string | ||
parentPath string | ||
SSHDomain string | ||
expect string | ||
subModuleMap map[string]string | ||
}{ | ||
{"git://github.com/user1/repo1", "/", "user1/repo2", "", "http://github.com/user1/repo1"}, | ||
{"https://localhost/user1/repo1.git", "/", "user1/repo2", "", "https://localhost/user1/repo1"}, | ||
{"http://localhost/user1/repo1.git", "/", "owner/reponame", "", "http://localhost/user1/repo1"}, | ||
{"[email protected]:user1/repo1.git", "/", "owner/reponame", "", "http://github.com/user1/repo1"}, | ||
{"ssh://[email protected]:2222/zefie/lge_g6_kernel_scripts.git", "/", "zefie/lge_g6_kernel", "", "http://git.zefie.net/zefie/lge_g6_kernel_scripts"}, | ||
{"[email protected]:2222/zefie/lge_g6_kernel_scripts.git", "/", "zefie/lge_g6_kernel", "", "http://git.zefie.net/2222/zefie/lge_g6_kernel_scripts"}, | ||
{"[email protected]:go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "", "https://try.gitea.io/go-gitea/gitea"}, | ||
{"ssh://[email protected]:9999/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "", "https://try.gitea.io/go-gitea/gitea"}, | ||
{"git://[email protected]:9999/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "", "https://try.gitea.io/go-gitea/gitea"}, | ||
{"ssh://[email protected]:9999/go-gitea/gitea", "https://127.0.0.1:3000/", "go-gitea/sdk", "", "https://127.0.0.1:3000/go-gitea/gitea"}, | ||
{"https://gitea.com:3000/user1/repo1.git", "https://127.0.0.1:3000/", "user/repo2", "", "https://gitea.com:3000/user1/repo1"}, | ||
{"https://example.gitea.com/gitea/user1/repo1.git", "https://example.gitea.com/gitea/", "", "user/repo2", "https://example.gitea.com/gitea/user1/repo1"}, | ||
{"https://username:[email protected]/username/repository.git", "/", "username/repository2", "", "https://username:[email protected]/username/repository"}, | ||
{"somethingbad", "https://127.0.0.1:3000/go-gitea/gitea", "/", "", ""}, | ||
{"git@localhost:user/repo", "https://localhost/", "user2/repo1", "", "https://localhost/user/repo"}, | ||
{"../path/to/repo.git/", "https://localhost/", "user/repo2", "", "https://localhost/user/path/to/repo.git"}, | ||
{"ssh://[email protected]:2222/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "ssh.gitea.io", "https://try.gitea.io/go-gitea/gitea"}, | ||
{"git://github.com/user1/repo1", "/", "user1/repo2", "", "http://github.com/user1/repo1", map[string]string{}}, | ||
{"https://localhost/user1/repo1.git", "/", "user1/repo2", "", "https://localhost/user1/repo1", map[string]string{}}, | ||
{"http://localhost/user1/repo1.git", "/", "owner/reponame", "", "http://localhost/user1/repo1", map[string]string{}}, | ||
{"[email protected]:user1/repo1.git", "/", "owner/reponame", "", "http://github.com/user1/repo1", map[string]string{}}, | ||
{"ssh://[email protected]:2222/zefie/lge_g6_kernel_scripts.git", "/", "zefie/lge_g6_kernel", "", "http://git.zefie.net/zefie/lge_g6_kernel_scripts", map[string]string{}}, | ||
{"[email protected]:2222/zefie/lge_g6_kernel_scripts.git", "/", "zefie/lge_g6_kernel", "", "http://git.zefie.net/2222/zefie/lge_g6_kernel_scripts", map[string]string{}}, | ||
{"[email protected]:go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "", "https://try.gitea.io/go-gitea/gitea", map[string]string{}}, | ||
{"ssh://[email protected]:9999/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "", "https://try.gitea.io/go-gitea/gitea", map[string]string{}}, | ||
{"git://[email protected]:9999/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "", "https://try.gitea.io/go-gitea/gitea", map[string]string{}}, | ||
{"ssh://[email protected]:9999/go-gitea/gitea", "https://127.0.0.1:3000/", "go-gitea/sdk", "", "https://127.0.0.1:3000/go-gitea/gitea", map[string]string{}}, | ||
{"https://gitea.com:3000/user1/repo1.git", "https://127.0.0.1:3000/", "user/repo2", "", "https://gitea.com:3000/user1/repo1", map[string]string{}}, | ||
{"https://example.gitea.com/gitea/user1/repo1.git", "https://example.gitea.com/gitea/", "", "user/repo2", "https://example.gitea.com/gitea/user1/repo1", map[string]string{}}, | ||
{"https://username:[email protected]/username/repository.git", "/", "username/repository2", "", "https://username:[email protected]/username/repository", map[string]string{}}, | ||
{"somethingbad", "https://127.0.0.1:3000/go-gitea/gitea", "/", "", "", map[string]string{}}, | ||
{"git@localhost:user/repo", "https://localhost/", "user2/repo1", "", "https://localhost/user/repo", map[string]string{}}, | ||
{"../path/to/repo.git/", "https://localhost/", "user/repo2", "", "https://localhost/user/path/to/repo.git", map[string]string{}}, | ||
{"ssh://[email protected]:2222/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "ssh.gitea.io", "https://try.gitea.io/go-gitea/gitea", map[string]string{}}, | ||
{"ssh://[email protected]:2222/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "try.gitea.io", "https://try.gitea.io/go-gitea/gitea", map[string]string{ | ||
"ssh://[email protected]:2222": "https://try.gitea.io", | ||
}}, | ||
{"[email protected]:go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "try.gitea.io", "https://try.gitea.io/go-gitea/gitea", map[string]string{ | ||
"[email protected]": "https://try.gitea.io", | ||
"ssh://[email protected]:2222": "Wrong", | ||
}}, | ||
{"ssh://[email protected]/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "try.gitea.io", "https://try.gitea.io/go-gitea/gitea", map[string]string{ | ||
"ssh://[email protected]": "https://try.gitea.io", | ||
"ssh://[email protected]:2222": "Wrong", | ||
}}, | ||
{"ssh://[email protected]/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "try.gitea.io", "https://try.gitea.io/go-gitea/gitea", map[string]string{ | ||
"[email protected]": "https://try.gitea.io", | ||
}}, | ||
{"ssh://[email protected]/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "try.gitea.io", "https://try.gitea.io/go-gitea/gitea", map[string]string{ | ||
"[email protected]": "https://try.gitea.io", | ||
}}, | ||
{"ssh://[email protected]/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "try.gitea.io", "https://try.gitea.io/go-gitea/gitea", map[string]string{ | ||
"[email protected]:go-gitea/gitea": "https://try.gitea.io/go-gitea/gitea", | ||
}}, | ||
} | ||
|
||
orig := SubModuleMap | ||
for _, kase := range kases { | ||
SubModuleMap = kase.subModuleMap | ||
assert.EqualValues(t, kase.expect, getRefURL(kase.refURL, kase.prefixURL, kase.parentPath, kase.SSHDomain)) | ||
} | ||
SubModuleMap = orig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters