From 8941f7fc01eb76ad66768a828bcc9bc8b8887731 Mon Sep 17 00:00:00 2001 From: Flutterlice Date: Wed, 1 Jan 2020 05:54:21 +0500 Subject: [PATCH 01/46] Fix for a wrong URL in activity page of repository. (Using config url instead of an actual one) (#9571) --- templates/repo/activity.tmpl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl index 504fd32300309..6432630af4caf 100644 --- a/templates/repo/activity.tmpl +++ b/templates/repo/activity.tmpl @@ -123,7 +123,7 @@
{{$.i18n.Tr "repo.activity.published_release_label"}}
{{.TagName}} {{if not .IsTag}} - {{.Title}} + {{.Title}} {{end}} {{TimeSinceUnix .CreatedUnix $.Lang}}

@@ -140,7 +140,7 @@ {{range .Activity.MergedPRs}}

{{$.i18n.Tr "repo.activity.merged_prs_label"}}
- #{{.Index}} {{.Issue.Title}} + #{{.Index}} {{.Issue.Title}} {{TimeSinceUnix .MergedUnix $.Lang}}

{{end}} @@ -156,7 +156,7 @@ {{range .Activity.OpenedPRs}}

{{$.i18n.Tr "repo.activity.opened_prs_label"}}
- #{{.Index}} {{.Issue.Title}} + #{{.Index}} {{.Issue.Title}} {{TimeSinceUnix .Issue.CreatedUnix $.Lang}}

{{end}} @@ -172,7 +172,7 @@ {{range .Activity.ClosedIssues}}

{{$.i18n.Tr "repo.activity.closed_issue_label"}}
- #{{.Index}} {{.Title}} + #{{.Index}} {{.Title}} {{TimeSinceUnix .ClosedUnix $.Lang}}

{{end}} @@ -188,7 +188,7 @@ {{range .Activity.OpenedIssues}}

{{$.i18n.Tr "repo.activity.new_issue_label"}}
- #{{.Index}} {{.Title}} + #{{.Index}} {{.Title}} {{TimeSinceUnix .CreatedUnix $.Lang}}

{{end}} @@ -209,9 +209,9 @@
{{$.i18n.Tr "repo.activity.unresolved_conv_label"}}
#{{.Index}} {{if .IsPull}} - {{.Title}} + {{.Title}} {{else}} - {{.Title}} + {{.Title}} {{end}} {{TimeSinceUnix .UpdatedUnix $.Lang}}

From 7bdf17ec29851b857bf88d5e5f39436799732dd6 Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Tue, 31 Dec 2019 21:54:56 -0600 Subject: [PATCH 02/46] Use limited commits (#9572) Signed-off-by: jolheiser --- services/mirror/mirror.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go index 7fc6e97b463a1..28b2e2a12728a 100644 --- a/services/mirror/mirror.go +++ b/services/mirror/mirror.go @@ -410,7 +410,7 @@ func syncMirror(repoID string) { theCommits.CompareURL = m.Repo.ComposeCompareURL(oldCommitID, newCommitID) - notification.NotifySyncPushCommits(m.Repo.MustOwner(), m.Repo, result.refName, oldCommitID, newCommitID, models.ListToPushCommits(commits)) + notification.NotifySyncPushCommits(m.Repo.MustOwner(), m.Repo, result.refName, oldCommitID, newCommitID, theCommits) } // Get latest commit date and update to current repository updated time From a864d61ee629dfc3aa5e75a5271354db5088f70e Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Tue, 31 Dec 2019 23:06:15 -0600 Subject: [PATCH 03/46] Add box-shadow to blue buttons in normal theme (#9573) Signed-off-by: jolheiser Co-authored-by: techknowlogick --- web_src/less/_base.less | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web_src/less/_base.less b/web_src/less/_base.less index 721863a70fb45..3da3ae6b99d10 100644 --- a/web_src/less/_base.less +++ b/web_src/less/_base.less @@ -1172,3 +1172,9 @@ i.icon.centerlock { .octicon-tiny { font-size: 0.85714286rem; } + +.ui.basic.blue.button, +.ui.basic.blue.buttons .button { + box-shadow: inset 0 0 0 1px #1678c2 !important; + color: #1678c2 !important; +} From d1798f77f62988828c004fcf8d234bff6340deb7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 1 Jan 2020 17:08:13 +0100 Subject: [PATCH 04/46] swagger UI: hide iretating search field (#9554) --- templates/swagger/ui.tmpl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/templates/swagger/ui.tmpl b/templates/swagger/ui.tmpl index 0125ee4a19969..7bc005e334417 100644 --- a/templates/swagger/ui.tmpl +++ b/templates/swagger/ui.tmpl @@ -85,13 +85,11 @@ window.onload = function() { dom_id: '#swagger-ui', deepLinking: true, presets: [ - SwaggerUIBundle.presets.apis, - SwaggerUIStandalonePreset + SwaggerUIBundle.presets.apis ], plugins: [ SwaggerUIBundle.plugins.DownloadUrl - ], - layout: "StandaloneLayout" + ] }) // End Swagger UI call region From c620eb5b2d0d874da68ebd734d3864c5224f71f7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 1 Jan 2020 23:51:10 +0100 Subject: [PATCH 05/46] Fix #9189 - API Allow only specific Colums to be updated on Issue (#9539) * dont insert "-1" in any case to issue.poster_id * Make sure API cant override importand fields * code format * fix lint * WIP test * add missing poster_id * fix test * user.IsGhost handle nil * CI.restart() * make sure no -1 is realy added * CI.restart() * @lunny suggestion remove some not allowed fields * seperate issue.LoadMilestone * load milestone and return it on IssueEdit via API * extend Test for TestAPIEditIssue * fix fixtures * declare allowedColumnsUpdateIssueByAPI only once * Update Year * no var just write id drecty into func cal Co-authored-by: Lauris BH --- integrations/api_issue_test.go | 58 ++++++++++++++++++++++++++++++++++ models/fixtures/issue.yml | 15 ++++++++- models/fixtures/milestone.yml | 8 +++++ models/fixtures/repository.yml | 9 +++--- models/issue.go | 44 +++++++++++++++----------- models/user.go | 8 +++++ routers/api/v1/repo/issue.go | 10 ++++-- routers/api/v1/repo/pull.go | 4 +-- 8 files changed, 127 insertions(+), 29 deletions(-) diff --git a/integrations/api_issue_test.go b/integrations/api_issue_test.go index f412f5af085da..382fe606bf356 100644 --- a/integrations/api_issue_test.go +++ b/integrations/api_issue_test.go @@ -62,3 +62,61 @@ func TestAPICreateIssue(t *testing.T) { Title: title, }) } + +func TestAPIEditIssue(t *testing.T) { + defer prepareTestEnv(t)() + + issueBefore := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 10}).(*models.Issue) + repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: issueBefore.RepoID}).(*models.Repository) + owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) + assert.NoError(t, issueBefore.LoadAttributes()) + assert.Equal(t, int64(1019307200), int64(issueBefore.DeadlineUnix)) + assert.Equal(t, api.StateOpen, issueBefore.State()) + + session := loginUser(t, owner.Name) + token := getTokenForLoggedInUser(t, session) + + // update values of issue + issueState := "closed" + removeDeadline := true + milestone := int64(4) + body := "new content!" + title := "new title from api set" + + urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d?token=%s", owner.Name, repo.Name, issueBefore.Index, token) + req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{ + State: &issueState, + RemoveDeadline: &removeDeadline, + Milestone: &milestone, + Body: &body, + Title: title, + + // ToDo change more + }) + resp := session.MakeRequest(t, req, http.StatusCreated) + var apiIssue api.Issue + DecodeJSON(t, resp, &apiIssue) + + issueAfter := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 10}).(*models.Issue) + + // check deleted user + assert.Equal(t, int64(500), issueAfter.PosterID) + assert.NoError(t, issueAfter.LoadAttributes()) + assert.Equal(t, int64(-1), issueAfter.PosterID) + assert.Equal(t, int64(-1), issueBefore.PosterID) + assert.Equal(t, int64(-1), apiIssue.Poster.ID) + + // API response + assert.Equal(t, api.StateClosed, apiIssue.State) + assert.Equal(t, milestone, apiIssue.Milestone.ID) + assert.Equal(t, body, apiIssue.Body) + assert.True(t, apiIssue.Deadline == nil) + assert.Equal(t, title, apiIssue.Title) + + // in database + assert.Equal(t, api.StateClosed, issueAfter.State()) + assert.Equal(t, milestone, issueAfter.MilestoneID) + assert.Equal(t, int64(0), int64(issueAfter.DeadlineUnix)) + assert.Equal(t, body, issueAfter.Content) + assert.Equal(t, title, issueAfter.Title) +} diff --git a/models/fixtures/issue.yml b/models/fixtures/issue.yml index 6b57268a7a027..ecee7499f6f04 100644 --- a/models/fixtures/issue.yml +++ b/models/fixtures/issue.yml @@ -108,4 +108,17 @@ is_closed: false is_pull: true created_unix: 946684820 - updated_unix: 978307180 \ No newline at end of file + updated_unix: 978307180 + +- + id: 10 + repo_id: 42 + index: 1 + poster_id: 500 + name: issue from deleted account + content: content from deleted account + is_closed: false + is_pull: false + created_unix: 946684830 + updated_unix: 999307200 + deadline_unix: 1019307200 diff --git a/models/fixtures/milestone.yml b/models/fixtures/milestone.yml index 15f422fc3b5c2..a9ecb4ee6a6ef 100644 --- a/models/fixtures/milestone.yml +++ b/models/fixtures/milestone.yml @@ -21,3 +21,11 @@ content: content3 is_closed: true num_issues: 0 + +- + id: 4 + repo_id: 42 + name: milestone of repo42 + content: content random + is_closed: false + num_issues: 0 diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index feec0b5fafb97..c7f4d4d1096ab 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -547,7 +547,8 @@ is_private: false num_stars: 0 num_forks: 0 - num_issues: 0 + num_issues: 1 + num_milestones: 1 is_mirror: false - @@ -588,7 +589,7 @@ is_mirror: false status: 0 -- +- id: 46 owner_id: 26 lower_name: repo_external_tracker @@ -600,7 +601,7 @@ is_mirror: false status: 0 -- +- id: 47 owner_id: 26 lower_name: repo_external_tracker_numeric @@ -612,7 +613,7 @@ is_mirror: false status: 0 -- +- id: 48 owner_id: 26 lower_name: repo_external_tracker_alpha diff --git a/models/issue.go b/models/issue.go index 75f7bd818aa6e..c832b9d014473 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2020 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -239,6 +240,16 @@ func (issue *Issue) loadReactions(e Engine) (err error) { return nil } +func (issue *Issue) loadMilestone(e Engine) (err error) { + if issue.Milestone == nil && issue.MilestoneID > 0 { + issue.Milestone, err = getMilestoneByRepoID(e, issue.RepoID, issue.MilestoneID) + if err != nil && !IsErrMilestoneNotExist(err) { + return fmt.Errorf("getMilestoneByRepoID [repo_id: %d, milestone_id: %d]: %v", issue.RepoID, issue.MilestoneID, err) + } + } + return nil +} + func (issue *Issue) loadAttributes(e Engine) (err error) { if err = issue.loadRepo(e); err != nil { return @@ -252,11 +263,8 @@ func (issue *Issue) loadAttributes(e Engine) (err error) { return } - if issue.Milestone == nil && issue.MilestoneID > 0 { - issue.Milestone, err = getMilestoneByRepoID(e, issue.RepoID, issue.MilestoneID) - if err != nil && !IsErrMilestoneNotExist(err) { - return fmt.Errorf("getMilestoneByRepoID [repo_id: %d, milestone_id: %d]: %v", issue.RepoID, issue.MilestoneID, err) - } + if err = issue.loadMilestone(e); err != nil { + return } if err = issue.loadAssignees(e); err != nil { @@ -296,6 +304,11 @@ func (issue *Issue) LoadAttributes() error { return issue.loadAttributes(x) } +// LoadMilestone load milestone of this issue. +func (issue *Issue) LoadMilestone() error { + return issue.loadMilestone(x) +} + // GetIsRead load the `IsRead` field of the issue func (issue *Issue) GetIsRead(userID int64) error { issueUser := &IssueUser{IssueID: issue.ID, UID: userID} @@ -1568,25 +1581,18 @@ func SearchIssueIDsByKeyword(kw string, repoIDs []int64, limit, start int) (int6 return total, ids, nil } -func updateIssue(e Engine, issue *Issue) error { - _, err := e.ID(issue.ID).AllCols().Update(issue) - if err != nil { - return err - } - return nil -} - -// UpdateIssue updates all fields of given issue. -func UpdateIssue(issue *Issue) error { +// UpdateIssueByAPI updates all allowed fields of given issue. +func UpdateIssueByAPI(issue *Issue) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { return err } - if err := updateIssue(sess, issue); err != nil { - return err - } - if err := issue.loadPoster(sess); err != nil { + + if _, err := sess.ID(issue.ID).Cols( + "name", "is_closed", "content", "milestone_id", "priority", + "deadline_unix", "updated_unix", "closed_unix", "is_locked"). + Update(issue); err != nil { return err } if err := issue.addCrossReferences(sess, issue.Poster, true); err != nil { diff --git a/models/user.go b/models/user.go index e832c2ed519b8..a8f2c6fd22336 100644 --- a/models/user.go +++ b/models/user.go @@ -791,6 +791,14 @@ func NewGhostUser() *User { } } +// IsGhost check if user is fake user for a deleted account +func (u *User) IsGhost() bool { + if u == nil { + return false + } + return u.ID == -1 && u.Name == "Ghost" +} + var ( reservedUsernames = []string{ "attachments", diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 4396e6faaebe2..ad82d53e7a190 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -524,8 +524,8 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { } } - if err = models.UpdateIssue(issue); err != nil { - ctx.Error(http.StatusInternalServerError, "UpdateIssue", err) + if err = models.UpdateIssueByAPI(issue); err != nil { + ctx.Error(http.StatusInternalServerError, "UpdateIssueByAPI", err) return } if form.State != nil { @@ -542,7 +542,11 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { // Refetch from database to assign some automatic values issue, err = models.GetIssueByID(issue.ID) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetIssueByID", err) + ctx.InternalServerError(err) + return + } + if err = issue.LoadMilestone(); err != nil { + ctx.InternalServerError(err) return } ctx.JSON(http.StatusCreated, issue.APIFormat()) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 0392eb8e8c480..d0551320fdbc7 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -450,8 +450,8 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { } } - if err = models.UpdateIssue(issue); err != nil { - ctx.Error(http.StatusInternalServerError, "UpdateIssue", err) + if err = models.UpdateIssueByAPI(issue); err != nil { + ctx.Error(http.StatusInternalServerError, "UpdateIssueByAPI", err) return } if form.State != nil { From 9cf7048a6a9bed8be9e02a3e0c1ae3336614cdc3 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 2 Jan 2020 03:07:15 +0100 Subject: [PATCH 06/46] Dont trigger notification twice on issue assignee change (#9582) --- routers/repo/issue.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 67c4ee3788194..925903fee420c 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -23,7 +23,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" - "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" @@ -1177,13 +1176,11 @@ func UpdateIssueAssignee(ctx *context.Context) { return } - removed, comment, err := issue_service.ToggleAssignee(issue, ctx.User, assigneeID) + _, _, err = issue_service.ToggleAssignee(issue, ctx.User, assigneeID) if err != nil { ctx.ServerError("ToggleAssignee", err) return } - - notification.NotifyIssueChangeAssignee(ctx.User, issue, assignee, removed, comment) } } ctx.JSON(200, map[string]interface{}{ From b2b10858c631dea6b7ac457f8e71c61b27bf4934 Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Wed, 1 Jan 2020 21:02:11 -0600 Subject: [PATCH 07/46] Don't auto-init SimpleMDE for review textarea (#9574) Signed-off-by: jolheiser Co-authored-by: Lauris BH --- templates/repo/diff/box.tmpl | 2 +- web_src/js/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 9f3b271e24b5c..9b0738b1b7835 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -213,7 +213,7 @@ {{$.i18n.Tr "preview"}}
- +
{{$.i18n.Tr "loading"}} diff --git a/web_src/js/index.js b/web_src/js/index.js index f4f08b828c8c4..3751c6d9e46f2 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -325,7 +325,7 @@ function initCommentForm() { return; } - setCommentSimpleMDE($('.comment.form textarea')); + setCommentSimpleMDE($('.comment.form textarea:not(.review-textarea)')); initBranchSelector(); initCommentPreviewTab($('.comment.form')); initImagePaste($('.comment.form textarea')); From 5b9283ddfea211ea0129449b6b501703306e5d25 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 2 Jan 2020 08:54:22 +0100 Subject: [PATCH 08/46] make sure Poster is loaded (#9583) --- models/issue.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/models/issue.go b/models/issue.go index c832b9d014473..485be4baef7be 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1595,6 +1595,11 @@ func UpdateIssueByAPI(issue *Issue) error { Update(issue); err != nil { return err } + + if err := issue.loadPoster(sess); err != nil { + return err + } + if err := issue.addCrossReferences(sess, issue.Poster, true); err != nil { return err } From 4ab072d9c2f10ecaf0c45913bf09a9d245ea9a98 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 2 Jan 2020 13:15:30 +0100 Subject: [PATCH 09/46] Changelog for 1.10.2 (#9586) --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfefea3a22c8e..c11e75ced2c3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ This changelog goes through all the changes that have been made in each release without substantial changes to our git log; to see the highlights of what has been added to each release, please refer to the [blog](https://blog.gitea.io). +## [1.10.2](https://github.com/go-gitea/gitea/releases/tag/v1.10.2) - 2020-01-02 +* BUGFIXES + * Allow only specific Columns to be updated on Issue via API (#9539) (#9580) + * Add ErrReactionAlreadyExist error (#9550) (#9564) + * Fix bug when migrate from API (#8631) (#9563) + * Use default avatar for ghost user (#9536) (#9537) + * Fix repository issues pagination bug when there are more than one label filter (#9512) (#9528) + * Fix deleted branch not removed when push the branch again (#9516) (#9524) + * Fix missing repository status when migrating repository via API (#9511) + * Trigger webhook when deleting a branch after merging a PR (#9510) + * Fix paging on /repos/{owner}/{repo}/git/trees/{sha} API endpoint (#9482) + * Fix NewCommitStatus (#9434) (#9435) + * Use OriginalURL instead of CloneAddr in migration logging (#9418) (#9420) + * Fix Slack webhook payload title generation to work with Mattermost (#9404) + * DefaultBranch needs to be prefixed by BranchPrefix (#9356) (#9359) + * Fix issue indexer not triggered when migrating a repository (#9333) + * Fix bug that release attachment files not deleted when deleting repository (#9322) (#9329) + * Fix migration releases (#9319) (#9326) (#9328) + * Fix File Edit: Author/Committer interchanged (#9297) (#9300) + ## [1.10.1](https://github.com/go-gitea/gitea/releases/tag/v1.10.1) - 2019-12-05 * BUGFIXES * Fix max length check and limit in multiple repo forms (#9148) (#9204) From 09bf77bc4f1eeac16bfde8979ab448657cd0aaf3 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Thu, 2 Jan 2020 12:18:28 +0000 Subject: [PATCH 10/46] [skip ci] Updated translations via Crowdin --- options/locale/locale_pt-BR.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index 19e30c4631681..68c3c4b752cd5 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -959,6 +959,7 @@ issues.add_time=Adicionar tempo manualmente issues.add_time_short=Adicionar tempo issues.add_time_cancel=Cancelar issues.add_time_history=`adicionou tempo gasto %s` +issues.del_time_history=`removeu tempo gasto %s` issues.add_time_hours=Horas issues.add_time_minutes=Minutos issues.add_time_sum_to_small=Nenhum tempo foi inserido. From b3c5b4b0d12ae42d10cb677deb9abdef6b044166 Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Thu, 2 Jan 2020 09:53:08 -0600 Subject: [PATCH 11/46] Update version in docs (#9588) --- docs/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.yaml b/docs/config.yaml index a0a349a78062f..cbfcd49e6ed91 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -18,7 +18,7 @@ params: description: Git with a cup of tea author: The Gitea Authors website: https://docs.gitea.io - version: 1.10.1 + version: 1.10.2 outputs: home: From 134e3fdf3d271f1015d062c74d55e3f28f7825d6 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 2 Jan 2020 22:27:31 +0100 Subject: [PATCH 12/46] [API] dont reqToken on GetReactions (fix #9543) (#9548) * dont reqToken on GetReactions * ctx.Repo.CanWrite has ctx.User.IsAdmin in It Co-authored-by: Lauris BH --- routers/api/v1/api.go | 12 ++++++------ routers/api/v1/repo/issue_reaction.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 0bb5320b16021..e4288f40f650b 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -664,10 +664,10 @@ func RegisterRoutes(m *macaron.Macaron) { m.Combo("", reqToken()). Patch(mustNotBeArchived, bind(api.EditIssueCommentOption{}), repo.EditIssueComment). Delete(repo.DeleteIssueComment) - m.Combo("/reactions", reqToken()). + m.Combo("/reactions"). Get(repo.GetIssueCommentReactions). - Post(bind(api.EditReactionOption{}), repo.PostIssueCommentReaction). - Delete(bind(api.EditReactionOption{}), repo.DeleteIssueCommentReaction) + Post(bind(api.EditReactionOption{}), reqToken(), repo.PostIssueCommentReaction). + Delete(bind(api.EditReactionOption{}), reqToken(), repo.DeleteIssueCommentReaction) }) }) m.Group("/:index", func() { @@ -704,10 +704,10 @@ func RegisterRoutes(m *macaron.Macaron) { m.Put("/:user", reqToken(), repo.AddIssueSubscription) m.Delete("/:user", reqToken(), repo.DelIssueSubscription) }) - m.Combo("/reactions", reqToken()). + m.Combo("/reactions"). Get(repo.GetIssueReactions). - Post(bind(api.EditReactionOption{}), repo.PostIssueReaction). - Delete(bind(api.EditReactionOption{}), repo.DeleteIssueReaction) + Post(bind(api.EditReactionOption{}), reqToken(), repo.PostIssueReaction). + Delete(bind(api.EditReactionOption{}), reqToken(), repo.DeleteIssueReaction) }) }, mustEnableIssuesOrPulls) m.Group("/labels", func() { diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go index bbc767cc99ad4..d612b20d7e5e1 100644 --- a/routers/api/v1/repo/issue_reaction.go +++ b/routers/api/v1/repo/issue_reaction.go @@ -55,7 +55,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) { return } - if !ctx.Repo.CanRead(models.UnitTypeIssues) && !ctx.User.IsAdmin { + if !ctx.Repo.CanRead(models.UnitTypeIssues) { ctx.Error(http.StatusForbidden, "GetIssueCommentReactions", errors.New("no permission to get reactions")) return } @@ -179,7 +179,7 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp ctx.Error(http.StatusInternalServerError, "comment.LoadIssue() failed", err) } - if comment.Issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) && !ctx.User.IsAdmin { + if comment.Issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) { ctx.Error(http.StatusForbidden, "ChangeIssueCommentReaction", errors.New("no permission to change reaction")) return } @@ -261,7 +261,7 @@ func GetIssueReactions(ctx *context.APIContext) { return } - if !ctx.Repo.CanRead(models.UnitTypeIssues) && !ctx.User.IsAdmin { + if !ctx.Repo.CanRead(models.UnitTypeIssues) { ctx.Error(http.StatusForbidden, "GetIssueReactions", errors.New("no permission to get reactions")) return } @@ -380,7 +380,7 @@ func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, i return } - if issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) && !ctx.User.IsAdmin { + if issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) { ctx.Error(http.StatusForbidden, "ChangeIssueCommentReaction", errors.New("no permission to change reaction")) return } From b39fab41c8b315ba7ddf9f9a4cc522385cf9f720 Mon Sep 17 00:00:00 2001 From: mrsdizzie Date: Fri, 3 Jan 2020 12:13:22 -0500 Subject: [PATCH 13/46] Some more e-mail notification fixes (#9596) * Some more e-mail notification fixes A few more small e-mail notification fixes/changes * Style footer of notification email to be smaller * Include text for when pull request is merged * Don't include original body of issue or PR when merging/closing by setting issue.Content to "" in these cases * Set Re: prefix and meessage-ID headers based on actName instead of checking for a comment. This fixes a bug where certain actions that didn't have a comment were setting Message-ID instead of In-Reply-To which caused some mail programs not to show those messages as they would have had the same Message-ID as a previous message. Also fixes the case where a final comment and closing message would have been displayed out of order if you didn't have a copy of the original issue/pr cretion message. * Update other template footers for consistency --- modules/notification/mail/mail.go | 3 ++- services/mailer/mail.go | 10 ++++++---- templates/mail/issue/assigned.tmpl | 16 ++++++++++------ templates/mail/issue/default.tmpl | 15 +++++++++++---- templates/mail/notify/collaborator.tmpl | 15 ++++++++++----- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/modules/notification/mail/mail.go b/modules/notification/mail/mail.go index 5148434dca23e..6cc6fda14bbb6 100644 --- a/modules/notification/mail/mail.go +++ b/modules/notification/mail/mail.go @@ -53,6 +53,7 @@ func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) { func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) { var actionType models.ActionType + issue.Content = "" if issue.IsPull { if isClosed { actionType = models.ActionClosePullRequest @@ -105,7 +106,7 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode log.Error("pr.LoadIssue: %v", err) return } - + pr.Issue.Content = "" if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest); err != nil { log.Error("MailParticipants: %v", err) } diff --git a/services/mailer/mail.go b/services/mailer/mail.go index a8768de6cdbde..fa40170d464eb 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -177,7 +177,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent commentType := models.CommentTypeComment if ctx.Comment != nil { - prefix = "Re: " commentType = ctx.Comment.Type link = ctx.Issue.HTMLURL() + "#" + ctx.Comment.HashTag() } else { @@ -189,13 +188,16 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent reviewType = ctx.Comment.Review.Type } - fallback = prefix + fallbackMailSubject(ctx.Issue) - // This is the body of the new issue or comment, not the mail body body := string(markup.RenderByType(markdown.MarkupName, []byte(ctx.Content), ctx.Issue.Repo.HTMLURL(), ctx.Issue.Repo.ComposeMetas())) actType, actName, tplName := actionToTemplate(ctx.Issue, ctx.ActionType, commentType, reviewType) + if actName != "new" { + prefix = "Re: " + } + fallback = prefix + fallbackMailSubject(ctx.Issue) + if ctx.Comment != nil && ctx.Comment.Review != nil { reviewComments = make([]*models.Comment, 0, 10) for _, lines := range ctx.Comment.Review.CodeComments { @@ -247,7 +249,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info) // Set Message-ID on first message so replies know what to reference - if ctx.Comment == nil { + if actName == "new" { msg.SetHeader("Message-ID", "<"+ctx.Issue.ReplyReference()+">") } else { msg.SetHeader("In-Reply-To", "<"+ctx.Issue.ReplyReference()+">") diff --git a/templates/mail/issue/assigned.tmpl b/templates/mail/issue/assigned.tmpl index 997e2447fc25e..d302a16f26c7e 100644 --- a/templates/mail/issue/assigned.tmpl +++ b/templates/mail/issue/assigned.tmpl @@ -1,17 +1,21 @@ + {{.Subject}}

@{{.Doer.Name}} assigned you to the {{if .IsPull}}pull request{{else}}issue{{end}} #{{.Issue.Index}} in repository {{.Repo}}.

-

- --- -
- View it on {{AppName}}. -

- + diff --git a/templates/mail/issue/default.tmpl b/templates/mail/issue/default.tmpl index 71291c61bb511..aebad09cd3005 100644 --- a/templates/mail/issue/default.tmpl +++ b/templates/mail/issue/default.tmpl @@ -3,12 +3,15 @@ {{.Subject}} - {{if .ReviewComments}} + - {{end}} + @@ -18,6 +21,8 @@ Closed #{{.Issue.Index}}. {{else if eq .ActionName "reopen"}} Reopened #{{.Issue.Index}}. + {{else if eq .ActionName "merge"}} + Merged #{{.Issue.Index}} into {{.Issue.PullRequest.BaseBranch}}. {{else if eq .ActionName "approve"}} @{{.Doer.Name}} approved this pull request. {{else if eq .ActionName "reject"}} @@ -42,10 +47,12 @@
{{end -}}

+ diff --git a/templates/mail/notify/collaborator.tmpl b/templates/mail/notify/collaborator.tmpl index 4bbf40bbc466e..947b4043999b8 100644 --- a/templates/mail/notify/collaborator.tmpl +++ b/templates/mail/notify/collaborator.tmpl @@ -1,16 +1,21 @@ + {{.Subject}}

You have been added as a collaborator of repository: {{.RepoName}}

-

- --- -
- View it on Gitea. -

+ From ea707f5a77d83d023cb02ce8e44c4b95ac83ef30 Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Fri, 3 Jan 2020 18:47:10 +0100 Subject: [PATCH 14/46] Add branch protection option to block merge on requested changes. (#9592) * Add branch protection option to block merge on requested changes. * Add migration step * Fix check to correct negation * Apply suggestions from code review Language improvement. Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com> * Copyright year. Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com> Co-authored-by: Lauris BH --- models/branches.go | 20 ++++++++++++++++++- models/migrations/migrations.go | 2 ++ models/migrations/v117.go | 17 ++++++++++++++++ modules/auth/repo_form.go | 1 + options/locale/locale_en-US.ini | 3 +++ routers/private/hook.go | 7 +++++++ routers/repo/issue.go | 3 ++- routers/repo/setting_protected_branch.go | 1 + templates/repo/issue/view_content/pull.tmpl | 6 ++++++ templates/repo/settings/protected_branch.tmpl | 7 +++++++ 10 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 models/migrations/v117.go diff --git a/models/branches.go b/models/branches.go index 21b23c75d92dc..385817e4f982b 100644 --- a/models/branches.go +++ b/models/branches.go @@ -44,6 +44,7 @@ type ProtectedBranch struct { ApprovalsWhitelistUserIDs []int64 `xorm:"JSON TEXT"` ApprovalsWhitelistTeamIDs []int64 `xorm:"JSON TEXT"` RequiredApprovals int64 `xorm:"NOT NULL DEFAULT 0"` + BlockOnRejectedReviews bool `xorm:"NOT NULL DEFAULT false"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"updated"` } @@ -166,6 +167,23 @@ func (protectBranch *ProtectedBranch) GetGrantedApprovalsCount(pr *PullRequest) return approvals } +// MergeBlockedByRejectedReview returns true if merge is blocked by rejected reviews +func (protectBranch *ProtectedBranch) MergeBlockedByRejectedReview(pr *PullRequest) bool { + if !protectBranch.BlockOnRejectedReviews { + return false + } + rejectExist, err := x.Where("issue_id = ?", pr.IssueID). + And("type = ?", ReviewTypeReject). + And("official = ?", true). + Exist(new(Review)) + if err != nil { + log.Error("MergeBlockedByRejectedReview: %v", err) + return true + } + + return rejectExist +} + // GetProtectedBranchByRepoID getting protected branch by repo ID func GetProtectedBranchByRepoID(repoID int64) ([]*ProtectedBranch, error) { protectedBranches := make([]*ProtectedBranch, 0) @@ -340,7 +358,7 @@ func (repo *Repository) IsProtectedBranchForMerging(pr *PullRequest, branchName if err != nil { return true, err } else if has { - return !protectedBranch.CanUserMerge(doer.ID) || !protectedBranch.HasEnoughApprovals(pr), nil + return !protectedBranch.CanUserMerge(doer.ID) || !protectedBranch.HasEnoughApprovals(pr) || protectedBranch.MergeBlockedByRejectedReview(pr), nil } return false, nil diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index e8bb3f16d460f..73c9bc113828d 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -288,6 +288,8 @@ var migrations = []Migration{ NewMigration("add user_id prefix to existing user avatar name", renameExistingUserAvatarName), // v116 -> v117 NewMigration("Extend TrackedTimes", extendTrackedTimes), + // v117 -> v118 + NewMigration("Add block on rejected reviews branch protection", addBlockOnRejectedReviews), } // Migrate database to current version diff --git a/models/migrations/v117.go b/models/migrations/v117.go new file mode 100644 index 0000000000000..662d6c7b4679e --- /dev/null +++ b/models/migrations/v117.go @@ -0,0 +1,17 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "xorm.io/xorm" +) + +func addBlockOnRejectedReviews(x *xorm.Engine) error { + type ProtectedBranch struct { + BlockOnRejectedReviews bool `xorm:"NOT NULL DEFAULT false"` + } + + return x.Sync2(new(ProtectedBranch)) +} diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 26ed2bb692923..c87549af92a20 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -171,6 +171,7 @@ type ProtectBranchForm struct { EnableApprovalsWhitelist bool ApprovalsWhitelistUsers string ApprovalsWhitelistTeams string + BlockOnRejectedReviews bool } // Validate validates the fields diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 691190427148d..712cd7ca410fd 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1054,6 +1054,7 @@ pulls.is_checking = "Merge conflict checking is in progress. Try again in few mo pulls.required_status_check_failed = Some required checks were not successful. pulls.required_status_check_administrator = As an administrator, you may still merge this pull request. pulls.blocked_by_approvals = "This Pull Request doesn't have enough approvals yet. %d of %d approvals granted." +pulls.blocked_by_rejection = "This Pull Request has changes requested by an official reviewer." pulls.can_auto_merge_desc = This pull request can be merged automatically. pulls.cannot_auto_merge_desc = This pull request cannot be merged automatically due to conflicts. pulls.cannot_auto_merge_helper = Merge manually to resolve the conflicts. @@ -1417,6 +1418,8 @@ settings.update_protect_branch_success = Branch protection for branch '%s' has b settings.remove_protected_branch_success = Branch protection for branch '%s' has been disabled. settings.protected_branch_deletion = Disable Branch Protection settings.protected_branch_deletion_desc = Disabling branch protection allows users with write permission to push to the branch. Continue? +settings.block_rejected_reviews = Block merge on rejected reviews +settings.block_rejected_reviews_desc = Merging will not be possible when changes are requested by official reviewers, even if there are enough approvals. settings.default_branch_desc = Select a default repository branch for pull requests and code commits: settings.choose_branch = Choose a branch… settings.no_protected_branch = There are no protected branches. diff --git a/routers/private/hook.go b/routers/private/hook.go index dc5001ad4e5a8..c1e283f357ecb 100644 --- a/routers/private/hook.go +++ b/routers/private/hook.go @@ -113,6 +113,13 @@ func HookPreReceive(ctx *macaron.Context, opts private.HookOptions) { }) return } + if protectBranch.MergeBlockedByRejectedReview(pr) { + log.Warn("Forbidden: User %d cannot push to protected branch: %s in %-v and pr #%d has requested changes", opts.UserID, branchName, repo, pr.Index) + ctx.JSON(http.StatusForbidden, map[string]interface{}{ + "err": fmt.Sprintf("protected branch %s can not be pushed to and pr #%d has requested changes", branchName, opts.ProtectedBranchID), + }) + return + } } else if !canPush { log.Warn("Forbidden: User %d cannot push to protected branch: %s in %-v", opts.UserID, branchName, repo) ctx.JSON(http.StatusForbidden, map[string]interface{}{ diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 925903fee420c..46020acb6dfbc 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -962,7 +962,8 @@ func ViewIssue(ctx *context.Context) { } if pull.ProtectedBranch != nil { cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull) - ctx.Data["IsBlockedByApprovals"] = pull.ProtectedBranch.RequiredApprovals > 0 && cnt < pull.ProtectedBranch.RequiredApprovals + ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull) + ctx.Data["IsBlockedByRejection"] = pull.ProtectedBranch.MergeBlockedByRejectedReview(pull) ctx.Data["GrantedApprovals"] = cnt } ctx.Data["IsPullBranchDeletable"] = canDelete && pull.HeadRepo != nil && git.IsBranchExist(pull.HeadRepo.RepoPath(), pull.HeadBranch) diff --git a/routers/repo/setting_protected_branch.go b/routers/repo/setting_protected_branch.go index c279c94b1b64b..8872c7471fac1 100644 --- a/routers/repo/setting_protected_branch.go +++ b/routers/repo/setting_protected_branch.go @@ -244,6 +244,7 @@ func SettingsProtectedBranchPost(ctx *context.Context, f auth.ProtectBranchForm) approvalsWhitelistTeams, _ = base.StringsToInt64s(strings.Split(f.ApprovalsWhitelistTeams, ",")) } } + protectBranch.BlockOnRejectedReviews = f.BlockOnRejectedReviews err = models.UpdateProtectBranch(ctx.Repo.Repository, protectBranch, models.WhitelistOptions{ UserIDs: whitelistUsers, diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 3503a51742d30..cec10a620ea62 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -41,6 +41,7 @@ {{else if .IsFilesConflicted}}grey {{else if .IsPullRequestBroken}}red {{else if .IsBlockedByApprovals}}red + {{else if .IsBlockedByRejection}}red {{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}red {{else if .Issue.PullRequest.IsChecking}}yellow {{else if .Issue.PullRequest.CanAutoMerge}}green @@ -100,6 +101,11 @@ {{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}} + {{else if .IsBlockedByRejection}} +
+ + {{$.i18n.Tr "repo.pulls.blocked_by_rejection"}} +
{{else if .Issue.PullRequest.IsChecking}}
diff --git a/templates/repo/settings/protected_branch.tmpl b/templates/repo/settings/protected_branch.tmpl index b6305861af1b6..bf74a12330792 100644 --- a/templates/repo/settings/protected_branch.tmpl +++ b/templates/repo/settings/protected_branch.tmpl @@ -204,6 +204,13 @@
{{end}} +
+
+ + +

{{.i18n.Tr "repo.settings.block_rejected_reviews_desc"}}

+
+
From 34c5eee703e8904f9eae662bc774ef0b26656799 Mon Sep 17 00:00:00 2001 From: Bagas Sanjaya Date: Sat, 4 Jan 2020 01:41:56 +0700 Subject: [PATCH 15/46] Add footer extra links template (#9576) * Add footer extra links template * [Docs] Update to mention extra links footer template * Commit suggestion from @davidsvantesson Co-Authored-By: David Svantesson * Move template placement to right side of footer Co-authored-by: David Svantesson Co-authored-by: Lauris BH --- docs/content/doc/advanced/customizing-gitea.en-us.md | 4 ++-- templates/base/footer_content.tmpl | 1 + templates/custom/extra_links_footer.tmpl | 0 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 templates/custom/extra_links_footer.tmpl diff --git a/docs/content/doc/advanced/customizing-gitea.en-us.md b/docs/content/doc/advanced/customizing-gitea.en-us.md index 8db022772d0a9..7ae9b74fa2f15 100644 --- a/docs/content/doc/advanced/customizing-gitea.en-us.md +++ b/docs/content/doc/advanced/customizing-gitea.en-us.md @@ -80,10 +80,10 @@ Dont forget to restart your gitea to apply the changes. ### Adding links and tabs -If all you want is to add extra links to the top navigation bar, or extra tabs to the repository view, you can put them in `extra_links.tmpl` and `extra_tabs.tmpl` inside your `custom/templates/custom/` directory. +If all you want is to add extra links to the top navigation bar or footer, or extra tabs to the repository view, you can put them in `extra_links.tmpl` (links added to the navbar), `extra_links_footer.tmpl` (links added to the left side of footer), and `extra_tabs.tmpl` inside your `custom/templates/custom/` directory. For instance, let's say you are in Germany and must add the famously legally-required "Impressum"/about page, listing who is responsible for the site's content: -just place it under your "custom/public/" directory (for instance `custom/public/impressum.html`) and put a link to it in `custom/templates/custom/extra_links.tmpl`. +just place it under your "custom/public/" directory (for instance `custom/public/impressum.html`) and put a link to it in either `custom/templates/custom/extra_links.tmpl` or `custom/templates/custom/extra_links_footer.tmpl`. To match the current style, the link should have the class name "item", and you can use `{{AppSubUrl}}` to get the base URL: `Impressum` diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index 364e58a3d03df..085e7207df835 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -19,6 +19,7 @@ JavaScript licenses {{if .EnableSwagger}}API{{end}} {{.i18n.Tr "website"}} + {{template "custom/extra_links_footer" .}} {{if (or .ShowFooterVersion .PageIsAdmin)}}{{GoVer}}{{end}} diff --git a/templates/custom/extra_links_footer.tmpl b/templates/custom/extra_links_footer.tmpl new file mode 100644 index 0000000000000..e69de29bb2d1d From 4a768e1c3e34fb3129e9a1c83cf16b758bfa5ae5 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Fri, 3 Jan 2020 18:44:08 +0000 Subject: [PATCH 16/46] [skip ci] Updated translations via Crowdin --- options/locale/locale_pt-BR.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index 68c3c4b752cd5..fa3e3d8116990 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -1017,7 +1017,7 @@ issues.review.content.empty=Você precisa deixar um comentário indicando as alt issues.review.reject=alterações solicitadas %s issues.review.pending=Pendente issues.review.review=Revisão -issues.review.reviewers=Revisões +issues.review.reviewers=Revisores issues.review.show_outdated=Mostrar desatualizado issues.review.hide_outdated=Ocultar desatualizado issues.assignee.error=Nem todos os responsáveis foram adicionados devido a um erro inesperado. @@ -1053,6 +1053,7 @@ pulls.is_checking=Verificação de conflitos do merge está em andamento. Tente pulls.required_status_check_failed=Algumas verificações necessárias não foram bem sucedidas. pulls.required_status_check_administrator=Como administrador, você ainda pode aplicar o merge deste pull request. pulls.blocked_by_approvals=Este pull request ainda não possui aprovações suficientes. %d de %d aprovações concedidas. +pulls.blocked_by_rejection=Este pull request possui alterações solicitadas por um revisor oficial. pulls.can_auto_merge_desc=O merge deste pull request pode ser aplicado automaticamente. pulls.cannot_auto_merge_desc=O merge deste pull request não pode ser aplicado automaticamente pois há conflitos. pulls.cannot_auto_merge_helper=Faça o merge manualmente para resolver os conflitos. @@ -1416,6 +1417,8 @@ settings.update_protect_branch_success=Proteção do branch '%s' foi atualizada. settings.remove_protected_branch_success=Proteção do branch '%s' foi desabilitada. settings.protected_branch_deletion=Desabilitar proteção de branch settings.protected_branch_deletion_desc=Desabilitar a proteção de branch permite que os usuários com permissão de escrita realizem push. Continuar? +settings.block_rejected_reviews=Bloquear merge em revisões rejeitadas +settings.block_rejected_reviews_desc=O merge não será possível quando são solicitadas alterações pelos revisores oficiais, mesmo que haja aprovação suficiente. settings.default_branch_desc=Selecione um branch padrão para pull requests e commits de código: settings.choose_branch=Escolha um branch... settings.no_protected_branch=Não há branches protegidos. From bedd7b2833349c151eeb21bec90d5cec0453613a Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Fri, 3 Jan 2020 18:39:12 -0300 Subject: [PATCH 17/46] Fix error logged when repos qs is empty (#9591) * Fix error logged when repos qs is empty * Update routers/user/home.go Co-Authored-By: Lauris BH Co-authored-by: techknowlogick Co-authored-by: Lauris BH --- routers/user/home.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/routers/user/home.go b/routers/user/home.go index ae5975a711c6b..f5e74b240664e 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -389,21 +389,23 @@ func Issues(ctx *context.Context) { reposQuery := ctx.Query("repos") var repoIDs []int64 - if issueReposQueryPattern.MatchString(reposQuery) { - // remove "[" and "]" from string - reposQuery = reposQuery[1 : len(reposQuery)-1] - //for each ID (delimiter ",") add to int to repoIDs - for _, rID := range strings.Split(reposQuery, ",") { - // Ensure nonempty string entries - if rID != "" && rID != "0" { - rIDint64, err := strconv.ParseInt(rID, 10, 64) - if err == nil { - repoIDs = append(repoIDs, rIDint64) + if len(reposQuery) != 0 { + if issueReposQueryPattern.MatchString(reposQuery) { + // remove "[" and "]" from string + reposQuery = reposQuery[1 : len(reposQuery)-1] + //for each ID (delimiter ",") add to int to repoIDs + for _, rID := range strings.Split(reposQuery, ",") { + // Ensure nonempty string entries + if rID != "" && rID != "0" { + rIDint64, err := strconv.ParseInt(rID, 10, 64) + if err == nil { + repoIDs = append(repoIDs, rIDint64) + } } } + } else { + log.Error("issueReposQueryPattern not match with query") } - } else { - log.Error("issueReposQueryPattern not match with query") } isShowClosed := ctx.Query("state") == "closed" From ee9b9365be0733dfac617536a966c4a34d9e590a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 4 Jan 2020 03:23:40 +0100 Subject: [PATCH 18/46] [Docs] Add guide on howto develop API (#9587) * draft 1 * add suggestions thanks to @bagasme @techknowlogick @davidsvantesson * http methods * use permalinks * Apply suggestions from code review Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com> * Apply suggestions from code review Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com> * code format + add to INDEX Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com> Co-authored-by: Lauris BH --- CONTRIBUTING.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a0134974ac0a0..2172aeec243d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,7 @@ - [Code review](#code-review) - [Styleguide](#styleguide) - [Design guideline](#design-guideline) + - [API v1](#api-v1) - [Developer Certificate of Origin (DCO)](#developer-certificate-of-origin-dco) - [Release Cycle](#release-cycle) - [Maintainers](#maintainers) @@ -177,6 +178,43 @@ To maintain understandable code and avoid circular dependencies it is important - **templates:** Golang templates for generating the html output. - **vendor:** External code that Gitea depends on. +## API v1 + +The API is documented by [swagger](http://try.gitea.io/api/swagger) and is based on [GitHub API v3](https://developer.github.com/v3/). +Thus, Gitea´s API should use the same endpoints and fields as GitHub´s API as far as possible, unless there are good reasons to deviate. +If Gitea provides functionality that GitHub does not, a new endpoint can be created. +If information is provided by Gitea that is not provided by the GitHub API, a new field can be used that doesn't collide with any GitHub fields. + +Updating an existing API should not remove existing fields unless there is a really good reason to do so. +The same applies to status responses. If you notice a problem, feel free to leave a comment in the code for future refactoring to APIv2 (which is currently not planned). + +All expected results (errors, success, fail messages) should be documented +([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/repo/issue.go#L319-L327)). + +All JSON input types must be defined as a struct in `models/structs/` +([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/modules/structs/issue.go#L76-L91)) +and referenced in +[routers/api/v1/swagger/options.go](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/swagger/options.go). +They can then be used like the following: +([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/repo/issue.go#L318)). + +All JSON responses must be defined as a struct in `models/structs/` +([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/modules/structs/issue.go#L36-L68)) +and referenced in its category in `routers/api/v1/swagger/` +([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/swagger/issue.go#L11-L16)) +They can be used like the following: +([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/repo/issue.go#L277-L279)) + +In general, HTTP methods are chosen as follows: + * **GET** endpoints return requested object and status **OK (200)** + * **DELETE** endpoints return status **No Content (204)** + * **POST** endpoints return status **Created (201)**, used to **create** new objects (e.g. a User) + * **PUT** endpoints return status **No Content (204)**, used to **add/assign** existing Obejcts (e.g. User) to something (e.g. Org-Team) + * **PATCH** endpoints return changed object and status **OK (200)**, used to **edit/change** an existing object + + +An endpoint which changes/edits an object expects all fields to be optional (except ones to identify the object, which are required). + ## Developer Certificate of Origin (DCO) From 2b8b0f66edcb9e0d87a53913c6ca0d9e1e0c01c6 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Sat, 4 Jan 2020 22:27:19 +0200 Subject: [PATCH 19/46] Add translatable Powered by Gitea text in footer (#9600) --- options/locale/locale_en-US.ini | 1 + templates/base/footer_content.tmpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 712cd7ca410fd..00221573d0dab 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -10,6 +10,7 @@ link_account = Link Account register = Register website = Website version = Version +powered_by = Powered by %s page = Page template = Template language = Language diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index 085e7207df835..db4c19c156bb0 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -1,7 +1,7 @@