Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move repository model into models/repo #17933

Merged
merged 7 commits into from
Dec 10, 2021
Merged

Conversation

lunny
Copy link
Member

@lunny lunny commented Dec 8, 2021

This is the first step to move repository related beans. To make it review easier, I will put others in future PRs.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Dec 8, 2021
@lunny lunny force-pushed the lunny/repo_refactor branch 2 times, most recently from 708860a to 4e5658d Compare December 9, 2021 06:08
@wxiaoguang
Copy link
Contributor

It would be better to keep model related prefix for functions in root models package.

For example, repoCheckUnitUser instead of checkUnitUser, repoReconsiderIssueAssignees instead of reconsiderIssueAssignees, RepoDeleteCollaboration instead of DeleteCollaboration, RepoAddDeletedBranch ... etc

And JSONUnmarshalHandleDoubleEncode should be put somewhere else, auth/source shouldn't depend on repo

Otherwise, LGTM

@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Dec 9, 2021
@lunny
Copy link
Member Author

lunny commented Dec 9, 2021

AddDeletedBranch

I changed most of them but kept DeleteCollaboration, AddDeletedBranch because I think the repo prefix is not a must word.

models/branches.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 9, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #17933 (7ac88ae) into main (d2d9bc8) will increase coverage by 0.03%.
The diff coverage is 60.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17933      +/-   ##
==========================================
+ Coverage   45.34%   45.37%   +0.03%     
==========================================
  Files         815      817       +2     
  Lines       90768    90806      +38     
==========================================
+ Hits        41157    41206      +49     
+ Misses      43045    43036       -9     
+ Partials     6566     6564       -2     
Impacted Files Coverage Δ
cmd/migrate_storage.go 0.00% <0.00%> (ø)
models/consistency.go 8.84% <0.00%> (ø)
models/error.go 39.29% <ø> (-0.71%) ⬇️
models/issue_assignees.go 75.00% <0.00%> (ø)
models/issue_dependency.go 63.93% <ø> (-0.36%) ⬇️
models/issue_label.go 68.87% <0.00%> (ø)
models/issue_stopwatch.go 66.88% <0.00%> (+0.85%) ⬆️
models/project_issue.go 29.35% <0.00%> (ø)
models/repo/pushmirror.go 66.66% <ø> (ø)
models/repo/wiki.go 81.81% <ø> (ø)
... and 196 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb8166c...7ac88ae. Read the comment docs.

@lunny lunny merged commit 719bddc into go-gitea:main Dec 10, 2021
@lunny lunny deleted the lunny/repo_refactor branch December 10, 2021 01:27
@@ -361,21 +364,24 @@ func repoAssignment(ctx *Context, repo *models.Repository) {

if repo.IsMirror {
var err error
ctx.Repo.Mirror, err = models.GetMirrorByRepoID(repo.ID)
mirror, err := repo_model.GetMirrorByRepoID(repo.ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes #18204

zeripath added a commit to zeripath/gitea that referenced this pull request Jan 7, 2022
In go-gitea#17933 repoAssignment no longer sets the ctx.Repo.Mirror field meaning that
attempting change mirror settings results in an NPE. This PR simply restores this.

Either we should remove this field or, we should set it. At present it seems simplest
to set it instead of going looking in the Data for the value although converting the
context to a bag of things may be the correct approach in the future.

Fix go-gitea#18204

Signed-off-by: Andrew Thornton <art27@cantab.net>
lunny pushed a commit that referenced this pull request Jan 8, 2022
In #17933 repoAssignment no longer sets the ctx.Repo.Mirror field meaning that
attempting change mirror settings results in an NPE. This PR simply restores this.

Either we should remove this field or, we should set it. At present it seems simplest
to set it instead of going looking in the Data for the value although converting the
context to a bag of things may be the correct approach in the future.

Fix #18204

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
* Some refactors related repository model

* Move more methods out of repository

* Move repository into models/repo

* Fix test

* Fix test

* some improvements

* Remove unnecessary function
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
In go-gitea#17933 repoAssignment no longer sets the ctx.Repo.Mirror field meaning that
attempting change mirror settings results in an NPE. This PR simply restores this.

Either we should remove this field or, we should set it. At present it seems simplest
to set it instead of going looking in the Data for the value although converting the
context to a bag of things may be the correct approach in the future.

Fix go-gitea#18204

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants