mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-22 17:02:41 +00:00
29 lines
574 B
Go
29 lines
574 B
Go
// 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))
|
|
}
|