mirror of
https://github.com/go-gitea/gitea.git
synced 2025-10-05 08:16:29 +00: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:
@@ -51,18 +51,6 @@ func (repo *Repository) GetRefCommitID(name string) (string, error) {
|
||||
return string(shaBs), nil
|
||||
}
|
||||
|
||||
// SetReference sets the commit ID string of given reference (e.g. branch or tag).
|
||||
func (repo *Repository) SetReference(name, commitID string) error {
|
||||
_, _, err := gitcmd.NewCommand("update-ref").AddDynamicArguments(name, commitID).RunStdString(repo.Ctx, &gitcmd.RunOpts{Dir: repo.Path})
|
||||
return err
|
||||
}
|
||||
|
||||
// RemoveReference removes the given reference (e.g. branch or tag).
|
||||
func (repo *Repository) RemoveReference(name string) error {
|
||||
_, _, err := gitcmd.NewCommand("update-ref", "--no-deref", "-d").AddDynamicArguments(name).RunStdString(repo.Ctx, &gitcmd.RunOpts{Dir: repo.Path})
|
||||
return err
|
||||
}
|
||||
|
||||
// IsCommitExist returns true if given commit exists in current repository.
|
||||
func (repo *Repository) IsCommitExist(name string) bool {
|
||||
if err := ensureValidGitRepository(repo.Ctx, repo.Path); err != nil {
|
||||
|
Reference in New Issue
Block a user