Skip to content

Commit 2c62bb5

Browse files
Merge branch 'master' into discord-auth
2 parents bd5fcbe + 03e558c commit 2c62bb5

File tree

132 files changed

+3673
-342
lines changed

Some content is hidden

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

132 files changed

+3673
-342
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pipeline:
7575
- make lint
7676
- make fmt-check
7777
- make swagger-check
78-
# - make swagger-validate
78+
- make swagger-validate
7979
- make misspell-check
8080
- make test-vendor
8181
- make build

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,25 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7-
## [1.5.0-RC1](https://github.com/go-gitea/gitea/releases/tag/v1.5.0-rc1) - 2018-07-04
7+
## [1.5.0](https://github.com/go-gitea/gitea/releases/tag/v1.5.0) - 2018-08-10
88
* SECURITY
9+
* Check that repositories can only be migrated to own user or organizations (#4366) (#4370)
910
* Limit uploaded avatar image-size to 4096px x 3072px by default (#4353)
1011
* Do not allow to reuse TOTP passcode (#3878)
12+
* BUGFIXES
13+
* Fix column droping for MSSQL that need new transaction for that (#4440) (#4484)
14+
* Redirect to correct page after using scratch token (#4458) (#4472)
15+
* Replace src with raw to fix image paths (#4377) (#4386)
16+
* Fixes repo membership check in API (#4341) (#4379)
17+
* Add default merge options when adding new repository (#4369) (#4373)
18+
* Fix repository last updated time update when delete a user who watched the repo (#4363) (#4371)
19+
* Fix html entity escaping in branch deletion message (#4471) (#4485)
20+
* Fix out-of-transaction query in removeOrgUser (#4521) (#4524)
21+
* Fix incorrect MergeWhitelistTeamIDs check in CanUserMerge function (#4519)
22+
* Fix panic issue on update avatar email (#4580) (#4590)
23+
* Fix bugs when too many IN variables (#4594) (#4597)
24+
* Push whitelist now doesn't apply to branch deletion (#4601) (#4640)
25+
* Site admin could create repos even MAX_CREATION_LIMIT=0 (#4645) (#4650)
1126
* FEATURE
1227
* Add cli commands to regen hooks & keys (#3979)
1328
* Add support for FIDO U2F (#3971)

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ TAGS ?=
4242

4343
TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp')
4444

45+
SWAGGER_SPEC := templates/swagger/v1_json.tmpl
46+
SWAGGER_SPEC_S_TMPL := s|"basePath":\s*"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
47+
SWAGGER_SPEC_S_JSON := s|"basePath":\s*"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
48+
4549
TEST_MYSQL_HOST ?= mysql:3306
4650
TEST_MYSQL_DBNAME ?= testgitea
4751
TEST_MYSQL_USERNAME ?= root
@@ -94,11 +98,12 @@ generate-swagger:
9498
@hash swagger > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
9599
$(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
96100
fi
97-
swagger generate spec -o ./public/swagger.v1.json
101+
swagger generate spec -o './$(SWAGGER_SPEC)'
102+
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
98103

99104
.PHONY: swagger-check
100105
swagger-check: generate-swagger
101-
@diff=$$(git diff public/swagger.v1.json); \
106+
@diff=$$(git diff '$(SWAGGER_SPEC)'); \
102107
if [ -n "$$diff" ]; then \
103108
echo "Please run 'make generate-swagger' and commit the result:"; \
104109
echo "$${diff}"; \
@@ -110,7 +115,9 @@ swagger-validate:
110115
@hash swagger > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
111116
$(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
112117
fi
113-
swagger validate ./public/swagger.v1.json
118+
$(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
119+
swagger validate './$(SWAGGER_SPEC)'
120+
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
114121

115122
.PHONY: errcheck
116123
errcheck:

cmd/serv.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"code.gitea.io/gitea/models"
1818
"code.gitea.io/gitea/modules/log"
19+
"code.gitea.io/gitea/modules/pprof"
1920
"code.gitea.io/gitea/modules/private"
2021
"code.gitea.io/gitea/modules/setting"
2122
"code.gitea.io/gitea/modules/util"
@@ -42,6 +43,9 @@ var CmdServ = cli.Command{
4243
Value: "custom/conf/app.ini",
4344
Usage: "Custom configuration file path",
4445
},
46+
cli.BoolFlag{
47+
Name: "enable-pprof",
48+
},
4549
},
4650
}
4751

@@ -143,6 +147,18 @@ func runServ(c *cli.Context) error {
143147
username := strings.ToLower(rr[0])
144148
reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git"))
145149

150+
if setting.EnablePprof || c.Bool("enable-pprof") {
151+
if err := os.MkdirAll(setting.PprofDataPath, os.ModePerm); err != nil {
152+
fail("Error while trying to create PPROF_DATA_PATH", "Error while trying to create PPROF_DATA_PATH: %v", err)
153+
}
154+
155+
stopCPUProfiler := pprof.DumpCPUProfileForUsername(setting.PprofDataPath, username)
156+
defer func() {
157+
stopCPUProfiler()
158+
pprof.DumpMemProfileForUsername(setting.PprofDataPath, username)
159+
}()
160+
}
161+
146162
isWiki := false
147163
unitType := models.UnitTypeCode
148164
if strings.HasSuffix(reponame, ".wiki") {

custom/conf/app.ini.sample

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,21 @@ FILE_MAX_SIZE = 3
6060
; Max number of files per upload. Defaults to 5
6161
MAX_FILES = 5
6262

63+
[repository.pull-request]
64+
; List of prefixes used in Pull Request title to mark them as Work In Progress
65+
WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
66+
6367
[ui]
6468
; Number of repositories that are displayed on one explore page
6569
EXPLORE_PAGING_NUM = 20
6670
; Number of issues that are displayed on one page
6771
ISSUE_PAGING_NUM = 10
6872
; Number of maximum commits displayed in one activity feed
6973
FEED_MAX_COMMIT_NUM = 5
74+
; Number of maximum commits displayed in commit graph.
75+
GRAPH_MAX_COMMIT_NUM = 100
76+
; Number of line of codes shown for a code comment
77+
CODE_COMMENT_LINES = 4
7078
; Value of `theme-color` meta tag, used by Android >= 5.0
7179
; An invalid color like "none" or "disable" will have the default style
7280
; More info: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
@@ -183,6 +191,12 @@ STATIC_ROOT_PATH =
183191
APP_DATA_PATH = data
184192
; Application level GZIP support
185193
ENABLE_GZIP = false
194+
; Application profiling (memory and cpu)
195+
; For "web" command it listens on localhost:6060
196+
; For "serve" command it dumps to disk at PPROF_DATA_PATH as (cpuprofile|memprofile)_<username>_<temporary id>
197+
ENABLE_PPROF = false
198+
; PPROF_DATA_PATH, use an absolute path when you start gitea as service
199+
PPROF_DATA_PATH = data/tmp/pprof
186200
; Landing page, can be "home", "explore", or "organizations"
187201
LANDING_PAGE = home
188202
; Enables git-lfs support. true or false, default is false.
@@ -211,7 +225,7 @@ USER = root
211225
PASSWD =
212226
; For "postgres" only, either "disable", "require" or "verify-full"
213227
SSL_MODE = disable
214-
; For "sqlite3" and "tidb", use absolute path when you start gitea as service
228+
; For "sqlite3" and "tidb", use an absolute path when you start gitea as service
215229
PATH = data/gitea.db
216230
; For "sqlite3" only. Query timeout
217231
SQLITE_TIMEOUT = 500
@@ -579,8 +593,8 @@ DEFAULT_INTERVAL = 8h
579593
MIN_INTERVAL = 10m
580594

581595
[api]
582-
; Enables /api/swagger, /api/v1/swagger etc. endpoints. True or false; default is true.
583-
ENABLE_SWAGGER_ENDPOINT = true
596+
; Enables Swagger. True or false; default is true.
597+
ENABLE_SWAGGER = true
584598
; Max number of items in a page
585599
MAX_RESPONSE_ITEMS = 50
586600

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
public/
2+
templates/swagger/v1_json.tmpl
23
themes/

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
6262
HTTP protocol.
6363
- `USE_COMPAT_SSH_URI`: **false**: Force ssh:// clone url instead of scp-style uri when
6464
default SSH port is used.
65+
66+
### Repository - Pull Request (`repository.pull-request`)
67+
- `WORK_IN_PROGRESS_PREFIXES`: **WIP:,\[WIP\]**: List of prefixes used in Pull Request
68+
title to mark them as Work In Progress
6569

6670
## UI (`ui`)
6771

6872
- `EXPLORE_PAGING_NUM`: **20**: Number of repositories that are shown in one explore page.
6973
- `ISSUE_PAGING_NUM`: **10**: Number of issues that are shown in one page (for all pages that list issues).
7074
- `FEED_MAX_COMMIT_NUM`: **5**: Number of maximum commits shown in one activity feed.
75+
- `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph.
7176
- `DEFAULT_THEME`: **gitea**: \[gitea, arc-green\]: Set the default theme for the Gitea install.
7277

7378
### UI - Admin (`ui.admin`)

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ to override can be found in the `templates` directory of Gitea source. Override
5959
making a copy of the file under `custom/templates` using a full path structure
6060
matching source.
6161

62-
Any statement contained inside `{{` and `}}` are Gitea's templete syntax and
62+
Any statement contained inside `{{` and `}}` are Gitea's template syntax and
6363
shouldn't be touched without fully understanding these components.
6464

6565
### Adding links and tabs

docs/content/doc/features/comparison.en-us.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ _Symbols used in table:_
8484
| Create new branches from issues ||||||||
8585
| Issue search ||||||||
8686
| Global issue search ||||||||
87+
| Issue dependency ||||||||
8788

8889
#### Pull/Merge requests
8990

@@ -92,8 +93,8 @@ _Symbols used in table:_
9293
| Pull/Merge requests ||||||||
9394
| Squash merging ||||||||
9495
| Rebase merging ||||||||
95-
| Pull/Merge request inline comments | |||||||
96-
| Pull/Merge request approval | |||||||
96+
| Pull/Merge request inline comments | |||||||
97+
| Pull/Merge request approval | |||||||
9798
| Merge conflict resolution ||||||||
9899
| Restrict push and merge access to certain users ||||||||
99100
| Revert specific commits or a merge request ||||||||

docs/content/doc/installation/from-binary.en-us.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ the destination platform from the [downloads page](https://dl.gitea.io/gitea), c
2121
the URL and replace the URL within the commands below:
2222

2323
```sh
24-
wget -O gitea https://dl.gitea.io/gitea/1.4.3/gitea-1.4.3-linux-amd64
24+
wget -O gitea https://dl.gitea.io/gitea/1.5.0/gitea-1.5.0-linux-amd64
2525
chmod +x gitea
2626
```
2727

@@ -90,6 +90,20 @@ cp gitea /usr/local/bin/gitea
9090

9191
See how to create [Linux service]({{< relref "run-as-service-in-ubuntu.en-us.md" >}})
9292

93+
## Updating to a new version
94+
95+
You can update to a new version of gitea by stopping gitea, replacing the binary at `/usr/local/bin/gitea` and restarting the instance.
96+
The binary file name should not be changed during the update to avoid problems
97+
in existing repositories.
98+
99+
It is recommended you do a [backup]({{< relref "doc/usage/backup-and-restore.en-us.md" >}}) before updating your installation.
100+
101+
If you have carried out the installation steps as described above, the binary should
102+
have the generic name `gitea`. Do not change this, i.e. to include the version number.
103+
104+
See below for troubleshooting instructions to repair broken repositories after
105+
an update of your gitea version.
106+
93107
## Troubleshooting
94108

95109
### Old glibc versions
@@ -107,3 +121,25 @@ For errors like `702 runWeb()] [E] Failed to start server: listen tcp 0.0.0.0:30
107121
bind: address already in use` gitea needs to be started on another free port. This
108122
is possible using `./gitea web -p $PORT`. It's possible another instance of gitea
109123
is already running.
124+
125+
### Git error after updating to a new version of gitea
126+
127+
If the binary file name has been changed during the update to a new version of gitea,
128+
git hooks in existing repositories will not work any more. In that case, a git
129+
error will be displayed when pushing to the repository.
130+
131+
```
132+
remote: ./hooks/pre-receive.d/gitea: line 2: [...]: No such file or directory
133+
```
134+
135+
The `[...]` part of the error message will contain the path to your previous gitea
136+
binary.
137+
138+
To solve this, go to the admin options and run the task `Resynchronize pre-receive,
139+
update and post-receive hooks of all repositories` to update all hooks to contain
140+
the new binary path. Please note that this overwrite all git hooks including ones
141+
with customizations made.
142+
143+
If you aren't using the built-in to Gitea ssh server you will also need to re-write
144+
the authorized key file by running the `Update the '.ssh/authorized_keys' file with
145+
Gitea SSH keys.` task in the admin options.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
date: "2018-06-01T19:00:00+02:00"
3+
title: "Usage: Pull Request"
4+
slug: "pull-request"
5+
weight: 13
6+
toc: true
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "usage"
11+
name: "Pull Request"
12+
weight: 13
13+
identifier: "pull-request"
14+
---
15+
16+
# Pull Request
17+
18+
## "Work In Progress" pull requests
19+
20+
Marking a pull request as being a work in progress will prevent that pull request from being accidentally merged. To mark a pull request as being a work in progress, you must prefix its title by `WIP:` or `[WIP]` (case insensitive). Those values are configurable in your `app.ini` file :
21+
22+
```
23+
[repository.pull-request]
24+
WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
25+
```
26+
27+
The first value of the list will be used in helpers.
28+
29+
## Pull Request Templates
30+
31+
You can find more information about pull request templates in the dedicated page : [Issue and Pull Request templates](../issue-pull-request-templates)

integrations/api_pull_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
package integrations
66

77
import (
8+
"fmt"
89
"net/http"
910
"testing"
1011

1112
"code.gitea.io/gitea/models"
13+
"code.gitea.io/gitea/modules/auth"
14+
"code.gitea.io/gitea/modules/setting"
1215
api "code.gitea.io/sdk/gitea"
1316

1417
"github.com/stretchr/testify/assert"
@@ -28,3 +31,26 @@ func TestAPIViewPulls(t *testing.T) {
2831
expectedLen := models.GetCount(t, &models.Issue{RepoID: repo.ID}, models.Cond("is_pull = ?", true))
2932
assert.Len(t, pulls, expectedLen)
3033
}
34+
35+
// TestAPIMergePullWIP ensures that we can't merge a WIP pull request
36+
func TestAPIMergePullWIP(t *testing.T) {
37+
prepareTestEnv(t)
38+
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
39+
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
40+
pr := models.AssertExistsAndLoadBean(t, &models.PullRequest{Status: models.PullRequestStatusMergeable}, models.Cond("has_merged = ?", false)).(*models.PullRequest)
41+
pr.LoadIssue()
42+
pr.Issue.ChangeTitle(owner, setting.Repository.PullRequest.WorkInProgressPrefixes[0]+" "+pr.Issue.Title)
43+
44+
// force reload
45+
pr.LoadAttributes()
46+
47+
assert.Contains(t, pr.Issue.Title, setting.Repository.PullRequest.WorkInProgressPrefixes[0])
48+
49+
session := loginUser(t, owner.Name)
50+
req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge", owner.Name, repo.Name, pr.Index), &auth.MergePullRequestForm{
51+
MergeMessageField: pr.Issue.Title,
52+
Do: string(models.MergeStyleMerge),
53+
})
54+
55+
session.MakeRequest(t, req, http.StatusMethodNotAllowed)
56+
}

integrations/pull_merge_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"code.gitea.io/gitea/models"
1515
"code.gitea.io/gitea/modules/test"
1616

17+
"github.com/Unknwon/i18n"
1718
"github.com/stretchr/testify/assert"
1819
)
1920

@@ -123,3 +124,23 @@ func TestPullCleanUpAfterMerge(t *testing.T) {
123124

124125
assert.EqualValues(t, "Branch 'user1/feature/test' has been deleted.", resultMsg)
125126
}
127+
128+
func TestCantMergeWorkInProgress(t *testing.T) {
129+
prepareTestEnv(t)
130+
session := loginUser(t, "user1")
131+
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
132+
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
133+
134+
resp := testPullCreate(t, session, "user1", "repo1", "master", "[wip] This is a pull title")
135+
136+
req := NewRequest(t, "GET", resp.Header().Get("Location"))
137+
resp = session.MakeRequest(t, req, http.StatusOK)
138+
htmlDoc := NewHTMLParser(t, resp.Body)
139+
text := strings.TrimSpace(htmlDoc.doc.Find(".merge.segment > .text.grey").Text())
140+
assert.NotEmpty(t, text, "Can't find WIP text")
141+
142+
// remove <strong /> from lang
143+
expected := i18n.Tr("en", "repo.pulls.cannot_merge_work_in_progress", "[wip]")
144+
replacer := strings.NewReplacer("<strong>", "", "</strong>", "")
145+
assert.Equal(t, replacer.Replace(expected), text, "Unable to find WIP text")
146+
}

0 commit comments

Comments
 (0)