0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-09-24 22:16:27 -04:00

Move updateref and removeref to gitrepo and remove unnecessary open repository (#35511)

Extracted from #35077
`UpdateRef` and `RemoveRef` will call git commands even for gogit
version.
This commit is contained in:
Lunny Xiao
2025-09-19 08:04:18 -07:00
committed by GitHub
parent 9a0ec53ee3
commit 198f37e33c
11 changed files with 46 additions and 47 deletions

View File

@@ -38,16 +38,6 @@ func (repo *Repository) GetRefCommitID(name string) (string, error) {
return ref.Hash().String(), nil
}
// SetReference sets the commit ID string of given reference (e.g. branch or tag).
func (repo *Repository) SetReference(name, commitID string) error {
return repo.gogitRepo.Storer.SetReference(plumbing.NewReferenceFromStrings(name, commitID))
}
// RemoveReference removes the given reference (e.g. branch or tag).
func (repo *Repository) RemoveReference(name string) error {
return repo.gogitRepo.Storer.RemoveReference(plumbing.ReferenceName(name))
}
// ConvertToHash returns a Hash object from a potential ID string
func (repo *Repository) ConvertToGitID(commitID string) (ObjectID, error) {
objectFormat, err := repo.GetObjectFormat()