Commit Graph

28 Commits (910947fbcd229abac9f507e266f94cb8864474cb)

Author SHA1 Message Date
6543 fd60ebfe14
[API] Migration: Change ServiceType String ()
* use different structs for MigrateRepoOptions on UI and API

* Fix TokenAuth and rename UID to an understandable Name

* fix swagger doc

* simplify & mk redable

* R E F A C T O R:
migration has now internal 3 structs to store its options:
 * the Options for WebUI: modules/auth/repo_form.go
 * the Options for API: modules/structs/repo.go
 * the option struct with after validation for internal prossessing: modules/migrations/base/options.go

* Copyright Header

* Deprecate UID - add RepoOwner

* adopt repo.go -> migrate.go

* add comment about each struct purpose

* lint
6543 1ea1cade85
Add Created & Updated to Milestone ()
* Add Created and Updated to Milestone table and expose via API

* Expose to UI - To Overloaded ?!?

* fix unit test

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
zeripath d15bb17b78
Default empty merger list to those with write permissions ()
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Cirno the Strongest cefbf73aea
Honor DEFAULT_PAGING_NUM for API ()
* Honor DEFAULT_PAGING_NUM for API

* set pagination to 10 for tests

* lint

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
6543 dc812f8ba5
Issue/Pull expose IsLocked Property on API ()
Expose IsLocked Property
zeripath 0b8b81e029
API PullReviewComment HTMLPullURL should return the HTMLURL ()
Fix 

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
6543 7257c39ddf
Refactor Milestone related ()
6543 c97494a4f4
API: Add pull review endpoints ()
* 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 <davidsvantesson@gmail.com>

* add comments

Co-authored-by: Thomas Berger <loki@lokis-chaos.de>
Co-authored-by: David Svantesson <davidsvantesson@gmail.com>
6543 c52d48aae4
Prevent merge of outdated PRs on protected branches ()
* Block PR on Outdated Branch

* finalize

* cleanup

* fix typo and sentences

thanks @guillep2k

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
6543 3d63caa542
[API] Get a single commit via Ref ()
* GET /repos/:owner/:repo/commits/:ref

* add Validation Checks

* Fix & Extend TEST

* add two new tast cases
Lauris BH bbd910ed1b
Allow to set protected file patterns that can not be changed under no conditions ()
Co-Authored-By: zeripath <art27@cantab.net>
Lunny Xiao dcaa5643d7
Fix branch api canPush and canMerge ()
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Lunny Xiao 83fe7d414e
Fix bug on branch API ()
zeripath 3fc4f3670c
Fix panic in API pulls when headbranch does not exist ()
* Fix panic in API pulls when headbranch does not exist
* refix other reference to plumbing.ErrReferenceNotFound

Signed-off-by: Andrew Thornton <art27@cantab.net>
Lunny Xiao 5abe1c52de
Display pull request head branch even the branch deleted or repository deleted ()
* 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 <art27@cantab.net>
Gustavo Marin af61b2249a
adds API endpoints to manage OAuth2 Application (list/create/delete) ()
* 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 <matti@mdranta.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
6543 7e8cdba181
[Refactor] move APIFormat() of Issue and Label to convert package ()
* 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 <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
David Svantesson 9ff4e1d2d9
Add API branch protection endpoint ()
* add API branch protection endpoint

* lint

* Change to use team names instead of ids.

* Status codes.

* fix

* Fix

* Add new branch protection options (BlockOnRejectedReviews, DismissStaleApprovals, RequireSignedCommits)

* Do xorm query directly

* fix xorm GetUserNamesByIDs

* Add some tests

* Improved GetTeamNamesByID

* http status created for CreateBranchProtection

* Correct status code in integration test

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
6543 8d43563a32
[BugFix] [API] Pull.API.Convert: Only try to get HeadBranch if HeadRepo exist ()
* only try to get HeadBranch if HeadRepo exist

* impruve

* no nil error

* add TEST

* correct error msg
Lunny Xiao 2677d071f9
Move newbranch to standalone package ()
* Move newbranch to standalone package

* move branch functions to modules to avoid dependencies cycles

* fix tests

* fix lint

* fix lint
David Svantesson 32fb813133 Allow repo admin to merge PR regardless of review status ()
* Allow repo admin to merge even if review is not ok.
Lunny Xiao 4d06d10dba Move tracked time api convert to convert package ()
Lunny Xiao 384c2b342e
Move pull request api convert to convert package ()
* Move pull request api convert to convert package

* Rename ToPullRequest to ToAPIPullRequest
6543 61c59bd695 [Bug] [API] Add language to user api ()
* add language to user api

* OK

Co-Authored-By: Lauris BH <lauris@nix.lv>
David Svantesson d0edb607a3 Fix what information is shown about user in API. ()
* Fix what information is shown about user in API.

* Use Email directly, as KeepEmailPrivate is already handled.
David Svantesson 69a255defb Team permission to create repository in organization ()
* Add team permission setting to allow creating repo in organization.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Add test case for creating repo when have team creation access.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* build error: should omit comparison to bool constant

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Add comment on exported functions

* Fix fixture consistency, fix existing unit tests

* Fix boolean comparison in xorm query.

* addCollaborator and changeCollaborationAccessMode separate steps

More clear to use different if-cases.

* Create and commit xorm session

* fix

* Add information of create repo permission in team sidebar

* Add migration step

* Clarify that repository creator will be administrator.

* Fix some things after merge

* Fix language text that use html

* migrations file

* Create repository permission -> Create repositories

* fix merge

* fix review comments
David Svantesson 86cff86b46 Update branch API endpoint to show effective branch protection. ()
* Add API endpoint for displaying effective branch protection.

* Add status checks.
Lunny Xiao daab245167
Move code.gitea.io/gitea/routers/api/v1/convert to code.gitea.io/gitea/modules/convert ()
* Move code.gitea.io/gitea/routers/api/v1/convert to code.gitea.io/gitea/modules/convert

* fix fmt