Commit Graph
85 Commits
Author SHA1 Message Date
b13b9d3dbd Move Errored PRs out of StatusChecking (#9675) (#9726)
* Move Errored PRs out of StatusChecking (#9675)

* Set Errored PRs out of StatusChecking

* Ensure that api status is correctly set too

* Update models/pull.go

Co-Authored-By: John Olheiser <[email protected]>

Co-authored-by: John Olheiser <[email protected]>

* Update services/pull/check.go

Co-authored-by: John Olheiser <[email protected]>
2020-01-12 20:52:40 +01:00
guillep2kandtechknowlogick ff16099c6d Don't attempt to close issue if already closed (#9699) 2020-01-11 01:42:11 -05:00
Lunny Xiaoandzeripath b9309e52f0 Move wiki related funtions from models to services/wiki (#9355)
* Move wiki related funtions from models to services/wiki
2020-01-07 18:27:36 +00:00
zeripathandGitHub 0d515474b8 Remove stray printf (#9631) 2020-01-07 14:30:03 +00:00
mrsdizzieandLauris BH b39fab41c8 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
2020-01-03 19:13:22 +02:00
John OlheiserandLunny Xiao 7bdf17ec29 Use limited commits (#9572)
Signed-off-by: jolheiser <[email protected]>
2020-01-01 11:54:56 +08:00
zeripathandGitHub 4acca9d2e8 Properly enforce gitea environment for pushes (#9501)
#8982 attempted to enforce the gitea environment for pushes - unfortunately it tested the settings before they were actually read in - and therefore does not do that!
2019-12-27 21:15:04 +00:00
1df701fd1a Add ActionCommentPull action (#9456)
* Add ActionCommentPull action

Adds ActionCommentPull action to distinguish between a comment on an
issue and on a pull request

* Update modules/notification/action/action.go

Co-authored-by: Lunny Xiao <[email protected]>
2019-12-22 08:29:26 +00:00
Mario LubenkaandLunny Xiao 61db834904 Change target branch for pull request (#6488)
* Adds functionality to change target branch of created pull requests

Signed-off-by: Mario Lubenka <[email protected]>

* Use const instead of var in JavaScript additions

Signed-off-by: Mario Lubenka <[email protected]>

* Check if branches are equal and if PR already exists before changing target branch

Signed-off-by: Mario Lubenka <[email protected]>

* Make sure to check all commits

Signed-off-by: Mario Lubenka <[email protected]>

* Print error messages for user as error flash message

Signed-off-by: Mario Lubenka <[email protected]>

* Disallow changing target branch of closed or merged pull requests

Signed-off-by: Mario Lubenka <[email protected]>

* Resolve conflicts after merge of upstream/master

Signed-off-by: Mario Lubenka <[email protected]>

* Change order of branch select fields

Signed-off-by: Mario Lubenka <[email protected]>

* Removes duplicate check

Signed-off-by: Mario Lubenka <[email protected]>

* Use ctx.Tr for translations

Signed-off-by: Mario Lubenka <[email protected]>

* Recompile JS

Signed-off-by: Mario Lubenka <[email protected]>

* Use correct translation namespace

Signed-off-by: Mario Lubenka <[email protected]>

* Remove redundant if condition

Signed-off-by: Mario Lubenka <[email protected]>

* Moves most change branch logic into pull service

Signed-off-by: Mario Lubenka <[email protected]>

* Completes comment

Signed-off-by: Mario Lubenka <[email protected]>

* Add Ref to ChangesPayload for logging changed target branches
instead of creating a new struct

Signed-off-by: Mario Lubenka <[email protected]>

* Revert changes to go.mod

Signed-off-by: Mario Lubenka <[email protected]>

* Directly use createComment method

Signed-off-by: Mario Lubenka <[email protected]>

* Return 404 if pull request is not found. Move written check up

Signed-off-by: Mario Lubenka <[email protected]>

* Remove variable declaration

Signed-off-by: Mario Lubenka <[email protected]>

* Return client errors on change pull request target errors

Signed-off-by: Mario Lubenka <[email protected]>

* Return error in commit.HasPreviousCommit

Signed-off-by: Mario Lubenka <[email protected]>

* Adds blank line

Signed-off-by: Mario Lubenka <[email protected]>

* Test patch before persisting new target branch

Signed-off-by: Mario Lubenka <[email protected]>

* Update patch before testing (not working)

Signed-off-by: Mario Lubenka <[email protected]>

* Removes patch calls when changeing pull request target

Signed-off-by: Mario Lubenka <[email protected]>

* Removes unneeded check for base name

Signed-off-by: Mario Lubenka <[email protected]>

* Moves ChangeTargetBranch completely to pull service. Update patch status.

Signed-off-by: Mario Lubenka <[email protected]>

* Set webhook mode after errors were validated

Signed-off-by: Mario Lubenka <[email protected]>

* Update PR in one transaction

Signed-off-by: Mario Lubenka <[email protected]>

* Move logic for check if head is equal with branch to pull model

Signed-off-by: Mario Lubenka <[email protected]>

* Adds missing comment and simplify return

Signed-off-by: Mario Lubenka <[email protected]>

* Adjust CreateComment method call

Signed-off-by: Mario Lubenka <[email protected]>
2019-12-16 14:20:25 +08:00
Lunny XiaoandGitHub 59d6401486 Use ioutil.TmpDir for new created temp directory (#9368)
* Use os.TmpDir for new created temp directory

* fix error message
2019-12-16 13:17:55 +08:00
Lunny XiaoandGitHub 43ada65571 remove unused method and rename createcommentWithNoAction (#9367) 2019-12-16 11:54:24 +08:00
Lunny Xiaoandtechknowlogick 67b316a954 Refactor comment (#9330)
* Refactor comment

* fix test

* improve code
2019-12-15 16:57:34 -05:00
zeripathandGitHub 3abe17f9e0 Sign protected branches (#8993)
* Move SignMerge to PullRequest

* Add approved signing mode

* As per @guillep2k comment
2019-12-15 11:06:31 +00:00
zeripathandGitHub e3c3b33ea7 Graceful: Xorm, RepoIndexer, Cron and Others (#9282)
* Change graceful to use a singleton obtained through GetManager instead of a global.
* Graceful: Make TestPullRequests shutdownable
* Graceful: Make the cron tasks graceful
* Graceful: AddTestPullRequest run in graceful ctx
* Graceful: SyncMirrors shutdown
* Graceful: SetDefaultContext for Xorm to be HammerContext
* Avoid starting graceful for migrate commands and checkout
* Graceful: DeliverHooks now can be shutdown
* Fix multiple syncing errors in modules/sync/UniqueQueue &  Make UniqueQueue closable
* Begin the process of making the repo indexer shutdown gracefully
2019-12-15 09:51:28 +00:00
Lunny XiaoandAntoine GIRARD ce2d488c94 Move PushToBaseRepo from models to services/pull (#9352) 2019-12-15 04:28:51 +01:00
John OlheiserandLunny Xiao 6715677b2b Push to create repo (#8419)
* Refactor

Signed-off-by: jolheiser <[email protected]>

* Add push-create to SSH serv

Signed-off-by: jolheiser <[email protected]>

* Cannot push for another user unless admin

Signed-off-by: jolheiser <[email protected]>

* Get owner in case admin pushes for another user

Signed-off-by: jolheiser <[email protected]>

* Set new repo ID in result

Signed-off-by: jolheiser <[email protected]>

* Update to service and use new org perms

Signed-off-by: jolheiser <[email protected]>

* Move pushCreateRepo to services

Signed-off-by: jolheiser <[email protected]>

* Fix import order

Signed-off-by: jolheiser <[email protected]>

* Changes for @guillep2k

* Check owner (not user) in SSH
* Add basic tests for created repos (private, not empty)

Signed-off-by: jolheiser <[email protected]>
2019-12-15 10:49:52 +08:00
Lunny XiaoandAntoine GIRARD 7b2ff82d20 Move some repository methods from models to modules/repository (#9353)
* Move some repository methods from models to modules/repository

* fix test
2019-12-14 18:30:01 +01:00
zeripathandAntoine GIRARD 74179d1b5e Remove SavePatch and generate patches on the fly (#9302)
* Save patches to temporary files

* Remove SavePatch and generate patches on the fly

* Use ioutil.TempDir

* fixup! Use ioutil.TempDir

* fixup! fixup! Use ioutil.TempDir

* RemoveAll LocalCopyPath() in initIntergrationTest

* Default to status checking on PR creation

* Remove unnecessary set to StatusChecking

* Protect against unable to load repo

* Handle conflicts

* Restore original conflict setting

* In TestPullRequests update status to StatusChecking before running TestPatch
2019-12-13 23:21:06 +01:00
Lunny Xiaoandtechknowlogick 82e0383d21 Move some pull request functions from models to services (#9266)
* Move some pull request functions from models to services

* Fix test
2019-12-06 21:44:10 -05:00
Lunny XiaoandGitHub 77730db257 Move repoWorkPool outside rename/transfer repository (#9086)
* Move repoWorkPool outside rename/transfer repository

* fix import

* Fix test
2019-12-06 12:00:50 +08:00
David Svantessonandtechknowlogick bac4b78e09 Branch protection: Possibility to not use whitelist but allow anyone with write access (#9055)
* Possibility to not use whitelist but allow anyone with write access

* fix existing test

* rename migration function

* Try to give a better name for migration step

* Clear settings if higher level setting is not set

* Move official reviews to db instead of counting approvals each time

* migration

* fix

* fix migration

* fix migration

* Remove NOT NULL from EnableWhitelist as migration isn't possible

* Fix migration, reviews are connected to issues.

* Fix SQL query issues in GetReviewersByPullID.

* Simplify function GetReviewersByIssueID

* Handle reviewers that has been deleted

* Ensure reviews for test is in a well defined order

* Only clear and set official reviews when it is an approve or reject.
2019-12-03 20:08:56 -05:00
Lunny Xiaoandtechknowlogick 2011a5b818 Extract createComment (#9125)
* Extract createComment

* fix lint

* fix lint
2019-11-30 21:44:39 -05:00
zeripathandLauris BH 60c5339042 Graceful: Cancel Process on monitor pages & HammerTime (#9213)
* Graceful: Create callbacks to with contexts

* Graceful: Say when Gitea is completely finished

* Graceful: Git and Process within HammerTime

Force all git commands to terminate at HammerTime
Force all process commands to terminate at HammerTime
Move almost all git processes to run as git Commands

* Graceful: Always Hammer after Shutdown

* ProcessManager: Add cancel functionality

* Fix tests

* Make sure that process.Manager.Kill() cancels

* Make threadsafe access to Processes and remove own unused Kill

* Remove cmd from the process manager as it is no longer used

* the default context is the correct context

* get rid of double till
2019-11-30 16:40:22 +02:00
Lunny XiaoandGitHub ef9a0370ca Fix panic when diff (#9187)
* fix panic when diff

* improve code
2019-11-28 17:05:57 +08:00
John OlheiserandLunny Xiao 62bcb2b7f1 Add avatar and issue labels to template repositories (#9149)
* Add avatar and issue labels

Signed-off-by: jolheiser <[email protected]>

* Fix redundant if-err

Signed-off-by: jolheiser <[email protected]>
2019-11-25 13:17:51 +08:00
John Olheiserandtechknowlogick e84326aaec Add git hooks and webhooks to template repositories; move to services (#8926)
* Add git hooks and webhooks to template options

Signed-off-by: jolheiser <[email protected]>

* Update models/repo.go

Co-Authored-By: guillep2k <[email protected]>

* Add tooltip if the user can't edit git hooks

Signed-off-by: jolheiser <[email protected]>

* Close repositories after copying git hooks

Signed-off-by: jolheiser <[email protected]>

* Wording

Co-Authored-By: guillep2k <[email protected]>

* Restructure for services

Signed-off-by: jolheiser <[email protected]>

* Return errors

Signed-off-by: jolheiser <[email protected]>

* Move GenerateRepository to using a DBContext

Signed-off-by: jolheiser <[email protected]>

* Wrap with models.WithTx

Signed-off-by: jolheiser <[email protected]>

* Remove debug print

Signed-off-by: jolheiser <[email protected]>

* Move if-error-delete-repo outside WithTx

Signed-off-by: jolheiser <[email protected]>

* Return nil if no repo generated

Signed-off-by: jolheiser <[email protected]>
2019-11-24 12:57:52 -05:00
guillep2kandtechknowlogick d779deef6e Fix show single review comments in the PR page (#9143) 2019-11-24 00:46:16 -05:00
Lunny Xiaoandtechknowlogick 8ab35eefc4 Move mirror sync actions to notification (#9022)
* Move mirror sync actions to notification

* fix lint
2019-11-24 00:16:59 -05:00
Bennoandtechknowlogick eb1b225d9a Send tag create and push webhook when release created on UI (#8671)
* 'update'

* Send push tag event when release created

* send tag create event while release created in UI

* update to go v1.13

* fix gofmt error

* update #8671 move release tag created hook to modules/notification/webhook due to #8802 refactoring

* use NotifyCreateRef and NotifyPushCommits instead of NotifyNewReleaseTag

* move tag notification to correct place
2019-11-22 17:13:57 -05:00
Lunny Xiaoandtechknowlogick d7ac9727bb Move merge actions to notification (#9024)
* Move merge actions to notification

* Add missing mail notification
2019-11-21 12:08:42 -05:00
guillep2kandLauris BH b15f26b1cf Close/reopen issues by keywords in titles and comments (#8866)
* Add close/reopen from comment functionality

* Fix comment

* Rewrite closing/reopening template

* Check xref permissions, move action to services/pull

* Fix RefIsPull field

* Add xref tests

* Fix xref unique filter

* Only highlight keywords for actionable xrefs

* Fix xref neuter filter

* Fix check return status

* Restart CI
2019-11-18 15:13:07 +02:00
guillep2kandzeripath 08ae6bb7ed Rewrite delivery of issue and comment mails (#9009)
* Mail issue subscribers, rework the function

* Simplify a little more

* Fix unused variable

* Refactor mail delivery to avoid heavy load on server

* Avoid splitting into too many goroutines

* Fix comments and optimize GetMaileableUsersByIDs()

* Fix return on errors
2019-11-18 08:08:20 +00:00
guillep2kandzeripath 9930d47be2 Add review comments to mail notifications (#8996) 2019-11-15 12:59:21 +00:00
Lunny XiaoandGitHub 21ae9838e0 Move transfer repository and rename repository on a service package and start action notification (#8573)
* move transfer repository and rename repository on a service package and start action notification

* remove unused codes

* fix lint

* fix bugs

* fix test

* fix test

* fix test

* fix lint

* update go mod and sum
2019-11-15 16:06:11 +08:00
Lars LehtonenandLauris BH 896ad1d9cf services/mirror: fix dropped test errors (#9007) 2019-11-15 06:54:23 +02:00
BennoandLunny Xiao 149a9df9e8 Expand/Collapse Files and Blob Excerpt while Reviewing/Comparing code (#8924)
* update #8659 fold/unfold code diffs

* add fold button style

* update #8659 implement expand up/down codes (blob excerpt)

* fix golint errors

* fix expand direction

* remove debug message

* update css style for blob exceprt

* fix typo in comment

* update style sheet with less

* update expect diff (add SectionInfo)

* update #8942 accept suggested change (fix typo)

* close reader and check file type before get tail section

* adjust button position and check file type before insert fold button

* move index js to web_src

* merge index.js with master

* generate index.js

* update js coding style
2019-11-15 10:52:59 +08:00
Lunny XiaoandGitHub dad67cae54 Refactor pull request review (#8954)
* refactor submit review

* remove unnecessary code

* remove unused comment

* fix lint

* remove duplicated actions

* remove duplicated actions

* fix typo

* fix comment content
2019-11-14 10:57:36 +08:00
guillep2kandzeripath 8282f26250 Don't send notification on pending reviews (#8943) 2019-11-13 18:36:04 +00:00
zeripathandGitHub 722a7c902d Add Close() method to gogitRepository (#8901)
In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.

This PR adds this Close function and adds the Close functions as necessary.

In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.

Fixes #7947
2019-11-13 07:01:19 +00:00
John OlheiserandLunny Xiao 74a6add4d9 Template Repositories (#8768)
* Start work on templates

Signed-off-by: jolheiser <[email protected]>

* Continue work

Signed-off-by: jolheiser <[email protected]>

* Fix IsTemplate vs IsGenerated

Signed-off-by: jolheiser <[email protected]>

* Fix tabs vs spaces

* Tabs vs Spaces

* Add templates to API & start adding tests

Signed-off-by: jolheiser <[email protected]>

* Fix integration tests

Signed-off-by: jolheiser <[email protected]>

* Remove unused User

Signed-off-by: jolheiser <[email protected]>

* Move template tests to existing repos

Signed-off-by: jolheiser <[email protected]>

* Minor re-check updates and cleanup

Signed-off-by: jolheiser <[email protected]>

* make fmt

Signed-off-by: jolheiser <[email protected]>

* Test cleanup

Signed-off-by: jolheiser <[email protected]>

* Fix optionalbool

Signed-off-by: jolheiser <[email protected]>

* make fmt

Signed-off-by: jolheiser <[email protected]>

* Test fixes and icon change

Signed-off-by: jolheiser <[email protected]>

* Add new user and repo for tests

Signed-off-by: jolheiser <[email protected]>

* Fix tests (finally)

Signed-off-by: jolheiser <[email protected]>

* Update meta repo with env variables

Signed-off-by: jolheiser <[email protected]>

* Move generation to create page

Combine with repo create template
Modify API search to prioritize owner for repo

Signed-off-by: jolheiser <[email protected]>

* Fix tests and coverage

Signed-off-by: jolheiser <[email protected]>

* Fix swagger and JS lint

Signed-off-by: jolheiser <[email protected]>

* Fix API searching for own private repos

Signed-off-by: jolheiser <[email protected]>

* Change wording

Signed-off-by: jolheiser <[email protected]>

* Fix repo search test. User had a private repo that didn't show up

Signed-off-by: jolheiser <[email protected]>

* Another search test fix

Signed-off-by: jolheiser <[email protected]>

* Clarify git content

Co-Authored-By: guillep2k <[email protected]>

* Feedback updates

Signed-off-by: jolheiser <[email protected]>

* Add topics WIP

Signed-off-by: jolheiser <[email protected]>

* Finish adding topics

Signed-off-by: jolheiser <[email protected]>

* Update locale

Signed-off-by: jolheiser <[email protected]>
2019-11-11 23:15:29 +08:00
zeripathandGitHub 8eeb2877d5 Adjust error reporting from merge failures and use LC_ALL=C for git (#8548)
There are two major components to this PR:

* This PR handles merge and rebase failures from merging a little more nicely with Flash errors rather a 500.
* All git commands are run in the LC_ALL="C" environment to ensure that error messages are in English. This DefaultLocale is defined in a way that if necessary (due to platform weirdness) it can be overridden at build time using LDFLAGS="-X "code.gitea.io/gitea/modules/git.DefaultLocale=C"" with C changed for the locale as necessary.
2019-11-10 08:42:51 +00:00
1f90147f39 Use templates for issue e-mail subject and body (#8329)
* Add template capability for issue mail subject

* Remove test string

* Fix trim subject length

* Add comment to template and run make fmt

* Add information for the template

* Rename defaultMailSubject() to fallbackMailSubject()

* General rewrite of the mail template code

* Fix .Doer name

* Use text/template for subject instead of html

* Fix subject Re: prefix

* Fix mail tests

* Fix static templates

* [skip ci] Updated translations via Crowdin

* Expose db.SetMaxOpenConns and allow non MySQL dbs to set conn pool params (#8528)

* Expose db.SetMaxOpenConns and allow other dbs to set their connection params
* Add note about port exhaustion

Co-Authored-By: guillep2k <[email protected]>

* Prevent .code-view from overriding font on icon fonts (#8614)

* Correct some outdated statements in the contributing guidelines (#8612)

* More information for drone-cli in CONTRIBUTING.md

* Increases the version of drone-cli to 1.2.0
* Adds a note for the Docker Toolbox on Windows

Signed-off-by: LukBukkit <[email protected]>

* Fix the url for the blog repository (now on gitea.com)

Signed-off-by: LukBukkit <[email protected]>

* Remove TrN due to lack of lang context

* Redo templates to match previous code

* Fix extra character in template

* Unify PR & Issue tempaltes, fix format

* Remove default subject

* Add template tests

* Fix template

* Remove replaced function

* Provide User as models.User for better consistency

* Add docs

* Fix doc inaccuracies, improve examples

* Change mail footer to math AppName

* Add test for mail subject/body template separation

* Add support for code review comments

* Update docs/content/doc/advanced/mail-templates-us.md

Co-Authored-By: 6543 <[email protected]>
2019-11-07 21:34:28 +08:00
Lunny XiaoandGitHub 0109229928 Move release webhook to notification (#8817)
* Move release webhook to notification

* Extract release webhook method

* fix bug

* fix import
2019-11-06 16:25:50 +08:00
Lunny XiaoandGitHub aaeef295bb Move pull webhook to notification (#8805)
* Move pull webhook to notification

* fix fmt
2019-11-05 19:04:08 +08:00
Lunny Xiaoandzeripath 491887d441 Move actions to notification (#8785) 2019-11-03 20:59:09 +00:00
022d2d8beb Move push commits events to notification (#8783)
* Move push commits events to notification

* Update modules/notification/base/null.go

Co-Authored-By: guillep2k <[email protected]>
2019-11-03 14:59:26 +08:00
Lunny XiaoandGitHub 8f26397928 Move issue milestone assign to issue service and move webhook to notification (#8780) 2019-11-02 11:33:20 +08:00
Lunny XiaoandGitHub f518fe6662 Rename HookQueue to hookQueue (#8778)
* Rename HookQueue to hookQueue

* fix lint
2019-11-02 10:35:12 +08:00
Lunny XiaoandGitHub 4b8d9e58c5 Move labels webhooks to notification (#8749)
* Move webhooks to notification

* fix notification
2019-11-02 09:49:57 +08:00
Lunny Xiaoandzeripath 0e7f7df3cf Move webhook to a standalone package under modules (#8747)
* Move webhook to a standalone package under modules

* fix test

* fix comments
2019-11-01 22:51:22 +00:00