Skip to content

Commit d9d8fad

Browse files
ElectronicWartboerger
authored andcommitted
Add UseCompatSSHURI setting (#2356)
* Add UseCompatSSHURI setting Signed-off-by: Manuel Kroeber <[email protected]> (+1 squashed commits) Squashed commits: [dda2dc79] Add ForceCloneSSHURL setting Signed-off-by: Manuel Kroeber <[email protected]> * Make protocol if construct more readable Signed-off-by: Manuel Kroeber <[email protected]>
1 parent f61a1d2 commit d9d8fad

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

conf/app.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ PULL_REQUEST_QUEUE_LENGTH = 1000
2323
PREFERRED_LICENSES = Apache License 2.0,MIT License
2424
; Disable ability to interact with repositories by HTTP protocol
2525
DISABLE_HTTP_GIT = false
26+
; Force ssh:// clone url instead of scp-style uri when default SSH port is used
27+
USE_COMPAT_SSH_URI = false
2628

2729
[repository.editor]
2830
; List of file extensions that should have line wraps in the CodeMirror editor

models/repo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2014 The Gogs Authors. All rights reserved.
2+
// Copyright 2017 The Gitea Authors. All rights reserved.
23
// Use of this source code is governed by a MIT-style
34
// license that can be found in the LICENSE file.
45

@@ -791,6 +792,8 @@ func (repo *Repository) cloneLink(isUncyclo bool) *CloneLink {
791792
cl := new(CloneLink)
792793
if setting.SSH.Port != 22 {
793794
cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.SSH.Domain, setting.SSH.Port, repo.Owner.Name, repoName)
795+
} else if setting.Repository.UseCompatSSHURI {
796+
cl.SSH = fmt.Sprintf("ssh://%s@%s/%s/%s.git", setting.RunUser, setting.SSH.Domain, repo.Owner.Name, repoName)
794797
} else {
795798
cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.SSH.Domain, repo.Owner.Name, repoName)
796799
}

modules/setting/setting.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ var (
161161
PullRequestQueueLength int
162162
PreferredLicenses []string
163163
DisableHTTPGit bool
164+
UseCompatSSHURI bool
164165

165166
// Repository editor settings
166167
Editor struct {
@@ -189,6 +190,7 @@ var (
189190
PullRequestQueueLength: 1000,
190191
PreferredLicenses: []string{"Apache License 2.0,MIT License"},
191192
DisableHTTPGit: false,
193+
UseCompatSSHURI: false,
192194

193195
// Repository editor settings
194196
Editor: struct {
@@ -903,6 +905,7 @@ func NewContext() {
903905
// Determine and create root git repository path.
904906
sec = Cfg.Section("repository")
905907
Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
908+
Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
906909
Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
907910
RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
908911
forcePathSeparator(RepoRootPath)

0 commit comments

Comments
 (0)