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

Don't create duplicated functions for code repositories and wiki repositories #33924

Merged
merged 5 commits into from
Mar 19, 2025

Conversation

lunny
Copy link
Member

@lunny lunny commented Mar 17, 2025

Fix #33910 (review)

This PR changed the Repositroy interface in gitrepo package which makes it only focus the relative path in the disk and abstract whether it's a wiki repository or not.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Mar 17, 2025
@lunny lunny requested a review from wxiaoguang March 17, 2025 22:34
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 17, 2025
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 17, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Mar 17, 2025
@GiteaBot GiteaBot 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 Mar 18, 2025
return string(sr)
}

func (repo *Repository) WikiStorageRepo() StorageRepo {
Copy link
Member

Choose a reason for hiding this comment

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

ToWikiPath()?

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's a storage repository interface, not only path.

return RelativePath(repo.OwnerName, repo.Name)
}

type StorageRepo string
Copy link
Member

Choose a reason for hiding this comment

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

RepoPath?

Copy link
Member

Choose a reason for hiding this comment

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

may RepoPath can cause confusion with repo url path? maybe StoragePath?

Copy link
Contributor

@wxiaoguang wxiaoguang Mar 19, 2025

Choose a reason for hiding this comment

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

There is already a complex Storage system in Gitea.

TBH any new variable named "StorageXxx" doesn't look good to me (but I won't say block)

Copy link
Member

@delvh delvh Mar 19, 2025

Choose a reason for hiding this comment

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

may RepoPath can cause confusion with repo url path?

No, I would say it does not:
After all, we are on the models layer here.
As such, it is far more likely that we are talking about how the repo is stored compared to how it is accessed.
If it had something to do with URLs, we would need the URL somewhere in the name, since that stuff is normally handled by routers and services.

Copy link
Member Author

@lunny lunny Mar 19, 2025

Choose a reason for hiding this comment

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

It maybe refactored to add more interface functions rather than repo path, so I don't think it's a good name as RepoPath. And this is an implementation of gitrepo.Repository.

}

func (repo *Repository) WikiStorageRepo() StorageRepo {
return StorageRepo(strings.ToLower(repo.OwnerName) + "/" + strings.ToLower(repo.Name) + ".wiki.git")
Copy link
Member

Choose a reason for hiding this comment

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

We could check here that we don't already have a Wiki repo:
It could be possible in the future that someone calls this method unaware that it's already a wiki repo, and receives a double-encoded wiki repo (.wiki.git.wiki.git).

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to add a comment here: currently, Repository refers to the entire concept of a repository. I don’t believe it can be interpreted to mean a wiki repository specifically.

@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 Mar 19, 2025
@delvh
Copy link
Member

delvh commented Mar 19, 2025

While this PR has two approvals already, I'd certainly like to wait for @wxiaoguang's review before merging as he proposed such a change in the first place.

@wxiaoguang
Copy link
Contributor

While this PR has two approvals already, I'd certainly like to wait for @wxiaoguang's review before merging as he proposed such a change in the first place.

Thank you very much for asking review. Sometimes I block PRs if something would go wrong.

For this one, I didn't see obvious problem (no block) but I don't know whether it is the right way (no approval). So feel free to approve and merge if you have reviewed.

@lunny
Copy link
Member Author

lunny commented Mar 19, 2025

The name could be changed if there is a better one. Since this abstract will make it easier and less change, I think we can move forward at the moment.

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 19, 2025
@lunny lunny merged commit a9e8ac0 into go-gitea:main Mar 19, 2025
26 checks passed
@GiteaBot GiteaBot added this to the 1.24.0 milestone Mar 19, 2025
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 19, 2025
@lunny lunny deleted the lunny/reafctor_storage_repo branch March 19, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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.

6 participants