Commit Graph
19 Commits
Author SHA1 Message Date
4df2ed29f2 Refactor: Move PushUpdateOptions (#13363)
Co-authored-by: Antoine GIRARD <[email protected]>
2020-10-30 22:59:02 +01:00
2d75d6f664 Move update-server-info to hooks (#12826)
Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
2020-10-14 00:24:06 +08:00
9b81193166 Cache last commit when pushing for big repository (#10109)
* Cache last commit when pushing for big repository

* Fix bug

* detect force push

* Refactor cache push

* Finish cache last commit info when push

* Some improvements

* Fix lint

* Remove unused changes

* Move pull request test before cache

* Fix test mysql

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
2020-10-09 01:17:23 +03:00
James LakinandGitHub 6fc129fe62 Fix repository create/delete event webhooks (#13008)
This small PR changes the webhook trigger behaviour to be more in line with what's expected. (When 'repository' events are enabled, of course)

In other words:

For system-wide or default webhooks, repository events will now trigger said webhook. Previously it had to be under an organization for create events to be visible - a tad unexpected!
Deleting a repository will now fire its own defined webhooks, not just organisational and system ones.
In order to enable the latter the webhook has to now be triggered before the actual repo undergoes deletion. I'm willing to tweak this to try and 'grab' the webhook model beforehand and trigger the webhook notifier directly afterwards, but this may make the code more complex for little benefit.

Closes #11766, #9180.
2020-10-02 10:37:46 +01:00
c85c9d40c2 Add config option to make create-on-push repositories public by default (#12936)
* Add config option to make create-on-push repositories public by default

* Fix linting

* Add option to 'config cheat sheet' page

* Chinese translation

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

* Fix typo in docs

* fix typo

* Add option to example config

Co-authored-by: Tait Hoyem <[email protected]>
Co-authored-by: a1012112796 <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-09-27 15:20:52 -04:00
7a7f56044a Adopt repositories (#12920)
* Don't automatically delete repository files if they are present

Prior to this PR Gitea would delete any repository files if they are
present during creation or migration. This can in certain circumstances
lead to data-loss and is slightly unpleasant.

This PR provides a mechanism for Gitea to adopt repositories on creation
and otherwise requires an explicit flag for deletion.

PushCreate is slightly different - the create will cause adoption if
that is allowed otherwise it will delete the data if that is allowed.

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

* Update swagger

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

* Fix tests and migrate overwrite

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

* as per @lunny

Only offer to adopt or overwrite if the user can do that.

Allow the site administrator to adopt or overwrite in all
circumstances

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

* Use setting.Repository.DefaultBranch for the default branch

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

* Always set setting.Repository.DefaultBranch

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

* update swagger

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

* update templates

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

* ensure repo closed

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

* Rewrite of adoption as per @6543 and @lunny

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

* Apply suggestions from code review

* update swagger

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

* missing not

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

* add modals and flash reporting

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

* Make the unadopted page searchable

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

* Add API

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

* Fix swagger

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

* fix swagger

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

* Handle empty and non-master branched repositories

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

* placate lint

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

* remove commented out code

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

Co-authored-by: techknowlogick <[email protected]>
2020-09-25 07:09:23 +03:00
037d5a33a0 Update only the repository columns that need updating (#12900)
We should only update is_empty, default_branch and updated time columns
during commitRepoAction and not update other columns as we risk
overwriting incorrect information.

Fix #11823
Fix #10536

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

Co-authored-by: techknowlogick <[email protected]>
2020-09-20 13:55:15 -04:00
dd1a651b58 Move all push update operations to a queue (#10133)
* Fix test

* Add no queue for test only

* improve code

* Auto watch whatever branch operation

* Fix lint

* Rename noqueue to immediate

* Remove old PushUpdate function

* Fix tests

Co-authored-by: zeripath <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
2020-09-11 10:14:48 -04:00
6543andGitHub 13bc82009c API endpoint for repo transfer (#9947)
* squash

* optimize

* fail before make any changes

* fix-header
2020-01-31 15:49:04 +00:00
f2d12f7b03 Fix pull view when head repository or head branch missed and close related pull requests when delete head repository or head branch (#9927)
* fix pull view when head repository or head branch missed and close related pull requests when delete branch

* fix pull view broken when head repository deleted

* close pull requests when head repositories deleted

* Add tests for broken pull request head repository or branch

* fix typo

* ignore special error when close pull request

Co-authored-by: Lauris BH <[email protected]>
2020-01-25 10:48:22 +08:00
Lunny XiaoandAntoine GIRARD d32eac44b1 Move RepoWorkingPool to services/repository package (#9754)
* Move RepoWorkingPool to services/repository package

* Make repoWorkingPool private

Co-authored-by: Antoine GIRARD <[email protected]>
2020-01-15 04:14:50 +01:00
Lunny XiaoandGitHub b465d0d787 Move create/fork repository from models to modules/repository (#9489)
* Move create/fork repository from models to modules/repository

* fix wrong reference

* fix test

* fix test

* fix lint

* Fix DBContext

* remove duplicated TestMain

* fix lint

* fix conflicts
2020-01-12 20:11:17 +08: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 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
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
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
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
Lunny XiaoandGitHub 9e85358777 Move some repositories' operations to a standalone service package (#8557)
* Move some repositories' operations to a standalone service package

* improve code

* remove unused codes

* add rollback when fork failed

* add repo when return
2019-10-26 14:54:11 +08:00