Skip to content

Commit e2feb3b

Browse files
author
Phil Hopper
authored
Merge pull request go-gitea#138 from ethantkoenig/ufw_develop
Revert "Changes from gitea:master (go-gitea#130)" and readd latest gitea changes
2 parents 17b247f + f761a3e commit e2feb3b

File tree

1,194 files changed

+229927
-2077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,194 files changed

+229927
-2077
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ coverage.out
4242
/dist
4343
/custom
4444
/data
45+
/indexers
4546
/log
4647
/public/img/avatar
4748

CONTRIBUTING.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Please search the issues on the issue tracker with a variety of keywords to ensu
1010

1111
If unique, [open an issue](https://github.com/go-gitea/gitea/issues/new) and answer the questions so we can understand and reproduce the problematic behavior.
1212

13-
The burden is on you to convince us that it is actually a bug in Gitea. This is easiest to do when you write clear, concise instructions so we can reproduce the behavior (even if it seems obvious). The more detailed and specific you are, the faster we will be able to help you. Check out [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
13+
To show us that the issue you are having is in Gitea itself, please write clear, concise instructions so we can reproduce the behavior (even if it seems obvious). The more detailed and specific you are, the faster we can fix the issue. Check out [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
1414

1515
Please be kind, remember that Gitea comes at no cost to you, and you're getting free help.
1616

@@ -24,7 +24,7 @@ This process gives everyone a chance to validate the design, helps prevent dupli
2424

2525
## Testing redux
2626

27-
Before sending code out for review, run all the tests for the whole tree to make sure the changes don't break other usage and keep the compatibility on upgrade. To make sure you are running the test suite exactly like we do you should install the CLI for [Drone CI](https://github.com/drone/drone), as we are using the server for continous testing, following [these instructions](http://readme.drone.io/0.5/install/cli/). After that you can simply call `drone exec` within your working directory and it will try to run the test suite locally.
27+
Before sending code out for review, run all the tests for the whole tree to make sure the changes don't break other usage and keep the compatibility on upgrade. To make sure you are running the test suite exactly like we do, you should install the CLI for [Drone CI](https://github.com/drone/drone), as we are using the server for continous testing, following [these instructions](http://readme.drone.io/0.5/install/cli/). After that you can simply call `drone exec` within your working directory and it will try to run the test suite locally.
2828

2929
## Code review
3030

@@ -34,7 +34,7 @@ Please try to make your pull request easy to review for us. Please read the "[Ho
3434

3535
* Make small pull requests. The smaller, the faster to review and the more likely it will be merged soon.
3636
* Don't make changes unrelated to your PR. Maybe there are typos on some comments, maybe refactoring would be welcome on a function... but if that is not related to your PR, please make *another* PR for that.
37-
* Split big pull requests in multiple small ones. An incremental change will be faster to review than a huge PR.
37+
* Split big pull requests into multiple small ones. An incremental change will be faster to review than a huge PR.
3838

3939
## Sign your work
4040

@@ -44,20 +44,20 @@ The sign-off is a simple line at the end of the explanation for the patch. Your
4444
Signed-off-by: Joe Smith <[email protected]>
4545
```
4646

47-
Please use your real name, we really dislike pseudonyms or anonymous contributions. We are in the opensource world without secrets. If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with `git commit -s`.
47+
Please use your real name, we really dislike pseudonyms or anonymous contributions. We are in the open-source world without secrets. If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with `git commit -s`.
4848

4949
## Maintainers
5050

51-
To make sure every PR is checked, we got team maintainers. Every PR **MUST** be reviewed by at least two maintainers (or owners) before it can get merged. A maintainer should be a contributor of Gitea (or Gogs) and contributed at least 4 accepted PRs. A contributor should apply as a maintainer in the [Gitter develop channel](https://gitter.im/go-gitea/develop). The owners or the team maintainers may invite the contributor. A maintainer should spend some time on code reviews. If a maintainer has no time to do that, they should apply to leave the maintainers team and we will give them the honor of being a member of the advisors team. Of course, if an advisor has time to code review, we will gladly welcome them back to maintainers team. If someone has no time to code review and forgets to leave the maintainers team, the owners have the power to move him from maintainers team to advisors team.
51+
To make sure every PR is checked, we have [team maintainers](https://github.com/orgs/go-gitea/teams/maintainers). Every PR **MUST** be reviewed by at least two maintainers (or owners) before it can get merged. A maintainer should be a contributor of Gitea (or Gogs) and contributed at least 4 accepted PRs. A contributor should apply as a maintainer in the [Gitter develop channel](https://gitter.im/go-gitea/develop). The owners or the team maintainers may invite the contributor. A maintainer should spend some time on code reviews. If a maintainer has no time to do that, they should apply to leave the maintainers team and we will give them the honor of being a member of the [advisors team](https://github.com/orgs/go-gitea/teams/advisors). Of course, if an advisor has time to code review, we will gladly welcome them back to the maintainers team. If a maintainer is inactive for more than 3 months and forgets to leave the maintainers team, the owners may move him or her from the maintainers team to the advisors team.
5252

5353
## Owners
5454

55-
Since Gitea is a pure community organization without any company support, to keep the development healthy we will elect the owners every year. Every time we will elect three owners. All the contributors may vote up to three people, one of which is the main owner, and the others are assistant owners. When the new owners have been elected, the old owners MUST move the power to the new ones. If an owner don't obey these rules, the others are allowed to revoke his owner status.
55+
Since Gitea is a pure community organization without any company support, to keep the development healthy we will elect three owners every year. All contributors may vote to elect up to three candidates, one of which will be the main owner, and the other two the assistant owners. When the new owners have been elected, the old owners will give up ownership to the newly elected owners. If an owner is unable to do so, the other owners will assist in ceding ownership to the newly elected owners.
5656

57-
After the election, the new owners should say they agree with these rules on the [CONTRIBUTING](CONTRIBUTING.md) on the [Gitter main channel](https://gitter.im/go-gitea/gitea). Below are the words to speak:
57+
After the election, the new owners should proactively agree with our [CONTRIBUTING](CONTRIBUTING.md) requirements on the [Gitter main channel](https://gitter.im/go-gitea/gitea). Below are the words to speak:
5858

5959
```
60-
I'm glad to be an owner of Gitea, I agree with [CONTRIBUTING](CONTRIBUTING.md). I will spend part of my time on Gitea and lead the development of Gitea.
60+
I'm honored to having been elected an owner of Gitea, I agree with [CONTRIBUTING](CONTRIBUTING.md). I will spend part of my time on Gitea and lead the development of Gitea.
6161
```
6262

6363
To honor the past owners, here's the history of the owners and the time they served:
@@ -78,7 +78,7 @@ Since the `master` branch is a tip version, if you wish to use Gitea in producti
7878
Code that you contribute should use the standard copyright header:
7979

8080
```
81-
// Copyright 2016 The Gitea Authors. All rights reserved.
81+
// Copyright 2017 The Gitea Authors. All rights reserved.
8282
// Use of this source code is governed by a MIT-style
8383
// license that can be found in the LICENSE file.
8484
```

MAINTAINERS

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Alexey Makhov <[email protected]> (@makhov)
22
Andrey Nering <[email protected]> (@andreynering)
33
Bo-Yi Wu <[email protected]> (@appleboy)
4+
Ethan Koenig <[email protected]> (@ethantkoenig)
45
Kees de Vries <[email protected]> (@Bwko)
56
Kim Carlbäcker <[email protected]> (@bkcsoft)
67
LefsFlare <[email protected]> (@LefsFlarey)

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BINDATA := modules/{options,public,templates}/bindata.go
1111
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
1212
JAVASCRIPTS :=
1313

14-
LDFLAGS += -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')"
14+
LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')"
1515

1616
TARGETS ?= linux/*,darwin/*,windows/*
1717
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
[简体中文](https://github.com/go-gitea/gitea/blob/master/README_ZH.md)
21
# Gitea - Git with a cup of tea - Door43 Version
32

43
[![Build Status](https://travis-ci.org/unfoldingWord-dev/gogs.svg?branch=master)](https://travis-ci.org/unfoldingWord-dev/gogs)
54
[![Join the chat at https://gitter.im/go-gitea/gitea](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-gitea/gitea?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](https://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
66
[![Coverage Status](https://codecov.io/gh/unfoldingWord-dev/gogs/branch/master/graph/badge.svg)](https://codecov.io/gh/unfoldingWord-dev/gogs)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/unfoldingWord-dev)](https://goreportcard.com/report/github.com/unfoldingWord-dev/gogs)
88
[![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea)
9-
[![Release](http://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest)
9+
[![Release](https://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest)
1010

1111
[![](public/img/door43.png)](https://git.door43.org)
1212

README_ZH.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
# Gitea - Git with a cup of tea
44

5-
[![Build Status](http://drone.gitea.io/api/badges/go-gitea/gitea/status.svg)](http://drone.gitea.io/go-gitea/gitea)
5+
[![Build Status](https://drone.gitea.io/api/badges/go-gitea/gitea/status.svg)](https://drone.gitea.io/go-gitea/gitea)
66
[![Join the chat at https://gitter.im/go-gitea/gitea](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-gitea/gitea?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7-
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](http://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
7+
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](https://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
88
[![Coverage Status](https://coverage.gitea.io/badges/go-gitea/gitea/coverage.svg)](https://coverage.gitea.io/go-gitea/gitea)
99
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/gitea)](https://goreportcard.com/report/code.gitea.io/gitea)
1010
[![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea)
11-
[![Release](http://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest)
11+
[![Release](https://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest)
1212

1313
||||
1414
|:-------------:|:-------:|:-------:|

cmd/dump.go

+58-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"log"
1212
"os"
1313
"path"
14+
"path/filepath"
1415
"time"
1516

1617
"code.gitea.io/gitea/models"
@@ -53,8 +54,13 @@ func runDump(ctx *cli.Context) error {
5354
setting.CustomConf = ctx.String("config")
5455
}
5556
setting.NewContext()
57+
setting.NewServices() // cannot access session settings otherwise
5658
models.LoadConfigs()
57-
models.SetEngine()
59+
60+
err := models.SetEngine()
61+
if err != nil {
62+
return err
63+
}
5864

5965
tmpDir := ctx.String("tempdir")
6066
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
@@ -107,6 +113,20 @@ func runDump(ctx *cli.Context) error {
107113
} else {
108114
log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath)
109115
}
116+
117+
log.Printf("Packing data directory...%s", setting.AppDataPath)
118+
var sessionAbsPath string
119+
if setting.SessionConfig.Provider == "file" {
120+
if len(setting.SessionConfig.ProviderConfig) == 0 {
121+
setting.SessionConfig.ProviderConfig = "data/sessions"
122+
}
123+
sessionAbsPath, _ = filepath.Abs(setting.SessionConfig.ProviderConfig)
124+
}
125+
126+
if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil {
127+
log.Fatalf("Fail to include data directory: %v", err)
128+
}
129+
110130
if err := z.AddDir("log", setting.LogRootPath); err != nil {
111131
log.Fatalf("Fail to include log: %v", err)
112132
}
@@ -129,3 +149,40 @@ func runDump(ctx *cli.Context) error {
129149

130150
return nil
131151
}
152+
153+
// zipAddDirectoryExclude zips absPath to specified zipPath inside z excluding excludeAbsPath
154+
func zipAddDirectoryExclude(zip *zip.ZipArchive, zipPath, absPath string, excludeAbsPath string) error {
155+
absPath, err := filepath.Abs(absPath)
156+
if err != nil {
157+
return err
158+
}
159+
dir, err := os.Open(absPath)
160+
if err != nil {
161+
return err
162+
}
163+
defer dir.Close()
164+
165+
zip.AddEmptyDir(zipPath)
166+
167+
files, err := dir.Readdir(0)
168+
if err != nil {
169+
return err
170+
}
171+
for _, file := range files {
172+
currentAbsPath := path.Join(absPath, file.Name())
173+
currentZipPath := path.Join(zipPath, file.Name())
174+
if file.IsDir() {
175+
if currentAbsPath != excludeAbsPath {
176+
if err = zipAddDirectoryExclude(zip, currentZipPath, currentAbsPath, excludeAbsPath); err != nil {
177+
return err
178+
}
179+
}
180+
181+
} else {
182+
if err = zip.AddFile(currentZipPath, currentAbsPath); err != nil {
183+
return err
184+
}
185+
}
186+
}
187+
return nil
188+
}

cmd/web.go

+29-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ and it takes care of all the other things for you`,
6060
Value: "custom/conf/app.ini",
6161
Usage: "Custom configuration file path",
6262
},
63+
cli.StringFlag{
64+
Name: "pid, P",
65+
Value: "/var/run/gitea.pid",
66+
Usage: "Custom pid file path",
67+
},
6368
},
6469
}
6570

@@ -94,6 +99,7 @@ func newMacaron() *macaron.Macaron {
9499
macaron.StaticOptions{
95100
Prefix: "avatars",
96101
SkipLogging: setting.DisableRouterLog,
102+
ETag: true,
97103
},
98104
))
99105

@@ -156,6 +162,11 @@ func runWeb(ctx *cli.Context) error {
156162
if ctx.IsSet("config") {
157163
setting.CustomConf = ctx.String("config")
158164
}
165+
166+
if ctx.IsSet("pid") {
167+
setting.CustomPID = ctx.String("pid")
168+
}
169+
159170
routers.GlobalInit()
160171

161172
m := newMacaron()
@@ -193,6 +204,12 @@ func runWeb(ctx *cli.Context) error {
193204
m.Post("/sign_up", bindIgnErr(auth.RegisterForm{}), user.SignUpPost)
194205
m.Get("/reset_password", user.ResetPasswd)
195206
m.Post("/reset_password", user.ResetPasswdPost)
207+
m.Group("/two_factor", func() {
208+
m.Get("", user.TwoFactor)
209+
m.Post("", bindIgnErr(auth.TwoFactorAuthForm{}), user.TwoFactorPost)
210+
m.Get("/scratch", user.TwoFactorScratch)
211+
m.Post("/scratch", bindIgnErr(auth.TwoFactorScratchAuthForm{}), user.TwoFactorScratchPost)
212+
})
196213
}, reqSignOut)
197214

198215
m.Group("/user/settings", func() {
@@ -213,6 +230,13 @@ func runWeb(ctx *cli.Context) error {
213230
Post(bindIgnErr(auth.NewAccessTokenForm{}), user.SettingsApplicationsPost)
214231
m.Post("/applications/delete", user.SettingsDeleteApplication)
215232
m.Route("/delete", "GET,POST", user.SettingsDelete)
233+
m.Group("/two_factor", func() {
234+
m.Get("", user.SettingsTwoFactor)
235+
m.Post("/regenerate_scratch", user.SettingsTwoFactorRegenerateScratch)
236+
m.Post("/disable", user.SettingsTwoFactorDisable)
237+
m.Get("/enroll", user.SettingsTwoFactorEnroll)
238+
m.Post("/enroll", bindIgnErr(auth.TwoFactorAuthForm{}), user.SettingsTwoFactorEnrollPost)
239+
})
216240
}, reqSignIn, func(ctx *context.Context) {
217241
ctx.Data["PageIsUserSettings"] = true
218242
})
@@ -299,7 +323,7 @@ func runWeb(ctx *cli.Context) error {
299323
return
300324
}
301325
})
302-
m.Post("/issues/attachments", repo.UploadIssueAttachment)
326+
m.Post("/attachments", repo.UploadAttachment)
303327
}, ignSignIn)
304328

305329
m.Group("/:username", func() {
@@ -467,13 +491,11 @@ func runWeb(ctx *cli.Context) error {
467491
m.Get("/:id/:action", repo.ChangeMilestonStatus)
468492
m.Post("/delete", repo.DeleteMilestone)
469493
}, reqRepoWriter, context.RepoRef())
470-
471494
m.Group("/releases", func() {
472495
m.Get("/new", repo.NewRelease)
473496
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
474497
m.Post("/delete", repo.DeleteRelease)
475498
}, reqRepoWriter, context.RepoRef())
476-
477499
m.Group("/releases", func() {
478500
m.Get("/edit/*", repo.EditRelease)
479501
m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
@@ -593,7 +615,10 @@ func runWeb(ctx *cli.Context) error {
593615
})
594616
// ***** END: Repository *****
595617

596-
m.Get("/notifications", reqSignIn, user.Notifications)
618+
m.Group("/notifications", func() {
619+
m.Get("", user.Notifications)
620+
m.Post("/status", user.NotificationStatusPost)
621+
}, reqSignIn)
597622

598623
m.Group("/api", func() {
599624
apiv1.RegisterRoutes(m)

conf/app.ini

+15-2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ SSL_MODE = disable
158158
; For "sqlite3" and "tidb", use absolute path when you start as service
159159
PATH = data/gitea.db
160160

161+
[indexer]
162+
ISSUE_INDEXER_PATH = indexers/issues.bleve
163+
UPDATE_BUFFER_LEN = 20
164+
161165
[admin]
162166

163167
[security]
@@ -173,6 +177,8 @@ COOKIE_REMEMBER_NAME = gitea_incredible
173177
REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER
174178
; Sets the minimum password length for new Users
175179
MIN_PASSWORD_LENGTH = 6
180+
; True when users are allowed to import local server paths
181+
IMPORT_LOCAL_PATHS = false
176182

177183
[service]
178184
ACTIVE_CODE_LIVE_MINUTES = 180
@@ -190,6 +196,13 @@ ENABLE_REVERSE_PROXY_AUTHENTICATION = false
190196
ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = false
191197
; Enable captcha validation for registration
192198
ENABLE_CAPTCHA = true
199+
; Default value for KeepEmailPrivate
200+
; New user will get the value of this setting copied into their profile
201+
DEFAULT_KEEP_EMAIL_PRIVATE = false
202+
; Default value for the domain part of the user's email address in the git log
203+
; if he has set KeepEmailPrivate true. The user's email replaced with a
204+
; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
205+
NO_REPLY_ADDRESS = noreply.example.org
193206

194207
[webhook]
195208
; Hook task queue length, increase if webhook shooting starts hanging
@@ -282,7 +295,7 @@ ENABLE = true
282295
; Path for attachments. Defaults to `data/attachments`
283296
PATH = data/attachments
284297
; One or more allowed types, e.g. image/jpeg|image/png
285-
ALLOWED_TYPES = image/jpeg|image/png
298+
ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip
286299
; Max size of each file. Defaults to 32MB
287300
MAX_SIZE = 4
288301
; Max number of files per upload. Defaults to 10
@@ -409,7 +422,7 @@ MAX_RESPONSE_ITEMS = 50
409422

410423
[i18n]
411424
LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR
412-
NAMES = English,简体中文,繁體中文(香港),繁體中文(台湾),Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano,Suomalainen,Türkçe,čeština,Српски,Svenska,한국어
425+
NAMES = English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano,Suomalainen,Türkçe,čeština,Српски,Svenska,한국어
413426

414427
; Used for datetimepicker
415428
[i18n.datelang]

0 commit comments

Comments
 (0)