mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-21 20:23:41 +09:00
refactor: correct git repo design and fix some legacy problems (#38512)
This commit is contained in:
+12
-4
@@ -230,15 +230,23 @@ func RelativePath(ownerName, repoName string) string {
|
||||
return strings.ToLower(ownerName) + "/" + strings.ToLower(repoName) + ".git"
|
||||
}
|
||||
|
||||
// RelativePath should be a unix style path like "owner-name/repo-name.git"
|
||||
func (repo *Repository) RelativePath() string {
|
||||
func (repo *Repository) GitRepoLocation() string {
|
||||
return RelativePath(repo.OwnerName, repo.Name)
|
||||
}
|
||||
|
||||
func (repo *Repository) GitRepoUniqueID() string {
|
||||
return strconv.FormatInt(repo.ID, 10)
|
||||
}
|
||||
|
||||
type StorageRepo string
|
||||
|
||||
// RelativePath should be an unix style path like username/reponame.git
|
||||
func (sr StorageRepo) RelativePath() string {
|
||||
func (sr StorageRepo) GitRepoUniqueID() string {
|
||||
// TODO: need to correctly refactor this method in the future.
|
||||
// "unique id" should be a cache-key-friendly string, but not a full repo path
|
||||
return string(sr)
|
||||
}
|
||||
|
||||
func (sr StorageRepo) GitRepoLocation() string {
|
||||
return string(sr)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,5 +26,5 @@ func TestRepository_RelativeWikiPath(t *testing.T) {
|
||||
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
assert.Equal(t, "user2/repo1.wiki.git", repo_model.RelativeWikiPath(repo.OwnerName, repo.Name))
|
||||
assert.Equal(t, "user2/repo1.wiki.git", repo.WikiStorageRepo().RelativePath())
|
||||
assert.Equal(t, "user2/repo1.wiki.git", repo.WikiStorageRepo().GitRepoLocation())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user