]> source.dussan.org Git - gitea.git/commitdiff
able to disable SSH for #883
authorUnknwon <joe2010xtmf@163.com>
Sat, 7 Feb 2015 15:46:57 +0000 (10:46 -0500)
committerUnknwon <joe2010xtmf@163.com>
Sat, 7 Feb 2015 15:46:57 +0000 (10:46 -0500)
README.md
README_ZH.md
cmd/serve.go
conf/app.ini
gogs.go
models/action.go
models/repo.go
modules/middleware/repo.go
modules/setting/setting.go
templates/.VERSION
templates/repo/header.tmpl

index 3d87e3a1ffd55534028e6b8b9b0048e112ad9e86..e93e599e71814cafd04097c319966a8532155ccb 100644 (file)
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go.
 
 ![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
 
-##### Current version: 0.5.12 Beta
+##### Current version: 0.5.13 Beta
 
 ### NOTICES
 
index be3a2b1bc43c861dd2c978fda8c59516c3918c5f..54e66315a863e600eb4ac1526a33ac2c4ddaa7a4 100644 (file)
@@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。
 
 ![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
 
-##### 当前版本:0.5.12 Beta
+##### 当前版本:0.5.13 Beta
 
 ## 开发目的
 
index 239096234202ef6c9dc4027a27208e17e63c67f6..1f5d944d4fbec97c68e3867a5f96ae17cfe26a07 100644 (file)
@@ -33,6 +33,12 @@ var CmdServ = cli.Command{
 func setup(logPath string) {
        setting.NewConfigContext()
        log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
+
+       if setting.DisableSSH {
+               println("Gogs: SSH has been disabled")
+               os.Exit(1)
+       }
+
        models.LoadModelsConfig()
 
        if models.UseSQLite3 {
index b7a0f1a7c5d249486bb936009166283bba686f24..17d1a3b3b92049a0bd85995ab26d6d13abe1d104 100644 (file)
@@ -18,6 +18,8 @@ DOMAIN = localhost
 ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
 HTTP_ADDR =
 HTTP_PORT = 3000
+; Disable SSH feature when not available
+DISABLE_SSH = false
 SSH_PORT = 22
 ; Disable CDN even in "prod" mode
 OFFLINE_MODE = false
diff --git a/gogs.go b/gogs.go
index ce524af5aa725f0b3782c08e0961ce460c351cfe..c09c4ca196a3907633d47a90c136881ee1a9dcd7 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
        "github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.5.12.0206 Beta"
+const APP_VER = "0.5.13.0207 Beta"
 
 func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
index 34f543c4b2e0dba6fcfae8ee9b0ada900d7e200b..a6c6cfbfaa92aac7e01a668e6fd32f12a581b8e7 100644 (file)
@@ -119,8 +119,6 @@ func (a Action) GetIssueInfos() []string {
 
 func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, commits []*base.PushCommit) error {
        for _, c := range commits {
-               // FIXME: should not be a reference when it comes with action.
-               // e.g. fixes #1 will not have duplicated reference message.
                for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) {
                        ref := ref[strings.IndexByte(ref, byte(' '))+1:]
                        ref = strings.TrimRightFunc(ref, func(c rune) bool {
index b74582175330b0990359c7c166569446cd79f40c..3e07adba63712bed6835d9e5b3bdb1e73ea90ce4 100644 (file)
@@ -247,8 +247,8 @@ func (repo *Repository) CloneLink() (cl CloneLink, err error) {
        if err = repo.GetOwner(); err != nil {
                return cl, err
        }
-       if setting.SshPort != 22 {
-               cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SshPort, repo.Owner.LowerName, repo.LowerName)
+       if setting.SSHPort != 22 {
+               cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SSHPort, repo.Owner.LowerName, repo.LowerName)
        } else {
                cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.Domain, repo.Owner.LowerName, repo.LowerName)
        }
index d143d8a86b35aa3eb6be4312f0d4b928932b67eb..1ab158dd6d8721a6be515f4ac53abca89bf3b4a8 100644 (file)
@@ -386,6 +386,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
                ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner
                ctx.Data["IsRepositoryTrueOwner"] = ctx.Repo.IsTrueOwner
 
+               ctx.Data["DisableSSH"] = setting.DisableSSH
                ctx.Repo.CloneLink, err = repo.CloneLink()
                if err != nil {
                        ctx.Handle(500, "CloneLink", err)
index e79e6d6b967760d2924f56c21e63545816ace9d5..6a205921b8ee370d360d9a72082e15673fa0b22a 100644 (file)
@@ -50,7 +50,8 @@ var (
        Protocol           Scheme
        Domain             string
        HttpAddr, HttpPort string
-       SshPort            int
+       DisableSSH         bool
+       SSHPort            int
        OfflineMode        bool
        DisableRouterLog   bool
        CertFile, KeyFile  string
@@ -209,7 +210,8 @@ func NewConfigContext() {
        Domain = sec.Key("DOMAIN").MustString("localhost")
        HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
        HttpPort = sec.Key("HTTP_PORT").MustString("3000")
-       SshPort = sec.Key("SSH_PORT").MustInt(22)
+       DisableSSH = sec.Key("DISABLE_SSH").MustBool()
+       SSHPort = sec.Key("SSH_PORT").MustInt(22)
        OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
        DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
        StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
index 99de7de73e77e75aa47bf8eb140e249976d99c2b..5a5ed364d98437b3191fef97b8a24c95dc1645dd 100644 (file)
@@ -1 +1 @@
-0.5.12.0206 Beta
\ No newline at end of file
+0.5.13.0207 Beta
\ No newline at end of file
index 20e67db810f9723c56f913d51da3783d1cdde20f..9e52efc727c778e639917d87d62fc9de11c488ee 100644 (file)
                 </a>
                 <div id="repo-header-download-drop" class="drop-down">
                     <div id="repo-clone" class="clear">
-                        <button class="btn btn-blue left left btn-left-radius" id="repo-clone-ssh" data-link="{{$.CloneLink.SSH}}">SSH</button>
-                        <button class="btn btn-gray left" id="repo-clone-https" data-link="{{$.CloneLink.HTTPS}}">HTTPS</button>
-                        <input id="repo-clone-url" class="ipt ipt-disabled left" value="{{$.CloneLink.SSH}}" readonly />
+                        {{if not $.DisableSSH}}
+                        <button class="btn btn-blue left btn-left-radius" id="repo-clone-ssh" data-link="{{$.CloneLink.SSH}}">SSH</button>
+                        {{end}}
+                        <button class="btn {{if $.DisableSSH}}btn-blue{{else}}btn-gray{{end}} left" id="repo-clone-https" data-link="{{$.CloneLink.HTTPS}}">HTTPS</button>
+                        <input id="repo-clone-url" class="ipt ipt-disabled left" value="{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}" readonly />
                         <button id="repo-clone-copy" class="btn btn-black left btn-right-radius" data-copy-val="val" data-copy-from="#repo-clone-url" original-title="{{$.i18n.Tr "repo.click_to_copy"}}" data-original-title="{{$.i18n.Tr "repo.click_to_copy"}}" data-after-title="{{$.i18n.Tr "repo.copied"}}">{{$.i18n.Tr "repo.copy_link"}}</button>
                         <p class="text-center" id="repo-clone-help">{{$.i18n.Tr "repo.clone_helper" "http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository" | Str2html}}</p>
                         <hr/>