Commit Graph
121 Commits
Author SHA1 Message Date
KN4CK3R ebf253b841 Add attachments for PR reviews (#16075)
* First step for multiple dropzones per page.

* Allow attachments on review comments.

* Lint.

* Fixed accidental initialize of the review textarea.

* Initialize SimpleMDE textarea.

Co-authored-by: techknowlogick <[email protected]>
2021-06-14 21:12:33 -04:00
Lunny Xiao 5fef041079 Remove unnecessary goroutine (#16080)
Co-authored-by: techknowlogick <[email protected]>
2021-06-09 15:52:55 -04:00
zeripath ba526ceffe Multiple Queue improvements: LevelDB Wait on empty, shutdown empty shadow level queue, reduce goroutines etc (#15693)
* move shutdownfns, terminatefns and hammerfns out of separate goroutines

Coalesce the shutdownfns etc into a list of functions that get run at shutdown
rather then have them run at goroutines blocked on selects.

This may help reduce the background select/poll load in certain
configurations.

* The LevelDB queues can actually wait on empty instead of polling

Slight refactor to cause leveldb queues to wait on empty instead of polling.

* Shutdown the shadow level queue once it is empty

* Remove bytefifo additional goroutine for readToChan as it can just be run in run

* Remove additional removeWorkers goroutine for workers

* Simplify the AtShutdown and AtTerminate functions and add Channel Flusher

* Add shutdown flusher to CUQ

* move persistable channel shutdown stuff to Shutdown Fn

* Ensure that UPCQ has the correct config

* handle shutdown during the flushing

* reduce risk of race between zeroBoost and addWorkers

* prevent double shutdown

Signed-off-by: Andrew Thornton <[email protected]>
2021-05-15 16:22:26 +02:00
6543 1cd301796c Only log Error on getLastCommitStatus error to let pull list still be visible (#15716) 2021-05-04 14:03:02 +02:00
Lunny Xiao 8202dd1311 Performance improvement for list pull requests (#15447) 2021-04-15 19:34:43 +02:00
zeripath 84f5a0bc62 Always set the merge base used to merge the commit (#15352)
The issue is that the TestPatch will reset the PR MergeBase - and it is possible for TestPatch to update the MergeBase whilst a merge is ongoing. The ensuing merge will then complete but it doesn't re-set the MergeBase it used to merge the PR.

Fixes the intermittent error in git test.

Signed-off-by: Andrew Thornton [email protected]
2021-04-10 09:27:29 +01:00
6543 9c4601bdf8 Code Formats, Nits & Unused Func/Var deletions (#15286)
* _ to unused func options

* rm useless brakets

* rm trifial non used models functions

* rm dead code

* rm dead global vars

* fix routers/api/v1/repo/issue.go

* dont overload import module
2021-04-09 09:40:34 +02:00
KN4CK3R c03e488e14 Add LFS Migration and Mirror (#14726)
* Implemented LFS client.

* Implemented scanning for pointer files.

* Implemented downloading of lfs files.

* Moved model-dependent code into services.

* Removed models dependency. Added TryReadPointerFromBuffer.

* Migrated code from service to module.

* Centralised storage creation.

* Removed dependency from models.

* Moved ContentStore into modules.

* Share structs between server and client.

* Moved method to services.

* Implemented lfs download on clone.

* Implemented LFS sync on clone and mirror update.

* Added form fields.

* Updated templates.

* Fixed condition.

* Use alternate endpoint.

* Added missing methods.

* Fixed typo and make linter happy.

* Detached pointer parser from gogit dependency.

* Fixed TestGetLFSRange test.

* Added context to support cancellation.

* Use ReadFull to probably read more data.

* Removed duplicated code from models.

* Moved scan implementation into pointer_scanner_nogogit.

* Changed method name.

* Added comments.

* Added more/specific log/error messages.

* Embedded lfs.Pointer into models.LFSMetaObject.

* Moved code from models to module.

* Moved code from models to module.

* Moved code from models to module.

* Reduced pointer usage.

* Embedded type.

* Use promoted fields.

* Fixed unexpected eof.

* Added unit tests.

* Implemented migration of local file paths.

* Show an error on invalid LFS endpoints.

* Hide settings if not used.

* Added LFS info to mirror struct.

* Fixed comment.

* Check LFS endpoint.

* Manage LFS settings from mirror page.

* Fixed selector.

* Adjusted selector.

* Added more tests.

* Added local filesystem migration test.

* Fixed typo.

* Reset settings.

* Added special windows path handling.

* Added unit test for HTTPClient.

* Added unit test for BasicTransferAdapter.

* Moved into util package.

* Test if LFS endpoint is allowed.

* Added support for git://

* Just use a static placeholder as the displayed url may be invalid.

* Reverted to original code.

* Added "Advanced Settings".

* Updated wording.

* Added discovery info link.

* Implemented suggestion.

* Fixed missing format parameter.

* Added Pointer.IsValid().

* Always remove model on error.

* Added suggestions.

* Use channel instead of array.

* Update routers/repo/migrate.go

* fmt

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: zeripath <[email protected]>
2021-04-08 18:25:57 -04:00
6543 11229ca539 IsUserAllowedToUpdate ignore igonre if user is nil (#14885) 2021-03-04 19:27:54 +01:00
a1012112796 a5279b74b6 Make manual merge autodetection optional and add manual merge as merge method (#12543)
* Make auto check manual merge as a chooseable mod and add manual merge way on ui

as title, Before this pr, we use same way with GH to check manually merge.
It good, but in some special cases, misjudgments can occur. and it's hard
to fix this bug. So I add option to allow repo manager block "auto check manual merge"
function, Then it will have same style like gitlab(allow empty pr). and to compensate for
not being able to detect THE PR merge automatically, I added a manual approach.

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

* make swager

* api support

* ping ci

* fix TestPullCreate_EmptyChangesWithCommits

* Apply suggestions from code review

Co-authored-by: zeripath <[email protected]>

* Apply review suggestions and add test

* Apply suggestions from code review

Co-authored-by: zeripath <[email protected]>

* fix build

* test error message

* make fmt

* Fix indentation issues identified by @silverwind

Co-authored-by: silverwind <[email protected]>

* Fix tests and make manually merged disabled error on API the same

Signed-off-by: Andrew Thornton <[email protected]>

* a small nit

* fix wrong commit id error

* fix bug

* simple test

* fix test

Co-authored-by: zeripath <[email protected]>
Co-authored-by: silverwind <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2021-03-03 22:41:23 -05:00
zeripath f0e15250b9 Migrate to use jsoniter instead of encoding/json (#14841)
* Migrate to use jsoniter

* fix tests

* update gitea.com/go-chi/binding

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: 6543 <[email protected]>
2021-03-01 22:08:10 +01:00
zeripath 59fd641d1f When Deleting Repository only explicitly close PRs whose base is not this repository (#14823)
When Deleting Repository only explicitly close PRs whose base is not this repository

Fix #14775

Signed-off-by: Andrew Thornton <[email protected]>
2021-03-01 18:39:44 +01:00
zeripath 3d8b5ad5f3 Fix a couple of CommentAsPatch issues. (#14804)
* CutDiffAroundLine makes the incorrect assumption that `---` and `+++` always represent part of the header of a diff.

This PR adds a flag to its parsing to prevent this problem and adds a streaming parsing technique to CutDiffAroundLine using an io.pipe instead of just sending data to an unbounded buffer.

Fix #14711

Signed-off-by: Andrew Thornton <[email protected]>

* Handle unquoted comment patch files

When making comment patches unfortunately the patch does not always quote the filename
This makes the diff --git header ambiguous again.

This PR finally adds handling for ambiguity in to parse patch

Fix #14812

Signed-off-by: Andrew Thornton <[email protected]>

* Add in testing for no error

There is no way currently for CutDiffAroundLine in this test to cause an
error however, it should still be tested.

Signed-off-by: Andrew Thornton <[email protected]>
2021-02-27 19:46:14 +01:00
a1012112796 ac701637b4 Add dismiss review feature (#12674)
* Add dismiss review feature

refs:
    https://github.blog/2016-10-12-dismissing-reviews-on-pull-requests/
    https://developer.github.com/v3/pulls/reviews/#dismiss-a-review-for-a-pull-request

* change modal ui and error message

* Add unDismissReview api

Signed-off-by: a1012112796 <[email protected]>
Co-authored-by: zeripath <[email protected]>
Co-authored-by: 6543 <[email protected]>
2021-02-11 18:32:25 +01:00
6543 0d1444751f [API] Add pagination to ListBranches (#14524)
* make PaginateUserSlice generic -> PaginateSlice

* Add pagination to ListBranches

* add skip, limit to Repository.GetBranches()

* Move routers/api/v1/utils/utils PaginateSlice -> modules/util/paginate.go

* repo_module.GetBranches paginate

* fix & rename & more logging

* better description

Co-authored-by: zeripath <[email protected]>
Co-authored-by: a1012112796 <[email protected]>
2021-02-03 20:06:13 +01:00
Jimmy Praet 4d9349123f label and milestone webhooks on issue/pull creation (#14363) 2021-01-17 16:15:57 +02:00
Lunny Xiao 3c96a37162 Some code improvements (#14266) 2021-01-06 19:23:57 +00:00
Jimmy Praet e6acce649b Send notifications for mentions in pulls, issues, (code-)comments (#14218)
Fixes #14187: mention handling extracted from email notification code
Fixes #14013: add notification for mentions in pull request code comments
Fixes #13450: Not receiving any emails with setting "Only Email on Mention"
2021-01-02 18:04:02 +01:00
6543 a19447aed1 migrate from com.* to alternatives (#14103)
* remove github.com/unknwon/com from models

* dont use "com.ToStr()"

* replace "com.ToStr" with "fmt.Sprint" where its easy to do

* more refactor

* fix test

* just "proxy" Copy func for now

* as per @lunny
2020-12-25 11:59:32 +02:00
Cirno the Strongest 2c9dd71140 Standardize Co-Authored-By / Reviewed-By strings (#14097)
* Standardize Co-Authored-By / Reviewed-By strings

* Use lowercase variant

Co-authored-by: Lunny Xiao <[email protected]>
2020-12-21 21:19:33 -05:00
Mura Li 09304db9a5 Use the text of pull-request as the squash commit's message (#13071)
Originally, it was filled by the commit messages of the involved
commits. In this change, we use the headline comment of the pull
request as the commit message when it is a squash merge.

Thanks to @zeripath for suggesting the idea.

Fixes #12365

Co-authored-by: Mura Li <[email protected]>
2020-12-21 17:46:14 +01:00
Cirno the Strongest f3c4baa84b Show dropdown with all statuses for commit (#13977)
* Show dropdown with all statuses for commit

* Use popups

* Remove unnecessary change

* Style popup

* Use divided list

* As per @silverwind

* Refactor GetLastCommitStatus

* Missing dropdown on repo home and commit page

* Fix tests

* Make status icon be a part of a link on PR list

* Fix missing translation call

* Indent fix

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-12-20 11:13:12 +08:00
Cirno the Strongest efa9a8a6e3 Show status check for merged PRs (#13975)
* Show status check for merged PRs

* Handle PRs with no commits

* Styling

Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: 6543 <[email protected]>
2020-12-18 13:37:55 +01:00
6543 e483220ea3 [Refactor] CombinedStatus and CommitStatus related functions & structs (#14026)
* RM unused struct

* rename (*CommitStatus) loadRepo() -> loadAttributes()

* move ToCommitStatus into its own file

* use CommitStatusState instead of StatusState

* move CombinedStatus convertion into convert package

* let models.GetLatestCommitStatus use repoID direct and accept ListOptions

* update swagger docs

* fix tests

* Fix swagger docs

* rm page

* fix swagger docs!!!

* return json null

* always return json

* rename api.Status to api.CommitStatus

* fix swagger docs

* sec swagger fix
2020-12-18 11:33:32 +08:00
Jimmy Praet e7a77d32cc Fix correct diff view for PR review comments in PR view page (#14002)
Fixes #13683.

The diff snippet that provides context for a code review comment on the pull request timeline page used to be calculated based on the headCommitID. But in 1.13, with PR #13448, this changed to the commitID from the blame for the commented line, which seems to cause these incorrect review comment diff snippets.

Co-authored-by: Lunny Xiao <[email protected]>
2020-12-16 11:54:58 +02:00
a1012112796 682f0b0460 Fix Pull Merge when tag with same name as base branch exist (#13882)
fix dst refspec error in 'Push back to upstream' when base branch have
same name with a tag.

fix #13851
Signed-off-by: a1012112796 <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: zeripath <[email protected]>
2020-12-08 02:46:50 +01:00
a1012112796 9c26dc1f3a Add block on official review requests branch protection (#13705)
Signed-off-by: a1012112796 <[email protected]>

Co-authored-by: Lauris BH <[email protected]>
2020-11-28 21:30:46 +02:00
John Olheiser 979fbe086c Increment skip to avoid infini-loop (#13703)
Signed-off-by: jolheiser <[email protected]>

Co-authored-by: Lauris BH <[email protected]>
2020-11-27 22:00:52 +02:00
Jimmy Praet 03fa2eccbc Use chronological commit order in default squash message (#13661) (#13696) 2020-11-25 15:08:17 -05:00
zeripath b091c994b5 Comments on review should have the same sha (#13448)
* When replying to an outdated comment it should not appear on the files page

This happened because the comment took the latest commitID as its base instead of the
reviewID that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

Signed-off-by: Andrew Thornton <[email protected]>

* fix test

Signed-off-by: Andrew Thornton <[email protected]>

* Fix broken migration

Signed-off-by: Andrew Thornton <[email protected]>

* fix mssql

Signed-off-by: Andrew Thornton <[email protected]>

* Create temporary table because ... well MSSQL ...

Signed-off-by: Andrew Thornton <[email protected]>

* Create temporary table because ... well MSSQL ...

Signed-off-by: Andrew Thornton <[email protected]>

* Create temporary table because ... well MSSQL ...

Signed-off-by: Andrew Thornton <[email protected]>

* fix mssql

Signed-off-by: Andrew Thornton <[email protected]>

* move session within the batch

Signed-off-by: Andrew Thornton <[email protected]>

* regen the sqlcmd each time round the loop

Signed-off-by: Andrew Thornton <[email protected]>

* as per @lunny

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2020-11-09 01:15:09 -05:00
Lunny Xiao 35cc82abbf Revert "Replies to outdated code comments should also be outdated (#13217)" (#13439)
This reverts commit 3cab3bee57.
2020-11-06 09:04:21 +02:00
zeripath 3cab3bee57 Replies to outdated code comments should also be outdated (#13217)
* When replying to an outdated comment it should not appear on the files page

This happened because the comment took the latest commitID as its base instead of the
reviewID that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

Signed-off-by: Andrew Thornton <[email protected]>

* fix test

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2020-11-04 17:55:15 -05:00
zeripath de6e427a01 go-version constraints ignore pre-releases (#13234)
Go-version constraints ignore pre-releases.

Rather than change the library further this PR simply changes
the git version comparison to use simple version compare ignoring the
issue of pre-releases.

Signed-off-by: Andrew Thornton <[email protected]>
2020-10-21 11:42:08 -04:00
赵智超 dfa7291f8f [Enhancement] Allow admin to merge pr with protected file changes (#12078)
* [Enhancement] Allow admin to merge pr with protected file changes

As tilte, show protected message in diff page and merge box.

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

* remove unused ver

* Update options/locale/locale_en-US.ini

Co-authored-by: Cirno the Strongest <[email protected]>

* Add TrN

* Apply suggestions from code review

* fix lint

* Update options/locale/locale_en-US.ini

Co-authored-by: zeripath <[email protected]>

* Apply suggestions from code review

* move pr proteced files check to TestPatch
* Call TestPatch when protected branches settings changed

* Apply review suggestion @CirnoT

* move to service @lunny

* slightly restructure routers/private/hook.go

Adds a lot of comments and simplifies the logic

Signed-off-by: Andrew Thornton <[email protected]>

* placate lint

Signed-off-by: Andrew Thornton <[email protected]>

* skip duplicate protected files check

* fix check logic

* slight refactor of TestPatch

Signed-off-by: Andrew Thornton <[email protected]>

* When checking for protected files changes in TestPatch use the temporary repository

Signed-off-by: Andrew Thornton <[email protected]>

* fix introduced issue with hook

Signed-off-by: Andrew Thornton <[email protected]>

* Remove the check on PR index being greater than 0 as it unnecessary

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Cirno the Strongest <[email protected]>
Co-authored-by: zeripath <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-10-13 14:50:57 -04:00
赵智超 8be3e439c2 Add team support for review request (#12039)
Add team support for review request

Block #11355

Signed-off-by: a1012112796 <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: Andrew Thornton <[email protected]>
2020-10-12 20:55:13 +01:00
6543 df4bbcd235 Fix error create comment on outdated file (#13041)
* FIX

* more specific

Co-authored-by: techknowlogick <[email protected]>
2020-10-05 20:18:55 -04:00
zeripath 4979f15c3f Add configurable Trust Models (#11712)
* Add configurable Trust Models

Gitea's default signature verification model differs from GitHub. GitHub
uses signatures to verify that the committer is who they say they are -
meaning that when GitHub makes a signed commit it must be the committer.
The GitHub model prevents re-publishing of commits after revocation of a
key and prevents re-signing of other people's commits to create a
completely trusted repository signed by one key or a set of trusted
keys.

The default behaviour of Gitea in contrast is to always display the
avatar and information related to a signature. This allows signatures to
be decoupled from the committer. That being said, allowing arbitary
users to present other peoples commits as theirs is not necessarily
desired therefore we have a trust model whereby signatures from
collaborators are marked trusted, signatures matching the commit line
are marked untrusted and signatures that match a user in the db but not
the committer line are marked unmatched.

The problem with this model is that this conflicts with Github therefore
we need to provide an option to allow users to choose the Github model
should they wish to.

Signed-off-by: Andrew Thornton <[email protected]>

* Adjust locale strings

Signed-off-by: Andrew Thornton <[email protected]>

* as per @6543

Co-authored-by: 6543 <[email protected]>

* Update models/gpg_key.go

* Add migration for repository

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: 6543 <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
2020-09-20 00:44:55 +08:00
zeripath 342e49e325 Stop cloning unnecessarily on PR update (#12839)
* Stop cloning unnecessarily on PR update

Fix #12740

Signed-off-by: Andrew Thornton <[email protected]>

* Remove unnecessary delete

Signed-off-by: Andrew Thornton <[email protected]>

* fix lint

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
2020-09-14 23:32:31 -04:00
Lunny Xiao 642c3c258b Fix git open close bug (#12834) 2020-09-14 19:42:40 +01:00
6543 bc11caff94 [Vendor] Switch go-version lib (#12719)
* vendor: switch from "mcuadros/go-version" to "hashicorp/go-version"

* Adapt P1

* simplify

* fix lint

* adapt

* fix lint & rm old code

* no deadlock

* rm RWMutex and check GoVersion only 1-time

* Copyright header

Co-authored-by: techknowlogick <[email protected]>
2020-09-05 12:42:58 -04:00
zeripath 9c9c3348bb Prevent NPE on commenting on lines with invalidated comments (with migration) (#12549)
* Prevent NPE on commenting on lines with invalidated comments

Only check for a review if we are replying to a previous review.

Prevent the NPE in #12239 by assuming that a comment without a Review is
non-pending.

Fix #12239

Signed-off-by: Andrew Thornton <[email protected]>

* Add hack around to show the broken comments

Signed-off-by: Andrew Thornton <[email protected]>

* Add migration and remove template hacks

Signed-off-by: Andrew Thornton <[email protected]>
2020-08-21 10:53:14 +03:00
zeripath d15bb17b78 Default empty merger list to those with write permissions (#12535)
Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
2020-08-20 10:48:40 +03:00
zeripath 74bd9691c6 Re-attempt to delete temporary upload if the file is locked by another process (#12447)
Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util.

Fix #12339

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: silverwind <[email protected]>
2020-08-11 21:05:34 +01:00
6543 262fce6db4 Update CommitsAhead CommitsBehind on Pull BaseBranch Change too (#11912) 2020-06-16 12:52:33 -05:00
zeripath 0973c03601 Handle more pathological branch and tag names (#11843)
* Handle more pathological branch and tag names

Signed-off-by: Andrew Thornton <[email protected]>

* Fix failing test

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2020-06-11 19:49:47 -04:00
zeripath 09f7d84f4c Ensure rejected push to refs/pull/index/head fails nicely (#11724)
A pre-receive hook that rejects pushes to refs/pull/index/head
will cause a broken PR which causes an internal server error
whenever it is viewed. This PR handles prevents the internal server
error by handling non-existent pr heads and sends a flash error
informing the creator there was a problem.

Signed-off-by: Andrew Thornton <[email protected]>
2020-06-08 19:07:41 +01:00
赵智超 0903b1ac8c Add push commits history comment on PR time-line (#11167)
* Add push commits history comment on PR time-line
* Add notify by email and ui of this comment type also

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

* Add migrations for IsForcePush
* fix wrong force-push judgement
* Apply suggestions from code review
* Remove commit number check
* add own notify fun
* fix some typo

Co-authored-by: guillep2k <[email protected]>

* fix lint

* fix style again, I forgot something before

* Change email notify way

* fix api

* add number check if It's force-push

* Add repo commit link fuction
remove unnecessary check
skip show push commits comment which not have commits alive

* Update issue_comment.go

* Apply suggestions from code review

Co-authored-by: mrsdizzie <[email protected]>

* Apply suggestions from code review

* fix ui view

Co-authored-by: silverwind <[email protected]>

* fix height

* remove unnecessary style define

* simplify GetBranchName

* Apply suggestions from code review

* save commit ids and isForce push by json
* simplify GetBranchName

* fix bug

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: mrsdizzie <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: silverwind <[email protected]>
2020-05-20 09:47:24 -03:00
6543 84bcb3451a Check Push permissions on IsUserAllowedToUpdate (#11448) 2020-05-16 20:48:30 -04:00
6543 c52d48aae4 Prevent merge of outdated PRs on protected branches (#11012)
* Block PR on Outdated Branch

* finalize

* cleanup

* fix typo and sentences

thanks @guillep2k

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

Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-04-16 22:00:36 -03:00
6543 f7ecc2bee7 fix (#11066) 2020-04-14 19:29:31 +03:00