mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-22 17:02:41 +00:00
refactor: correct git repo design and fix some legacy problems (#38512)
This commit is contained in:
28
modules/git/gitcmd/repo.go
Normal file
28
modules/git/gitcmd/repo.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package gitcmd
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"gitea.dev/modules/setting"
|
||||
)
|
||||
|
||||
type RepositoryFacade interface {
|
||||
GitRepoUniqueID() string
|
||||
GitRepoLocation() string
|
||||
}
|
||||
|
||||
func (c *Command) WithRepo(repo RepositoryFacade) *Command {
|
||||
c.opts.Dir = RepoLocalPath(repo)
|
||||
return c
|
||||
}
|
||||
|
||||
func RepoLocalPath(repo RepositoryFacade) string {
|
||||
repoLoc := repo.GitRepoLocation()
|
||||
if filepath.IsAbs(repoLoc) {
|
||||
return repoLoc
|
||||
}
|
||||
return filepath.Join(setting.RepoRootPath, filepath.FromSlash(repoLoc))
|
||||
}
|
||||
Reference in New Issue
Block a user