Commit Graph
599 Commits
Author SHA1 Message Date
78f0b5b92b Add option to API to update PullRequest base branch (#11666) (#11796)
* EditPull: add option to change base

Close #11552

Co-authored-by: Lauris BH <[email protected]>
2020-06-07 23:20:53 +03:00
6543andGitHub 20951c5c21 In File Create/Update API return 404 if Branch does not exist (#11791) (#11795)
* In File Create/Update API return 404 if Branch does not exist (#11791)

* v1.12 version ;)
2020-06-07 22:50:19 +03:00
Cirno the StrongestandGitHub 287e2c781b Fix timezone on issue deadline (#11697) (#11784)
* Fix timezone on issue deadline

* FormatDate

Co-authored-by: zeripath <[email protected]>
(cherry picked from commit bbe13b60cd)
2020-06-06 13:44:16 +01:00
6543andGitHub 70739c32a9 Handle expected errors in FileCreate & FileUpdate API (#11643) (#11718)
as title

needed for #11641
2020-06-01 07:28:52 +01:00
6543andGitHub 762c0463f4 Handle expected errors in AddGPGkey API (#11644) (#11661)
* handle GPG Parse & Email Errors

* correct TEST

* update Swagger

* more Docu
2020-05-28 18:16:41 -04:00
zeripathandGitHub a777f8ae75 Allow different HardBreaks settings for documents and comments (#11515) (#11599)
GH has different HardBreaks behaviour for markdown comments and documents.

Comments have hard breaks and documents have soft breaks - therefore Gitea's rendering will always be different from GH's if we only provide one setting.

Here we split the setting in to two - one for documents and one for comments and other things.

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

Changes to index.js as per @silverwind 
Co-authored-by: silverwind <[email protected]>

Changes to docs as per @guillep2k 
Co-authored-by: guillep2k <[email protected]>
2020-05-24 11:45:56 +01:00
8525a48581 Fix repo-list private and total count bugs (#11500) (#11532)
* Fix repo-list private and total count bugs

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

* Ensure limited and private org public repos are displayed on "private"

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

* switch from onlyPrivate to is_private

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

* Generate swagger

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

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

Co-authored-by: guillep2k <[email protected]>
2020-05-21 08:23:20 -05:00
414c9ee76a Make API EditIssue and EditPullRequest issue notifications (#11123)
* Make API EditIssue and EditPullRequest issue notifications

Restructure models.UpdateIssueByAPI and EditIssue/EditPullRequest
to issue notifications

Fix #10014

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

* As per @6543

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

* update status!

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

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: John Olheiser <[email protected]>
Co-authored-by: guillep2k <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-05-17 00:05:19 +03:00
c86bc8e061 Add paging and archive/private repository filtering to dashboard list (#11321)
* Add archived options to SearchRepository

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

* Add only-private search

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

* Add filter options and paging to dashboard repository page

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

* swagger generate

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

* fix-swagger-again

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

* as per @mrsdizzie also remember state

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

Co-authored-by: Lauris BH <[email protected]>
2020-05-16 23:07:01 +03:00
6543andGitHub 7257c39ddf Refactor Milestone related (#11225) 2020-05-12 22:54:35 +01:00
zeripathandGitHub c42c31a111 Correctly set the organization num repos (#11339)
* Correctly set the organization num repos

Correctly set the organization num repos to the number of
accessible repos for the user

Fix #11194

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

* as per @lunny

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

* attempt to fix mssql

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

* Update models/user.go

* Explicit columns

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

* Add test and fix 0 counted orgs

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

* remove orgname from api

Signed-off-by: Andrew Thornton <[email protected]>
2020-05-12 01:04:08 +03:00
32b8172e56 Consolidate API for getting single commit (#11368)
* Allow Git ref for /repos/{owner}/{repo}/git/commits/{sha}

* Consolidate API for getting single commit

* Fix tests and do it differently

Co-authored-by: zeripath <[email protected]>
2020-05-11 12:44:36 +03:00
6543andGitHub cd4f7ba5bf Fix tracked time issues (#11349)
* Fix nil exeption: #11313

* fix 500

* activate test 😆

* move logic
2020-05-09 11:18:44 -03:00
赵智超andGitHub 119173130a Add default CommitID for create pull review api (#11334)
If user create pull review through api but not set CommitID,
I think it's necessary to use last headCommitID as default seting,
or this review will be considered as stale review which is wrong

Signed-off-by: a1012112796 <[email protected]>
2020-05-08 19:50:23 +01:00
6543andGitHub 486e4c8087 When deleting a tracked time through the API return 404 not 500 (#11319) 2020-05-07 18:54:33 +01:00
c97494a4f4 API: Add pull review endpoints (#11224)
* API: Added pull review read only endpoints

* Update Structs, move Conversion, Refactor

* refactor

* lint & co

* fix lint + refactor

* add new Review state, rm unessesary, refacotr loadAttributes, convert patch to diff

* add DeletePullReview

* add paggination

* draft1: Create & submit review

* fix lint

* fix lint

* impruve test

* DONT use GhostUser for loadReviewer

* expose comments_count of a PullReview

* infent GetCodeCommentsCount()

* fixes

* fix+impruve

* some nits

* Handle Ghosts 👻

* add TEST for GET apis

* complete TESTS

* add HTMLURL to PullReview responce

* code format as per @lafriks

* update swagger definition

* Update routers/api/v1/repo/pull_review.go

Co-authored-by: David Svantesson <[email protected]>

* add comments

Co-authored-by: Thomas Berger <[email protected]>
Co-authored-by: David Svantesson <[email protected]>
2020-05-02 03:20:51 +03:00
6543andGitHub e9e8638f18 Return issue subscription status from API subscribe (#10966)
* [API] issue subscription indicate by http status

* CI.restart()
2020-04-30 23:55:24 +01:00
6543andGitHub ab69b9b1a6 Refactor UpdateOAuth2Application (#11034)
Following on from #11008 refactor UpdateOAuth2Application
2020-04-30 18:50:47 +01:00
6543andGitHub bfda0f3864 [API] ListIssues add filter for milestones (#10148)
* Refactor Issue Filter Func

* ListIssues add filter for milestones

* as per @lafriks

* documentation ...
2020-04-30 01:15:39 -03:00
6543andGitHub 4ddfe0d07a Fix GetContents(): Dont't ignore Executables (#11192)
* Refactor: dont expose help functions

* repofiles GetContents: dont ignore executables

* CI.restart()
2020-04-24 19:20:22 +03:00
silverwindandGitHub 7e20f1cb5b enable ENABLE_HARD_LINE_BREAK by default (#11162)
enable ENABLE_HARD_LINE_BREAK by default

This matches GitHub's rendering.

Fix #11155
2020-04-21 23:13:56 +01:00
74cc3c5e18 Allow list collaborators for users with Read access to repo (#9995)
Co-authored-by: Lunny Xiao <[email protected]>
2020-04-21 11:22:04 -04:00
6543andGitHub bb4261a5ed Add issue subscription check to API (#10967)
close #10962

Adds `GET /api/v1​/repos​/{owner}​/{repo}​/issues​/{index}​/subscriptions​/check`
 -> return a `WachInfo`
2020-04-21 14:48:53 +01:00
6543andGitHub b9ed8d8497 make branch parameter optional for /api/v1/repos/{owner}/{repo}/contents/{filepath} (#11067) 2020-04-20 17:47:05 +01:00
CirnoTandGitHub d2693f18de Support organization labels for PRs in API (#11135)
Fix `/repos/{owner}/{repo}/pulls` and `/repos/{owner}/{repo}/pulls/{index}` to accept organization labels during PR creation and edition.
2020-04-20 14:10:45 +01:00
6543andGitHub 3c5a4d094a [API] Add branch delete (#11112)
* use same process as in routers/repo/branch.go/deleteBranch

* make sure default branch can not be deleted

* remove IsDefaultBranch from UI process - it is worth its own pull

* permissions
2020-04-19 10:38:09 +08:00
38d5f88a81 Add X-Total-Count on /repos/{owner]/{repo}/pulls API (#11113)
Co-authored-by: techknowlogick <[email protected]>
2020-04-18 02:53:56 -04: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 70fab7e26a document 404 responce and meaning (#11073) 2020-04-15 16:03:05 +03:00
2e85ad665a Contents API should return 404 on not exist (#10323)
* Return 404 on not exist

* swagger update and use git.IsErrNotExist

* Handle delete too

* Handle delete too x2

* Fix pr 10323 (#3)

* fix TESTS

* leafe a note for fututre

* placate golangci-lint

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

* Update integrations/api_repo_file_delete_test.go

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

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Antoine GIRARD <[email protected]>
Co-authored-by: 6543 <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-04-15 02:18:51 -03: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
6543andGitHub 0dadea19bc [Api] Check Notify (always return json) (#10059)
* BEAKING: check return status based on struct not httpStatus

* update Tests

* CI.restart()
2020-04-10 19:49:39 -04:00
743022116d Add Get/Update for api/v1/user/applications/oauth2 (#11008)
Add api methods for getting and updating user oauth2 applications.

Signed-off-by: Dan Molik <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2020-04-09 19:37:31 -05:00
b40107c416 [suggest] change merge strategy: do not check write access if user in merge white list (#10951)
* [suggest] change merge strategy: do not check write access if user in merge white list #10935

(cherry picked from commit ba74fc6389dfcad03c273441a49b54e4d38c86ee)

* fix NPE

* Fix cross compile (#10952)

* Fix cross compile

* Add test for cross compile

* Fix drone

* Fix drone

* Also prevent CC environment not to generate

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

* fix merge box icon color bug (#10974)

that because need some space beturn ``text`` and color defines

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

* [skip ci] Updated translations via Crowdin

* Allow X in addition to x in tasks (#10979)

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

* remove api: merge  reqRepoWriter

Co-authored-by: zeripath <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: 赵智超 <[email protected]>
Co-authored-by: GiteaBot <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-04-08 14:26:50 +03:00
6543andGitHub 3d63caa542 [API] Get a single commit via Ref (#10915)
* GET /repos/:owner/:repo/commits/:ref

* add Validation Checks

* Fix & Extend TEST

* add two new tast cases
2020-04-07 22:54:46 -04: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
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
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 48890ce546 Allow site admin to check /api/v1/orgs endpoints (#10867)
Fix #9950

Signed-off-by: Andrew Thornton <[email protected]>
2020-03-28 19:45:55 +00: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
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
dcaa5643d7 Fix branch api canPush and canMerge (#10776)
Co-authored-by: techknowlogick <[email protected]>
2020-03-20 23:41:33 -04:00
zeripathandGitHub 33c5e5e7fa Prevent panic in stopwatch (#10670)
Signed-off-by: Andrew Thornton <[email protected]>
2020-03-08 14:46:24 -03: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
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
6543andGitHub 4160bd6ef1 Remove Unused Functions (#10516)
* remove ReplaceLeft

* remove GetRepositoryByOwnerAndName chainload to models.GetRepositoryByOwnerAndName

* remove CheckUnitUser chainload to models.CheckUnitUser

* remove MakeAssigneeList

* remove DownloadDiff & DownloadPatch -> DownloadDiffOrPatch

* remove GetRandomBytesAsBase64

* remove PushUpdateDeleteTags

* remove GetUserByKeyID
(you still can resolve user by "k, err := GetPublicKeyByID; userID := k.OwnerID")

* remove BasicAuthEncode from struct package -> same function in modules/base/tools !

* remove UserID from api.utils

* remove unused func from structs package
2020-03-02 00:05:44 +02:00
af61b2249a adds API endpoints to manage OAuth2 Application (list/create/delete) (#10437)
* add API endpoint to create OAuth2 Application.

* move endpoint to /user. Add swagger documentations and proper response type.

* change json tags to snake_case. add CreateOAuth2ApplicationOptions to swagger docs.

* change response status to Created (201)

* add methods to list OAuth2 apps and delete an existing OAuth2 app by ID.

* add APIFormat convert method and file header

* fixed header

* hide secret on oauth2 application list

* add Created time to API response

* add API integration tests for create/list/delete OAuth2 applications.

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: zeripath <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-02-29 03:19:32 -03:00
7e8cdba181 [Refactor] move APIFormat() of Issue and Label to convert package (#10423)
* Label: delete .APIFormat() and use convert.ToLabel()

* move issue APIFormat too

* add missing one

* move TEST too

* handle error -> return empty APIIssue

* Apply suggestions from code review

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

Co-authored-by: zeripath <[email protected]>
Co-authored-by: guillep2k <[email protected]>
2020-02-28 23:49:50 -03:00
John OlheiserandGitHub 78585b1cd7 Fix double PR notification from API (#10482)
Signed-off-by: jolheiser <[email protected]>
2020-02-26 12:12:34 -06:00