Commit Graph
2675 Commits
Author SHA1 Message Date
12960b9d18 [BugFix] remove nil inserts in models (#11096)
* Fix InsertReleases Nil Insert on Attachments

* FIX "No element on slice when insert" & smal refactor

* again

* impruve

* rm useles newline

* Apply suggestions from code review

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

* process insert as a whole

Co-authored-by: zeripath <[email protected]>
2020-04-17 20:42:57 +03:00
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
6543andGitHub a4cab2bbfa [BugFix] ReviewCount: GetApprovalCounts func sorted wrong (#11086)
* FIX by simplify

* code reformat and optimize
2020-04-16 13:44:34 +03:00
Lauris BHandGitHub 4dc62dadce Migrate to go-enry new version (#10906) 2020-04-15 20:40:39 +03:00
6543andGitHub d66b9a4690 Fix Migration 136 (be less aggressive to open pulls missing git files) (#11072)
* be less aggressife to open pulls when migrating

* remove unused
2020-04-14 17:16:07 -05:00
6543andGitHub 10e2f29144 Cache PullRequest Divergence (#10914)
* Cache PullRequest Divergence

* only re-calc divergence if AddTestPullRequestTask() is exec

* migrate already open pulls

* finalize

* take care of closed&not-merged+deleted-branch pull requests

* fix nil pointer exeption

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

* try this

* no error its a warn

* init gitea-repositories-meta

* dont use gitDivergence type

* CI.restart()

* CI.restart()

* CI.restart()

* CI.restart()

* check IsUserAllowedToUpdate independend from CommitsBehind
2020-04-14 09:53:34 -04:00
281029529b ui: Add MergePull comment type instead of close for merge PR (#11058)
Signed-off-by: a1012112796 <[email protected]>

Co-authored-by: Lauris BH <[email protected]>
2020-04-14 09:06:23 +08:00
ad5c43ae5d Reject duplicate AccessToken names (#10994)
* make sure duplicate token names cannot be used

* add check to api routes too

* add @lunny s suggestion

* fix & don't forget User.ID

* AccessTokenByNameExists() return error too

* unique token for each test

* fix lint

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

Co-authored-by: Lanre Adelowo <[email protected]>
2020-04-13 22:02:48 +03:00
cc07b9ca37 Fix CreateComment for SQLite and JS click event on Request Review (#11040)
* fix some bug about Request review

* fix ``CreateComment`` wrong using ,it will not work when use Sqlite
* fix wrong js click event code , it will send wrong data when it has
many choices

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

* Apply suggestions from code review

Co-Authored-By: Lauris BH <[email protected]>

* add getReviewerByIssueIDAndUserID
fix wrong conditions check in initIssueComments after #10972

* call CI again

Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-04-11 01:44:50 -03:00
6543andGitHub bc362ea3c6 remove package code.gitea.io/gitea/modules/git import out of models (#11025) 2020-04-10 14:26:37 +03:00
08208cdfb8 Fix forked repo has no icon and language stat. (#10791)
* Update header.tmpl

* Update _repository.less

* Update pull.go

* Update indexer.go

* Update pull.go

* Update pull.go

* Update indexer.go

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

Thanks the advice from lunny and 6543.

* fix forked repo doesn't have language stat

Modified as suggested by 6543.

* fix forked repo doesn't have language stat

simplify the function.

* fix forked repo doesn't have language stat

update the indexer after the loop

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-04-08 15:13:04 +03:00
71979d9663 Automatically remove Watches, Assignments, etc if user loses access due to being removed as collaborator or from a team (#10997)
* remove a user from being assigned to any issue/PR if (s)he is removed as a collaborator

* fix gender specific comment

* do not remove users that still have access to the repo if they are a member of a team that can access the repo

* add context to errors

* updates

* incorporate review fixes

* Update models/repo_collaboration.go

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

* Update models/repo_collaboration.go

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

* Fix Rebase Relict

* Fix & Impruve

* use xorm builder

* all in one session

* generalize reconsiderIssueAssignees

* Only Unwatch if have no access anymore

* prepare for reuse

* Same things if remove User from Team

* fix lint

* let mysql take time to react

* add description

* CI.restart()

* CI.restart()

Co-authored-by: Lanre Adelowo <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-04-07 22:52:01 +01:00
6543andGitHub ad31d6b5e8 Fix release counter on API repository info (#10968)
Use the same mechanism as the webpage for calculating the release count

Fix #10946
2020-04-06 19:42:30 +01:00
ef89e75d0e add request review from specific reviewers feature in pull request (#10756)
* add request review feature in pull request

add a way to notify specific reviewers to review like github , by add  or delet a  special type
review . The acton is  is similar to Assign ,  so many code reuse the function and items of
Assignee, but the meaning and result is different.

The Permission style is is similar to github, that only writer can add a review request from Reviewers,
but the poster can recall and remove a review request after a reviwer has revied even if he don't have
Write Premission. only manager , the poster and reviewer of a request review can remove it.

The reviewers can be requested to review contain all readers for private repo , for public, contain
all writers and watchers.

The offical Review Request will block merge if Reject can block it.

an other change: add ui otify for Assignees.

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

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

* new change

* add placeholder string

* do some changes follow #10238 to add review requests num on lists also
change icon for review requests to eye

Co-authored-by: Lauris BH <[email protected]>
2020-04-06 19:33:34 +03:00
zeripathandGitHub d26885e2bf Mulitple Gitea Doctor improvements (#10943)
* Add `gitea doctor --list` flag to list the checks that will be run, including those by default
* Add `gitea doctor --run` to run specific checks
* Add `gitea doctor --all` to run all checks
* Add db version checker
* Add non-default recalculate merge bases check/fixer to doctor
* Add hook checker (Fix #9878) and ensure hooks are executable (Fix #6319)
* Fix authorized_keys checker - slight change of functionality here because parsing the command is fragile and we should just check if the authorized_keys file is essentially the same as what gitea would produce. (This is still not perfect as order matters - we should probably just md5sum the two files.)
* Add SCRIPT_TYPE check (Fix #10977)
* Add `gitea doctor --fix` to attempt to fix what is possible to easily fix
* Add `gitea doctor --log-file` to set the log-file, be it a file, stdout or to switch off completely. (Fixes previously undetected bug with certain xorm logging configurations - see @6543 comment.)

Signed-off-by: Andrew Thornton <[email protected]>
2020-04-06 11:44:47 +01:00
zeripathandGitHub ca33a95778 Allow X in addition to x in tasks (#10979)
Signed-off-by: Andrew Thornton <[email protected]>
2020-04-05 17:39:05 -05:00
John OlheiserandGitHub baadb51445 Add gitea-vet (#10948)
* Add copyright

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

* Add gitea-vet and fix non-compliance

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

* Combine tools.go into build.go and clean up

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

* Remove extra GO111MODULE=on

Signed-off-by: jolheiser <[email protected]>
2020-04-05 07:20:50 +01:00
f685edf510 Change review status icons on PR view style to Github style (#10737)
* change the icon of ApproveReview pr from "eye" to "check" like github
* change the icon of RejectReview pr from "x" to "request-change" like github
* add "-" after "{{" which need to be one line (TODO: may be not change all)

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

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: John Olheiser <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-04-03 02:12:42 -03:00
8d99ee2773 Add Organization Wide Labels (#10814)
* Add organization wide labels

Implement organization wide labels similar to organization wide
webhooks. This lets you create individual labels for organizations that can be used
for all repos under that organization (so being able to reuse the same
label across multiple repos).

This makes it possible for small organizations with many repos to use
labels effectively.

Fixes #7406

* Add migration

* remove comments

* fix tests

* Update options/locale/locale_en-US.ini

Removed unused translation string

* show org labels in issue search label filter

* Use more clear var name

* rename migration after merge from master

* comment typo

* update migration again after rebase with master

* check for orgID <=0 per guillep2k review

* fmt

* Apply suggestions from code review

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

* remove unused code

* Make sure RepoID is 0 when searching orgID per code review

* more changes/code review requests

* More descriptive translation var per code review

* func description/delete comment when issue label deleted instead of hiding it

* remove comment

* only use issues in that repo when calculating number of open issues for org label on repo label page

* Add integration test for IssuesSearch API with labels

* remove unused function

* Update models/issue_label.go

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

* Use subquery in GetLabelIDsInReposByNames

* Fix tests to use correct orgID

* fix more tests

* IssuesSearch api now uses new BuildLabelNamesIssueIDsCondition. Add a few more tests as well

* update comment for clarity

* Revert previous code change now that we can use the new BuildLabelNamesIssueIDsCondition

* Don't sort repos by date in IssuesSearch API

After much debugging I've found a strange issue where in some cases MySQL will return a different result than other enigines if a query is sorted by a null collumn. For example with our integration test data where we don't set updated_unix in repository fixtures:

SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 45

Returns different results for MySQL than other engines. However, the similar query:

SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 30

Returns the same results.

This causes integration tests to fail on MySQL in certain cases but would never show up in a real installation. Since this API call always returns issues based on the optionally provided repo_priority_id or the issueID itself, there is no change to results by changing the repo sorting method used to get ids earlier in the function.

* linter is back!

* code review

* remove now unused option

* Fix newline at end of files

* more unused code

* update to master

* check for matching ids before query

* Update models/issue_label.go

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

* Update models/issue_label.go

* update comments

* Update routers/org/setting.go

Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: guillep2k <[email protected]>
Co-authored-by: 6543 <[email protected]>
2020-04-01 01:14:46 -03:00
2c25e75dca Various Merge Base fixes (#10786)
* Fix broken merge base migration v128 for merged PR

* Allow PRs with deleted base branches to still show diff

* as per @lunny

Co-authored-by: Lauris BH <[email protected]>
2020-03-31 16:42:44 +03:00
Lunny XiaoandGitHub 73cf0e2614 Fix milestones too many SQL variables bug (#10880)
* Fix milestones too many SQL variables bug

* Fix test

* Don't display repositories with no milestone and fix tests

* Remove unused code and add some comments
2020-03-31 10:47:00 +03:00
zeripathandGitHub bf847b9397 Upgrade golangci-lint to 1.24.0 (#10894)
* upgrade golangci-lint to 1.24.0 to allow go 1.14 compatibility
* fix golangci-lint errors
* make make golangci-lint work when out of go-path

Signed-off-by: Andrew Thornton <[email protected]>
2020-03-30 21:52:45 +03:00
f490291bea Use subquery to instead In (#10874)
* Use subquery to instead In

* Support excludedLabelNames on issues options

* Fix tests

Co-authored-by: zeripath <[email protected]>
2020-03-30 02:30:39 -03:00
zeripathandGitHub d01763ee14 Protect against NPEs in notifications list (#10879)
Unfortunately there appears to be potential race with notifications
being set before the associated issue has been committed.

This PR adds protection in to the notifications list to log any failures
and remove these notifications from the display.

References #10815 - and prevents the panic but does not completely fix
this.

Signed-off-by: Andrew Thornton <[email protected]>
2020-03-29 20:51:14 +01:00
zeripathandGitHub 209045f55b Slight simplification of accessibleRepositoryCondition (#10875)
* Slight simplification of accessibleRepositoryCondition

Signed-off-by: Andrew Thornton <[email protected]>
2020-03-29 15:31:10 +01:00
61f603cd8a Create a new function to build search repository condition (#10858)
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-03-29 02:27:06 -03:00
zeripathandGitHub ea67e563dd Use ErrKeyUnableToVerify if fail to calc fingerprint in ssh-keygen (#10863)
* Use ErrKeyUnableToVerify if fail to calc fingerprint in ssh-keygen

Fix #3985

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

* Pass up the unable to verify
2020-03-28 19:24:55 +02:00
828a27feeb Add Matrix webhook (#10831)
* Add Matrix webhook

Signed-off-by: Till Faelligen <[email protected]>

* Add template and related translations for Matrix hook

Signed-off-by: Till Faelligen <[email protected]>

* Add actual webhook routes and form

Signed-off-by: Till Faelligen <[email protected]>

* Add missing file

Signed-off-by: Till Faelligen <[email protected]>

* Update modules/webhook/matrix_test.go

* Use stricter regex to replace URLs

Signed-off-by: Till Faelligen <[email protected]>

* Escape url and text

Signed-off-by: Till Faelligen <[email protected]>

* Remove unnecessary whitespace

* Fix copy and paste mistake

Co-Authored-By: Tulir Asokan <[email protected]>

* Fix indention inconsistency

* Use Authorization header instead of url parameter

* Add raw commit information to webhook

Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: Tulir Asokan <[email protected]>
2020-03-28 15:09:55 +02:00
7cd47046ea Handle push rejection in branch and upload (#10854)
* Handle push rejections and push out-of-date in branch creation and
file upload.
* Remove the duplicated sanitize from services/pull/merge
* Move the errors Err(Merge)PushOutOfDate and ErrPushRejected to
modules/git
* Handle errors better in the upload file dialogs

Fix #10460

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-03-28 01:13:18 -03:00
Success GoandGitHub 8cffae65a6 Fix typo of MSSQL (#10850) 2020-03-27 16:12:39 +02:00
e6baa656f7 make avatar lookup occur at image request (#10540)
speed up page generation by making avatar lookup occur at the browser
not at page generation

* Protect against evil email address ".."

* hash the complete email address

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

Co-Authored-By: Lauris BH <[email protected]>
2020-03-27 14:34:39 +02:00
Lauris BHandGitHub a3f90948d8 Set MySQL rowtype to dynamic for new tables (#10833)
* Set mysql rowtype to dynamic for new tables

* Update models.go
2020-03-27 10:44:05 +02:00
453f6e6e5a In authorized_keys use double-quote for windows compatibility (#10841)
Co-authored-by: Lauris BH <[email protected]>
2020-03-27 09:49:39 +02:00
bbd910ed1b Allow to set protected file patterns that can not be changed under no conditions (#10806)
Co-Authored-By: zeripath <[email protected]>
2020-03-27 00:26:34 +02:00
zeripathandGitHub 52cfd2743c Option to set default branch at repository creation (#10803)
* Option to set default branch at repository creation
* Handle template repos with non-default master branch
* Add DefaultBranch handling on creation to API

Fix #9542

Signed-off-by: Andrew Thornton <[email protected]>
2020-03-26 19:14:51 +00:00
Lunny XiaoandGitHub c61b902538 Upgrade xorm to v1.0.0 (#10646)
* Upgrade xorm to v1.0.0

* small nit

* Fix tests

* Update xorm

* Update xorm

* fix go.sum

* fix test

* Fix bug when dump

* Fix bug

* update xorm to latest

* Fix migration test

* update xorm to latest

* Fix import order

* Use xorm tag
2020-03-22 11:12:55 -04:00
b3f4f812d8 account for empty lines in receive-hook message (#10773)
Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: John Olheiser <[email protected]>
2020-03-20 20:21:28 +02:00
a9f4489bbc System-wide webhooks (#10546)
* Create system webhook column (and migration)

* Create system webhook DB methods

Based on the default webhook ones

* Modify router to handle system webhooks and default ones

* Remove old unused admin nav template

* Adjust orgRepoCtx to differentiate system and default webhook URLs

* Assign IsSystemWebhook when creating webhooks

* Correctly use booleans for IsSystemWebhook

* Use system webhooks when preparing webhooks for payload

* Add UI and locale changes

* Use router params to differentiate admin hook pages

* Fix deleting admin webhooks and rename method

* Add clarity to webhook docs

* Revert "Remove old unused admin nav template"

This reverts commit 191a20a7389fe5f6256b0ad6aafd04b9b0e295c5.

* Rename WebHooksNewPost to GiteaHooksNewPost for clarity

* Reintroduce blank line lost during merge conflict

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-03-09 00:08:05 +02:00
John OlheiserandGitHub 4a4fc73ee1 Fix migration (#10641)
Signed-off-by: jolheiser <[email protected]>
2020-03-06 17:43:37 +02:00
3f1c0841cb Granular webhook events (#9626)
* Initial work

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

* Add PR reviews and API coverage

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

* Split up events

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

* Add migration and locale

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

* Format

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

* Revert IsPull

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

* Fix comments

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

* Fix tests

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

* Fix PR reviews

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

* Fix issue_comment

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

* Make fmt

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

* Migrations

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

* Backwards compatible API

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

* Fix feishu

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

* Move session commit

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

Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-03-06 07:10:48 +02:00
zeripathandGitHub 80db44267c Add Approval Counts to pulls list (#10238)
* Add Approval Counts to pulls list

Add simple approvals counts to pulls lists

* Remove non-official counts

* Add PR features to milestone_issues.tmpl
2020-03-06 03:44:06 +00:00
ae452d024e Migration for deleting orphaned dependencies (#10617)
Co-authored-by: Lunny Xiao <[email protected]>
2020-03-05 16:54:50 +01:00
6a57364dc8 Delete dependencies when deleting a repository (#10608)
Co-authored-by: zeripath <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-03-05 09:58:02 +02:00
6420f17fb6 Add migration to fix the old broken merge-bases (#10604)
* Add migration

* Fix migration

* Update models/migrations/v128.go

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

Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-03-05 09:18:07 +02:00
Lauris BHandGitHub 37c3db7be6 Add restricted user filter to LDAP authentication (#10600)
* Add restricted user filter to LDAP authentification

* Fix unit test cases
2020-03-05 08:30:33 +02:00
3d5d21133c OAuth2: add Yandex provider (#8335) (#10564)
* OAuth2: add Yandex provider (#8335)

* remove changes from locale ru-RU

* fmt modules/auth/oauth2/oauth2.go

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

* fix fmt

* Update templates/admin/auth/new.tmpl

* fix fmt

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: 6543 <[email protected]>
Co-authored-by: guillep2k <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-03-05 00:08:52 +02:00
techknowlogickandGitHub bea497ff96 nextcloud oauth (#10562)
Fix #7078
2020-03-02 22:11:45 -05:00
5abe1c52de Display pull request head branch even the branch deleted or repository deleted (#10413)
* Display pull request head branch even the branch deleted or repository deleted

* Merge getHeadRepo/loadHeadRepo and getBaseRepo/loadBaseRepo on pull and fill repo when pr.Issue.Repo is available

* retrieve sha from pull head when pull request branch deleted and fix tests

* Fix test

* Ensure MustHeadRepoName returns empty string if no head repo

Co-authored-by: zeripath <[email protected]>
2020-03-02 22:31:55 +00:00
5e1438ba92 Admin page for managing user e-mail activation (#10557)
* Implement mail activation admin panel

* Add export comments

* Fix another export comment

* again...

* And again!

* Apply suggestions by @lunny

* Add UI for user activated emails

* Make new activation UI work

* Fix lint

* Prevent admin from self-deactivate; add modal

Co-authored-by: zeripath <[email protected]>
2020-03-02 15:25:36 -03:00
Lunny XiaoandGitHub 753c0675c1 Fix migration bug on v96.go (#10572) 2020-03-02 12:53:39 -03:00