Browse Source

Merge branch 'dev' of github.com:gogits/gogs into dev

Conflicts:
	conf/app.ini
lunnyxiao 11 years ago
parent
commit
061a879cea

+ 4 - 4
README.md

@@ -5,12 +5,12 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go.
 
 
 ![Demo](https://gowalker.org/public/gogs_demo.gif)
 ![Demo](https://gowalker.org/public/gogs_demo.gif)
 
 
-##### Current version: 0.5.0 Beta
+##### Current version: 0.5.2 Beta
 
 
 ### NOTICES
 ### NOTICES
 
 
-- Due to testing purpose, data of [try.gogits.org](http://try.gogits.org) has been reset in **June 21, 2014** and will reset multiple times after. Please do **NOT** put your important data on the site.
-- Demo site [try.gogits.org](http://try.gogits.org) is running under `dev` branch.
+- Due to testing purpose, data of [try.gogs.io](https://try.gogs.io) has been reset in **June 21, 2014** and will reset multiple times after. Please do **NOT** put your important data on the site.
+- Demo site [try.gogs.io](https://try.gogs.io) is running under `dev` branch.
 
 
 #### Other language version
 #### Other language version
 
 
@@ -24,7 +24,7 @@ The goal of this project is to make the easiest, fastest and most painless way t
 
 
 - Please see [Documentation](http://gogs.io/docs/intro/) for project design, known issues, and change log.
 - Please see [Documentation](http://gogs.io/docs/intro/) for project design, known issues, and change log.
 - See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team.
 - See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team.
-- Try it before anything? Do it [online](http://try.gogits.org/Unknown/gogs) or go down to **Installation -> Install from binary** section!
+- Try it before anything? Do it [online](https://try.gogs.io/Unknown/gogs) or go down to **Installation -> Install from binary** section!
 - Having troubles? Get help from [Troubleshooting](http://gogs.io/docs/intro/troubleshooting.md).
 - Having troubles? Get help from [Troubleshooting](http://gogs.io/docs/intro/troubleshooting.md).
 
 
 ## Features
 ## Features

+ 2 - 2
README_ZH.md

@@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。
 
 
 ![Demo](https://gowalker.org/public/gogs_demo.gif)
 ![Demo](https://gowalker.org/public/gogs_demo.gif)
 
 
-##### 当前版本:0.5.0 Beta
+##### 当前版本:0.5.2 Beta
 
 
 ## 开发目的
 ## 开发目的
 
 
@@ -15,7 +15,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自
 
 
 - 有关项目设计、已知问题和变更日志,请通过  [使用手册](http://gogs.io/docs/intro/) 查看。
 - 有关项目设计、已知问题和变更日志,请通过  [使用手册](http://gogs.io/docs/intro/) 查看。
 - 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
 - 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
-- 想要先睹为快?通过 [在线体验](http://try.gogits.org/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。
+- 想要先睹为快?通过 [在线体验](https://try.gogs.io/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。
 - 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.md) 页面获取帮助。
 - 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.md) 页面获取帮助。
 
 
 ## 功能特性
 ## 功能特性

+ 6 - 7
cmd/web.go

@@ -64,7 +64,8 @@ func newMacaron() *macaron.Macaron {
 	m := macaron.New()
 	m := macaron.New()
 	m.Use(macaron.Logger())
 	m.Use(macaron.Logger())
 	m.Use(macaron.Recovery())
 	m.Use(macaron.Recovery())
-	m.Use(macaron.Static("public",
+	m.Use(macaron.Static(
+		path.Join(setting.StaticRootPath, "public"),
 		macaron.StaticOptions{
 		macaron.StaticOptions{
 			SkipLogging: !setting.DisableRouterLog,
 			SkipLogging: !setting.DisableRouterLog,
 		},
 		},
@@ -124,7 +125,7 @@ func runWeb(*cli.Context) {
 
 
 	// Routers.
 	// Routers.
 	m.Get("/", ignSignIn, routers.Home)
 	m.Get("/", ignSignIn, routers.Home)
-	m.Get("/explore", routers.Explore)
+	m.Get("/explore", ignSignIn, routers.Explore)
 	m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install)
 	m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install)
 	m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost)
 	m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost)
 	m.Group("", func(r *macaron.Router) {
 	m.Group("", func(r *macaron.Router) {
@@ -355,11 +356,9 @@ func runWeb(*cli.Context) {
 	}, ignSignIn, middleware.RepoAssignment(true, true))
 	}, ignSignIn, middleware.RepoAssignment(true, true))
 
 
 	m.Group("/:username", func(r *macaron.Router) {
 	m.Group("/:username", func(r *macaron.Router) {
-		r.Get("/:reponame", middleware.RepoAssignment(true, true, true), repo.Home)
-		m.Group("/:reponame", func(r *macaron.Router) {
-			r.Any("/*", repo.Http)
-		})
-	}, ignSignInAndCsrf)
+		r.Get("/:reponame", ignSignIn, middleware.RepoAssignment(true, true, true), repo.Home)
+		r.Any("/:reponame/*", ignSignInAndCsrf, repo.Http)
+	})
 
 
 	// Not found handler.
 	// Not found handler.
 	m.NotFound(routers.NotFound)
 	m.NotFound(routers.NotFound)

+ 2 - 2
conf/app.ini

@@ -253,8 +253,8 @@ DRIVER =
 CONN =
 CONN =
 
 
 [i18n]
 [i18n]
-LANGS = en-US,zh-CN,de-DE
-NAMES = English,简体中文,Deutsch
+LANGS = en-US,zh-CN,de-DE,fr-CA
+NAMES = English,简体中文,Deutsch,Français
 
 
 [git]
 [git]
 MAX_GITDIFF_LINES = 10000
 MAX_GITDIFF_LINES = 10000

File diff suppressed because it is too large
+ 516 - 0
conf/locale/locale_fr-CA.ini


+ 1 - 1
gogs.go

@@ -17,7 +17,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 	"github.com/gogits/gogs/modules/setting"
 )
 )
 
 
-const APP_VER = "0.5.0.0913 Beta"
+const APP_VER = "0.5.2.0916 Beta"
 
 
 func init() {
 func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())
 	runtime.GOMAXPROCS(runtime.NumCPU())

+ 18 - 6
models/publickey.go

@@ -22,6 +22,7 @@ import (
 
 
 	"github.com/gogits/gogs/modules/log"
 	"github.com/gogits/gogs/modules/log"
 	"github.com/gogits/gogs/modules/process"
 	"github.com/gogits/gogs/modules/process"
+	"github.com/gogits/gogs/modules/setting"
 )
 )
 
 
 const (
 const (
@@ -119,23 +120,30 @@ func CheckPublicKeyString(content string) (bool, error) {
 	tmpFile.WriteString(content)
 	tmpFile.WriteString(content)
 	tmpFile.Close()
 	tmpFile.Close()
 
 
-	// … see if ssh-keygen recognizes its contents
+	// Check if ssh-keygen recognizes its contents.
 	stdout, stderr, err := process.Exec("CheckPublicKeyString", "ssh-keygen", "-l", "-f", tmpPath)
 	stdout, stderr, err := process.Exec("CheckPublicKeyString", "ssh-keygen", "-l", "-f", tmpPath)
 	if err != nil {
 	if err != nil {
 		return false, errors.New("ssh-keygen -l -f: " + stderr)
 		return false, errors.New("ssh-keygen -l -f: " + stderr)
 	} else if len(stdout) < 2 {
 	} else if len(stdout) < 2 {
 		return false, errors.New("ssh-keygen returned not enough output to evaluate the key")
 		return false, errors.New("ssh-keygen returned not enough output to evaluate the key")
 	}
 	}
+
+	// The ssh-keygen in Windows does not print key type, so no need go further.
+	if setting.IsWindows {
+		return true, nil
+	}
+
 	sshKeygenOutput := strings.Split(stdout, " ")
 	sshKeygenOutput := strings.Split(stdout, " ")
 	if len(sshKeygenOutput) < 4 {
 	if len(sshKeygenOutput) < 4 {
 		return false, errors.New("Not enough fields returned by ssh-keygen -l -f")
 		return false, errors.New("Not enough fields returned by ssh-keygen -l -f")
 	}
 	}
+
+	// Check if key type and key size match.
 	keySize, err := com.StrTo(sshKeygenOutput[0]).Int()
 	keySize, err := com.StrTo(sshKeygenOutput[0]).Int()
 	if err != nil {
 	if err != nil {
 		return false, errors.New("Cannot get key size of the given key")
 		return false, errors.New("Cannot get key size of the given key")
 	}
 	}
 	keyType := strings.TrimSpace(sshKeygenOutput[len(sshKeygenOutput)-1])
 	keyType := strings.TrimSpace(sshKeygenOutput[len(sshKeygenOutput)-1])
-
 	if minimumKeySize := MinimumKeySize[keyType]; minimumKeySize == 0 {
 	if minimumKeySize := MinimumKeySize[keyType]; minimumKeySize == 0 {
 		return false, errors.New("Sorry, unrecognized public key type")
 		return false, errors.New("Sorry, unrecognized public key type")
 	} else if keySize < minimumKeySize {
 	} else if keySize < minimumKeySize {
@@ -160,10 +168,14 @@ func saveAuthorizedKeyFile(key *PublicKey) error {
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	if finfo.Mode().Perm() > 0600 {
-		log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", finfo.Mode().Perm().String())
-		if err = f.Chmod(0600); err != nil {
-			return err
+
+	// FIXME: following command does not support in Windows.
+	if !setting.IsWindows {
+		if finfo.Mode().Perm() > 0600 {
+			log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", finfo.Mode().Perm().String())
+			if err = f.Chmod(0600); err != nil {
+				return err
+			}
 		}
 		}
 	}
 	}
 
 

+ 7 - 2
models/repo.go

@@ -95,8 +95,13 @@ func NewRepoContext() {
 	if err != nil {
 	if err != nil {
 		log.Fatal(4, "Fail to get Git version: %v", err)
 		log.Fatal(4, "Fail to get Git version: %v", err)
 	}
 	}
-	if ver.Major < 2 && ver.Minor < 8 {
-		log.Fatal(4, "Gogs requires Git version greater or equal to 1.8.0")
+
+	reqVer, err := git.ParseVersion("1.7.1")
+	if err != nil {
+		log.Fatal(4, "Fail to parse required Git version: %v", err)
+	}
+	if ver.LessThan(reqVer) {
+		log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1")
 	}
 	}
 
 
 	// Check if server has basic git setting and set if not.
 	// Check if server has basic git setting and set if not.

+ 8 - 0
modules/git/repo_commit.go

@@ -137,6 +137,14 @@ func (repo *Repository) GetCommit(commitId string) (*Commit, error) {
 }
 }
 
 
 func (repo *Repository) commitsCount(id sha1) (int, error) {
 func (repo *Repository) commitsCount(id sha1) (int, error) {
+	if gitVer.LessThan(MustParseVersion("1.8.0")) {
+		stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", "--pretty=format:''", id.String())
+		if err != nil {
+			return 0, errors.New(string(stderr))
+		}
+		return len(bytes.Split(stdout, []byte("\n"))), nil
+	}
+
 	stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "rev-list", "--count", id.String())
 	stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "rev-list", "--count", id.String())
 	if err != nil {
 	if err != nil {
 		return 0, errors.New(stderr)
 		return 0, errors.New(stderr)

+ 64 - 12
modules/git/version.go

@@ -11,33 +11,85 @@ import (
 	"github.com/Unknwon/com"
 	"github.com/Unknwon/com"
 )
 )
 
 
+var (
+	// Cached Git version.
+	gitVer *Version
+)
+
 // Version represents version of Git.
 // Version represents version of Git.
 type Version struct {
 type Version struct {
 	Major, Minor, Patch int
 	Major, Minor, Patch int
 }
 }
 
 
-// GetVersion returns current Git version installed.
-func GetVersion() (Version, error) {
-	stdout, stderr, err := com.ExecCmd("git", "version")
-	if err != nil {
-		return Version{}, errors.New(stderr)
-	}
-
-	infos := strings.Split(stdout, " ")
+func ParseVersion(verStr string) (*Version, error) {
+	infos := strings.Split(verStr, ".")
 	if len(infos) < 3 {
 	if len(infos) < 3 {
-		return Version{}, errors.New("not enough output")
+		return nil, errors.New("incorrect version input")
 	}
 	}
 
 
-	v := Version{}
-	for i, s := range strings.Split(strings.TrimSpace(infos[2]), ".") {
+	v := &Version{}
+	for i, s := range infos {
 		switch i {
 		switch i {
 		case 0:
 		case 0:
 			v.Major, _ = com.StrTo(s).Int()
 			v.Major, _ = com.StrTo(s).Int()
 		case 1:
 		case 1:
 			v.Minor, _ = com.StrTo(s).Int()
 			v.Minor, _ = com.StrTo(s).Int()
 		case 2:
 		case 2:
-			v.Patch, _ = com.StrTo(s).Int()
+			v.Patch, _ = com.StrTo(strings.TrimSpace(s)).Int()
 		}
 		}
 	}
 	}
 	return v, nil
 	return v, nil
 }
 }
+
+func MustParseVersion(verStr string) *Version {
+	v, _ := ParseVersion(verStr)
+	return v
+}
+
+// Compare compares two versions,
+// it returns 1 if original is greater, -1 if original is smaller, 0 if equal.
+func (v *Version) Compare(that *Version) int {
+	if v.Major > that.Major {
+		return 1
+	} else if v.Major < that.Major {
+		return -1
+	}
+
+	if v.Minor > that.Minor {
+		return 1
+	} else if v.Minor < that.Minor {
+		return -1
+	}
+
+	if v.Patch > that.Patch {
+		return 1
+	} else if v.Patch < that.Patch {
+		return -1
+	}
+
+	return 0
+}
+
+func (v *Version) LessThan(that *Version) bool {
+	return v.Compare(that) < 0
+}
+
+// GetVersion returns current Git version installed.
+func GetVersion() (*Version, error) {
+	if gitVer != nil {
+		return gitVer, nil
+	}
+
+	stdout, stderr, err := com.ExecCmd("git", "version")
+	if err != nil {
+		return nil, errors.New(stderr)
+	}
+
+	infos := strings.Split(stdout, " ")
+	if len(infos) < 3 {
+		return nil, errors.New("not enough output")
+	}
+
+	gitVer, err = ParseVersion(infos[2])
+	return gitVer, err
+}

+ 3 - 0
modules/setting/setting.go

@@ -10,6 +10,7 @@ import (
 	"os/exec"
 	"os/exec"
 	"path"
 	"path"
 	"path/filepath"
 	"path/filepath"
+	"runtime"
 	"strings"
 	"strings"
 	"time"
 	"time"
 
 
@@ -99,12 +100,14 @@ var (
 	CustomPath   string // Custom directory path.
 	CustomPath   string // Custom directory path.
 	ProdMode     bool
 	ProdMode     bool
 	RunUser      string
 	RunUser      string
+	IsWindows    bool
 
 
 	// I18n settings.
 	// I18n settings.
 	Langs, Names []string
 	Langs, Names []string
 )
 )
 
 
 func init() {
 func init() {
+	IsWindows = runtime.GOOS == "windows"
 	log.NewLogger(0, "console", `{"level": 0}`)
 	log.NewLogger(0, "console", `{"level": 0}`)
 }
 }
 
 

+ 2 - 2
public/ng/css/gogs.css

@@ -686,7 +686,7 @@ ol.linenums {
   width: auto;
   width: auto;
 }
 }
 /*
 /*
-The dashboard page style
+    The dashboard page style
 */
 */
 #dashboard-header {
 #dashboard-header {
   border-bottom: 1px solid #d6d6d6;
   border-bottom: 1px solid #d6d6d6;
@@ -1032,7 +1032,7 @@ The register and sign-in page style
 }
 }
 #repo-clone-url {
 #repo-clone-url {
   border-right: none;
   border-right: none;
-  width: 200px;
+  width: 190px;
   border-left: none;
   border-left: none;
 }
 }
 #repo-clone-help {
 #repo-clone-help {

+ 1 - 3
public/ng/less/gogs/dashboard.less

@@ -1,9 +1,7 @@
 @import "../ui/var";
 @import "../ui/var";
-
 /*
 /*
-The dashboard page style
+    The dashboard page style
 */
 */
-
 @dashboardHeaderBorderColor: #D6D6D6;
 @dashboardHeaderBorderColor: #D6D6D6;
 @dashboardHeaderLinkColor: #444;
 @dashboardHeaderLinkColor: #444;
 @dashboardHeaderLinkHoverColor: #D9453D;
 @dashboardHeaderLinkHoverColor: #D9453D;

+ 1 - 1
public/ng/less/gogs/repository.less

@@ -95,7 +95,7 @@ background-color: @repoHeaderBgColor;
 }
 }
 #repo-clone-url {
 #repo-clone-url {
 	border-right: none;
 	border-right: none;
-	width: 200px;
+	width: 190px;
 	border-left: none;
 	border-left: none;
 }
 }
 #repo-clone-help {
 #repo-clone-help {

+ 1 - 1
routers/user/auth.go

@@ -280,7 +280,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe
 		ctx.Data["IsSendRegisterMail"] = true
 		ctx.Data["IsSendRegisterMail"] = true
 		ctx.Data["Email"] = u.Email
 		ctx.Data["Email"] = u.Email
 		ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
 		ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
-		ctx.HTML(200, "user/activate")
+		ctx.HTML(200, ACTIVATE)
 
 
 		if err := ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
 		if err := ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
 			log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
 			log.Error(4, "Set cache(MailResendLimit) fail: %v", err)

+ 1 - 1
routers/user/home.go

@@ -94,7 +94,7 @@ func Dashboard(ctx *middleware.Context) {
 	feeds := make([]*models.Action, 0, len(actions))
 	feeds := make([]*models.Action, 0, len(actions))
 	for _, act := range actions {
 	for _, act := range actions {
 		if act.IsPrivate {
 		if act.IsPrivate {
-			if has, _ := models.HasAccess(ctxUser.Name, act.RepoUserName+"/"+act.RepoName,
+			if has, _ := models.HasAccess(ctx.User.Name, act.RepoUserName+"/"+act.RepoName,
 				models.READABLE); !has {
 				models.READABLE); !has {
 				continue
 				continue
 			}
 			}

+ 18 - 0
scripts/systemd/gogs.service

@@ -0,0 +1,18 @@
+[Unit]
+Description=Gogs (Go Git Service) server
+After=syslog.target
+After=network.target
+#After=mysqld.service
+#After=postgresql.service
+#After=memcached.service
+#After=redis.service
+
+[Service]
+Type=simple
+User=git
+Group=git
+ExecStart=/home/git/gogs/gogs/start.sh
+WorkingDirectory=/home/git/gogs
+
+[Install]
+WantedBy=multi-user.target

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.5.0.0913 Beta
+0.5.2.0916 Beta

+ 1 - 1
templates/repo/release/list.tmpl

@@ -29,7 +29,7 @@
                     <p class="info">
                     <p class="info">
                         <span class="author"><img class="avatar" src="{{.Publisher.AvatarLink}}" alt="" width="20">&nbsp;&nbsp;
                         <span class="author"><img class="avatar" src="{{.Publisher.AvatarLink}}" alt="" width="20">&nbsp;&nbsp;
                         <a href="/user/{{.Publisher.Name}}">{{.Publisher.Name}}</a></span>
                         <a href="/user/{{.Publisher.Name}}">{{.Publisher.Name}}</a></span>
-                        {{if .Created}}<span class="time">{{TimeSince .Created}}</span>{{end}}
+                        {{if .Created}}<span class="time">{{TimeSince .Created $.Lang}}</span>{{end}}
                         <span class="ahead"><strong>{{.NumCommitsBehind}}</strong> commits to {{.Target}} since this release</span>
                         <span class="ahead"><strong>{{.NumCommitsBehind}}</strong> commits to {{.Target}} since this release</span>
                     </p>
                     </p>
                     <div class="markdown desc">
                     <div class="markdown desc">

+ 2 - 2
templates/user/dashboard/dashboard.tmpl

@@ -9,7 +9,7 @@
                 <div class="avatar left">
                 <div class="avatar left">
                     <img class="avatar-30" src="{{AvatarLink .GetActEmail}}" alt="">
                     <img class="avatar-30" src="{{AvatarLink .GetActEmail}}" alt="">
                 </div>
                 </div>
-                <div class="content left {{if eq .GetOpType 5}}push-news{{end}}">
+                <div class="content left {{if eq .GetOpType 5}}push-news{{end}} grid-4-5">
                     <p class="text-bold">
                     <p class="text-bold">
                         <a href="/{{.GetActUserName}}">{{.GetActUserName}}</a>
                         <a href="/{{.GetActUserName}}">{{.GetActUserName}}</a>
                         {{if eq .GetOpType 1}}
                         {{if eq .GetOpType 1}}
@@ -30,7 +30,7 @@
                             {{ $push := ActionContent2Commits .}}
                             {{ $push := ActionContent2Commits .}}
                             {{ $repoLink := .GetRepoLink}}
                             {{ $repoLink := .GetRepoLink}}
                             {{range $push.Commits}}
                             {{range $push.Commits}}
-                            <li><img class="avatar-16" src="{{AvatarLink .AuthorEmail}}?s=16"> <a href="/{{$repoLink}}/commit/{{.Sha1}}">{{ShortSha .Sha1}}</a> {{.Message}}</li>
+                            <li><img class="avatar-16" src="{{AvatarLink .AuthorEmail}}?s=16"> <a href="/{{$repoLink}}/commit/{{.Sha1}}">{{ShortSha .Sha1}}</a> <span class="text-truncate grid-4-5">{{.Message}}</span></li>
                             {{end}}
                             {{end}}
                         </ul>
                         </ul>
                     </div>
                     </div>