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

This commit is contained in:
FuXiaoHei 2014-05-01 20:57:11 +08:00
commit cc1eb5643e
24 changed files with 56 additions and 140 deletions

View file

@ -24,10 +24,10 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
## Overview
- Please see [Wiki](https://github.com/gogits/gogs/wiki) 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.
- Try it before anything? Do it [online](http://try.gogits.org/Unknown/gogs) or go down to **Installation -> Install from binary** section!
- Having troubles? Get help from [Troubleshooting](https://github.com/gogits/gogs/wiki/Troubleshooting).
- Having troubles? Get help from [Troubleshooting](http://gogs.io/docs/intro/troubleshooting.md).
## Features
@ -49,12 +49,12 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
## Installation
Make sure you install [Prerequirements](https://github.com/gogits/gogs/wiki/Prerequirements) first.
Make sure you install [Prerequirements](http://gogs.io/docs/installation/) first.
There are 3 ways to install Gogs:
- [Install from binary](https://github.com/gogits/gogs/wiki/Install-from-binary): **STRONGLY RECOMMENDED**
- [Install from source](https://github.com/gogits/gogs/wiki/Install-from-source)
- [Install from binary](http://gogs.io/docs/installation/install_from_binary.md): **STRONGLY RECOMMENDED**
- [Install from source](http://gogs.io/docs/installation/install_from_source.md)
- [Ship with Docker](https://github.com/gogits/gogs/tree/master/dockerfiles)
## Acknowledgments

View file

@ -15,10 +15,10 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
## 项目概览
- 有关项目设计、已知问题和变更日志,请通过 [Wiki](https://github.com/gogits/gogs/wiki) 查看。
- 有关项目设计、已知问题和变更日志,请通过 [使用手册](http://gogs.io/docs/intro/) 查看。
- 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
- 想要先睹为快?通过 [在线体验](http://try.gogits.org/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。
- 使用过程中遇到问题?尝试从 [故障排查](https://github.com/gogits/gogs/wiki/Troubleshooting) 页面获取帮助。
- 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.md) 页面获取帮助。
## 功能特性
@ -41,12 +41,12 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
## 安装部署
在安装 Gogs 之前,您需要先安装 [基本环境](https://github.com/gogits/gogs/wiki/Prerequirements)。
在安装 Gogs 之前,您需要先安装 [基本环境](http://gogs.io/docs/installation/)。
然后,您可以通过以下 3 种方式来安装 Gogs
- [二进制安装](https://github.com/gogits/gogs/wiki/Install-from-binary): **强烈推荐**
- [源码安装](https://github.com/gogits/gogs/wiki/Install-from-source)
- [二进制安装](http://gogs.io/docs/installation/install_from_binary.md): **强烈推荐**
- [源码安装](http://gogs.io/docs/installation/install_from_source.md)
- [采用 Docker 部署](https://github.com/gogits/gogs/tree/master/dockerfiles)
## 特别鸣谢

View file

@ -15,11 +15,9 @@ LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0|
[server]
PROTOCOL = http
DOMAIN = localhost
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:3000/
; Disable CDN even in "prod" mode
OFFLINE_MODE = false
HTTP_ADDR =
HTTP_PORT = 3000
; Generate steps:
; $ cd path/to/gogs/custom/https
; $ go run $GOROOT/src/pkg/crypto/tls/generate_cert.go -ca=true -duration=8760h0m0s -host=myhost.example.com

View file

@ -1,26 +0,0 @@
### Binary install gogs on ubuntu 14.04 LTS
### create user and install denpendency
- sudo adduser git
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get install git
- sudo apt-get install mysql-server
### create the database
- $mysql -u root -p
- mysql> SET GLOBAL storage_engine = 'InnoDB';
- mysql> CREATE DATABASE gogs CHARACTER SET utf8 COLLATE utf8_bin;
- mysql> GRANT ALL PRIVILEGES ON gogs.* TO 'root'@'localhost' IDENTIFIED BY 'password';
- mysql> FLUSH PRIVILEGES;
- mysql> QUIT
### install the gogs
- mkdir gogs
- cd gogs
- curl -L http://gobuild.io/github.com/gogits/gogs/v0.3.0/linux/amd64 -o v0.3.0.zip
- unzip v0.3.0.zip
- ./start.sh
> The up-to-date binary could be found at
> http://gobuild.io/download/github.com/gogits/gogs

View file

@ -1,48 +0,0 @@
##Install gogs under ubuntu 14.04 LTS 32bit from source code
###Requirements
- Go Programming Language: Version >= 1.2
- git(bash): Version >= 1.6.6(both server and client)
- MySQL: Version >= 5.1 or PostgreSQL or NOTHING.
### Create the user which will run git
- sudo adduser git
- su git
### Install git and Mysql-server
- sudo apt-get install git
- sudo apt-get install mysql-server
### Create database
- $ mysql -u root -p
- mysql> SET GLOBAL storage_engine = 'InnoDB';
- mysql> CREATE DATABASE gogs CHARACTER SET utf8 COLLATE utf8_bin;
- mysql> GRANT ALL PRIVILEGES ON gogs.* TO 'root'@'localhost' IDENTIFIED BY 'pasword';
- mysql> FLUSH PRIVILEGES;
- mysql> QUIT
### install go from source
- sudo apt-get install build-essential
- sudo apt-get install mercurial
- hg clone -r release https://go.googlecode.com/hg/ /home/git/golang/
- echo export GOROOT=/home/git/golang >>.bashrc
- echo export GOARCH=386 >>.bashrc
- echo export GOOS=linux >>.bashrc
- echo export GOBIN= /home/git/golang/bin >>.bashrc
- echo export GOPATH=$HOME/app/Go >>.bashrc
- echo PATH=${PATH}: /$HOME/golang/bin >>.bashrc
- cd $GOROOT/src
- ./make.bash
### Download and install dependencies
- $ go get -u github.com/gogits/gogs
### Build main program
- $ cd $GOPATH/src/github.com/gogits/gogs
- $ go build
- $ ./start.sh
### At present, you could access gogs from http://localhost:3000

View file

@ -1,29 +0,0 @@
# Configs of the docker images, you might have specify your own configs here.
# type of database, support 'mysql' and 'postgres'
DB_TYPE="postgres"
DB_PASSWORD="YOUR_DB_PASSWORD"
DB_RUN_NAME="YOUR_DB_RUN_NAME"
HOST_PORT="YOUR_HOST_PORT"
# Replace the database root password in database image Dockerfile.
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/$DB_TYPE/Dockerfile
# Replace the database root password in gogits image deploy.sh file.
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/gogits/deploy.sh
# Replace the database type in gogits image deploy.sh file.
sed -i "s/THE_DB_TYPE/$DB_TYPE/g" images/gogits/deploy.sh
# Build the database image
cd images/$DB_TYPE
docker build -t gogs/$DB_TYPE .
#
## Build the gogits image
cd ../gogits
docker build -t gogs/gogits .
#
## Run MySQL image with name
docker run -d --name $DB_RUN_NAME gogs/$DB_TYPE
#
## Run gogits image and link it to the database image
echo "Now we have the $DB_TYPE image(running) and gogs image, use the follow command to start gogs service:"
echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db -p $HOST_PORT:3000 gogs/gogits \033[0m"

View file

@ -1,8 +1,6 @@
FROM stackbrew/ubuntu:13.10
MAINTAINER Meaglith Ma <genedna@gmail.com> (@genedna)
ENV DEBIAN_FRONTEND noninteractive
#aliyun#RUN echo "deb http://mirrors.aliyun.com/ubuntu/ saucy main restricted" > /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-updates main restricted" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy universe" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-updates universe" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy multiverse" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-updates multiverse" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-backports main restricted universe multiverse" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-security main restricted" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-security universe" >> /etc/apt/sources.list && echo "deb http://mirrors.aliyun.com/ubuntu/ saucy-security multiverse" >> /etc/apt/sources.list
#nchc#RUN echo "deb http://free.nchc.org.tw/ubuntu/ saucy main restricted" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy main restricted" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-updates main restricted" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-updates main restricted" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy universe" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy universe" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-updates universe" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-updates universe" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy multiverse" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-updates multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-updates multiverse" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-backports main restricted universe multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-backports main restricted universe multiverse" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-security main restricted" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-security main restricted" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-security universe" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-security universe" >> /etc/apt/source.list && echo "deb http://free.nchc.org.tw/ubuntu/ saucy-security multiverse" >> /etc/apt/source.list && echo "deb-src http://free.nchc.org.tw/ubuntu/ saucy-security multiverse" >> /etc/apt/source.list && echo "deb http://extras.ubuntu.com/ubuntu saucy main" >> /etc/apt/source.list && echo "deb-src http://extras.ubuntu.com/ubuntu saucy main" >> /etc/apt/source.list

View file

@ -3,8 +3,6 @@ FROM ubuntu
# Set the file maintainer (your name - the file's author)
MAINTAINER Borja Burgos <borja@tutum.co>
ENV DEBIAN_FRONTEND noninteractive
# Update the default application repository sources list
RUN apt-get update

View file

@ -3,8 +3,6 @@
FROM stackbrew/ubuntu:saucy
MAINTAINER Meaglith Ma <genedna@gmail.com> (@genedna)
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get install -y --force-yes software-properties-common
RUN add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
RUN apt-get --yes --force-yes update

View file

@ -1,8 +1,6 @@
FROM ubuntu
MAINTAINER SvenDowideit@docker.com
ENV DEBIAN_FRONTEND noninteractive
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8

View file

@ -1,8 +1,6 @@
FROM stackbrew/ubuntu:saucy
MAINTAINER Meaglith Ma <genedna@gmail.com> (@genedna), Lance Ju <juzhenatpku@gmail.com> (@crystaldust)
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y redis-server
# Usually redis doesn't need a password
#RUN sed -i "s/# requirepass foobared/requirepass THE_REDIS_PASSWORD/g" /etc/redis/redis.conf

View file

@ -19,7 +19,7 @@ import (
// Test that go1.2 tag above is included in builds. main.go refers to this definition.
const go12tag = true
const APP_VER = "0.3.1.0430 Alpha"
const APP_VER = "0.3.1.0501 Alpha"
func init() {
base.AppVer = APP_VER

View file

@ -88,12 +88,6 @@ func CommitRepoAction(userId int64, userName, actEmail string,
return err
}
if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail,
OpType: opType, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
return err
}
// Change repository bare status and update last updated time.
repo, err := GetRepositoryByName(userId, repoName)
if err != nil {
@ -106,12 +100,24 @@ func CommitRepoAction(userId int64, userName, actEmail string,
return err
}
if !repo.IsPrivate {
if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail,
OpType: opType, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
return err
}
}
log.Trace("action.CommitRepoAction(end): %d/%s", userId, repoName)
return nil
}
// NewRepoAction adds new action for creating repository.
func NewRepoAction(user *User, repo *Repository) (err error) {
if repo.IsPrivate {
return nil
}
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name}); err != nil {
log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
@ -124,6 +130,10 @@ func NewRepoAction(user *User, repo *Repository) (err error) {
// TransferRepoAction adds new action for transfering repository.
func TransferRepoAction(user, newUser *User, repo *Repository) (err error) {
if repo.IsPrivate {
return nil
}
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
OpType: OP_TRANSFER_REPO, RepoId: repo.Id, RepoName: repo.Name, Content: newUser.Name}); err != nil {
log.Error("action.TransferRepoAction(notify watchers): %d/%s", user.Id, repo.Name)

View file

@ -46,6 +46,7 @@ type User struct {
Id int64
LowerName string `xorm:"unique not null"`
Name string `xorm:"unique not null"`
FullName string
Email string `xorm:"unique not null"`
Passwd string `xorm:"not null"`
LoginType int

View file

@ -21,7 +21,7 @@ type Form interface {
}
type RegisterForm struct {
UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
UserName string `form:"username" binding:"Required;AlphaDashDot;MaxSize(30)"`
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"`
RetypePasswd string `form:"retypepasswd"`
@ -123,6 +123,8 @@ func validate(errors *base.BindingErrors, data base.TmplData, form Form) {
data["ErrorMsg"] = form.Name(field.Name) + " cannot be empty"
case base.BindingAlphaDashError:
data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) characters"
case base.BindingAlphaDashDotError:
data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) or dot characters"
case base.BindingMinSizeError:
data["ErrorMsg"] = form.Name(field.Name) + " must contain at least " + getMinMaxSize(field) + " characters"
case base.BindingMaxSizeError:
@ -174,7 +176,7 @@ type InstallForm struct {
RunUser string `form:"run_user"`
Domain string `form:"domain"`
AppUrl string `form:"app_url"`
AdminName string `form:"admin_name" binding:"Required"`
AdminName string `form:"admin_name" binding:"Required;AlphaDashDot;MaxSize(30)"`
AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(30)"`
AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"`
SmtpHost string `form:"smtp_host"`

View file

@ -75,6 +75,7 @@ type FeedsForm struct {
type UpdateProfileForm struct {
UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
FullName string `form:"fullname" binding:"MaxSize(40)"`
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
Website string `form:"website" binding:"MaxSize(50)"`
Location string `form:"location" binding:"MaxSize(50)"`

View file

@ -45,6 +45,7 @@ func (this *BindingErrors) Combine(other BindingErrors) {
const (
BindingRequireError string = "Required"
BindingAlphaDashError string = "AlphaDash"
BindingAlphaDashDotError string = "AlphaDashDot"
BindingMinSizeError string = "MinSize"
BindingMaxSizeError string = "MaxSize"
BindingEmailError string = "Email"

View file

@ -180,9 +180,10 @@ func Validate(obj interface{}) martini.Handler {
}
var (
alphaDashPattern = regexp.MustCompile("[^\\d\\w-_]")
emailPattern = regexp.MustCompile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?")
urlPattern = regexp.MustCompile(`(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?`)
alphaDashPattern = regexp.MustCompile("[^\\d\\w-_]")
alphaDashDotPattern = regexp.MustCompile("[^\\d\\w-_\\.]")
emailPattern = regexp.MustCompile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?")
urlPattern = regexp.MustCompile(`(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?`)
)
func validateStruct(errors *base.BindingErrors, obj interface{}) {
@ -227,6 +228,11 @@ func validateStruct(errors *base.BindingErrors, obj interface{}) {
errors.Fields[field.Name] = base.BindingAlphaDashError
break
}
case rule == "AlphaDashDot":
if alphaDashDotPattern.MatchString(fmt.Sprintf("%v", fieldValue)) {
errors.Fields[field.Name] = base.BindingAlphaDashDotError
break
}
case strings.HasPrefix(rule, "MinSize("):
min, err := strconv.Atoi(rule[8 : len(rule)-1])
if err != nil {

View file

@ -21,5 +21,6 @@ func TemplatePreview(ctx *middleware.Context, params martini.Params) {
ctx.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374"
ctx.Data["ActiveCodeLives"] = base.Service.ActiveCodeLives / 60
ctx.Data["ResetPwdCodeLives"] = base.Service.ResetPwdCodeLives / 60
ctx.Data["CurDbValue"] = ""
ctx.HTML(200, params["_1"])
}

View file

@ -54,6 +54,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
user.Name = form.UserName
}
user.FullName = form.FullName
user.Email = form.Email
user.Website = form.Website
user.Location = form.Location

View file

@ -15,7 +15,7 @@
</div>
<div class="col-md-4">
<p class="desc"><a href="http://gogits.org">Official Website</a></p>
<p class="desc"><a href="http://gogs.io">Official Website</a></p>
</div>
</div>
</div>

View file

@ -3,7 +3,7 @@
<nav class="nav">
<a id="nav-logo" class="nav-item pull-left{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="logo"></a>
<a class="nav-item pull-left{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a>
<a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" target="_blank" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}}
<a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" target="_blank" href="http://gogs.io/docs">Help</a>{{if .IsSigned}}
{{if .HasAccess}}<form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form">
<div class="input-group">
<div class="input-group-btn">

View file

@ -6,6 +6,7 @@
<a href="http://gravatar.com/emails/" class="center-block" data-toggle="tooltip" data-placement="bottom" title="Change your avatar at gravatar.com">
<img id="user-avatar" src="{{.Owner.AvatarLink}}?s=200" alt="user-avatar" title="{{.Owner.Name}}"/>
</a>
{{if .Owner.FullName}}<span id="user-name" class="center-block">{{.Owner.FullName}}</span>{{end}}
<span id="user-name" class="center-block">{{.Owner.Name}}</span>
</div>
<div class="profile-info">

View file

@ -17,6 +17,13 @@
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Full Name</label>
<div class="col-md-8">
<input name="fullname" class="form-control" placeholder="Type your full name" value="{{.SignedUser.FullName}}">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Email<strong class="text-danger">*</strong></label>
<div class="col-md-8">