Skip to content

Conversation

lafriks
Copy link
Member

@lafriks lafriks commented Apr 30, 2018

Fixes #3864

@codecov-io
Copy link

codecov-io commented Apr 30, 2018

Codecov Report

Merging #3870 into master will increase coverage by 0.04%.
The diff coverage is 61.29%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #3870 +/- ## ========================================== + Coverage 20.13% 20.18% +0.04%  ========================================== Files 145 145 Lines 29124 29151 +27 ========================================== + Hits 5864 5883 +19  - Misses 22368 22374 +6  - Partials 892 894 +2
Impacted Files Coverage Δ
models/wiki.go 62.5% <100%> (ø) ⬆️
models/repo.go 18% <60%> (+0.67%) ⬆️
modules/process/manager.go 73.91% <0%> (+4.34%) ⬆️

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 9ec7f6b...a87542b. Read the comment docs.

@bkcsoft bkcsoft added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 30, 2018
models/repo.go Outdated
}

func (repo *Repository) getOwnerName(e Engine) error {
if repo.OwnerName != "" {
Copy link
Member

Choose a reason for hiding this comment

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

len(repo.OwnerName) > 0

func (repo *Repository) mustOwnerName(e Engine) string {
if err := repo.getOwnerName(e); err != nil {
log.Error(4, "Error loading repository owner name: %v", err)
return "error"
Copy link
Member

Choose a reason for hiding this comment

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

So error is now a reserved username/organization name? Then it should be added to said list 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

It already returns owner name error in mustOwner, I just keep previous behaviour, this should be fixed in other PR

}

u := new(User)
has, err := e.ID(repo.OwnerID).Cols("name").Get(u)
Copy link
Member

Choose a reason for hiding this comment

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

Other than a slight increase in memory usage, I don't see any point in only loading the name. The database still has to find and fetch the entire row 🤔 I would change this to just mustOwner()

Copy link
Member Author

Choose a reason for hiding this comment

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

That's needed because it is used in migrations and can be that struct has more fields than database has so there will be error in select that database does not contain such column

@bkcsoft bkcsoft added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 1, 2018
@bkcsoft bkcsoft 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 May 2, 2018
@lafriks lafriks merged commit 5ffdf93 into go-gitea:master May 2, 2018
@lafriks lafriks deleted the fix/migration_from_old_versions branch May 2, 2018 06:10
lafriks added a commit to lafriks-fork/gitea that referenced this pull request May 2, 2018
@lafriks lafriks added the backport/done All backports for this PR have been created label May 2, 2018
}

u := new(User)
has, err := e.ID(repo.OwnerID).Cols("name").Get(u)
Copy link
Member

Choose a reason for hiding this comment

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

has, err := e.Table("repository").Select("owner_name").Where("id=?", repo.OwnerID).Get(&repo.OwnerName) 
Copy link
Member Author

Choose a reason for hiding this comment

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

@lunny do you want me to submit PR to change this to master first?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean something like:

has, err := e.Table("user").Select("name").Where("id=?", repo.OwnerID).Get(&repo.OwnerName) 
Copy link
Member

Choose a reason for hiding this comment

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

@lafriks the currently code is OK. I only want to say there is another way to do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, thanks, I will keep in mind that

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug type/enhancement An improvement of existing functionality

5 participants