Refactor calc mergebase

This commit is contained in:
Lunny Xiao
2025-07-14 12:07:12 -07:00
parent f8cea67265
commit eddd21bdea
10 changed files with 151 additions and 81 deletions

View File

@@ -4,6 +4,7 @@
package git
import (
"context"
"regexp"
"strings"
@@ -220,3 +221,14 @@ func (ref RefName) RefWebLinkPath() string {
}
return string(refType) + "/" + util.PathEscapeSegments(ref.ShortName())
}
func UpdateRef(ctx context.Context, repoPath, refName, newCommitID string) error {
_, _, err := NewCommand("update-ref").AddDynamicArguments(refName, newCommitID).RunStdString(ctx, &RunOpts{Dir: repoPath})
return err
}
func RemoveRef(ctx context.Context, repoPath, refName string) error {
_, _, err := NewCommand("update-ref", "--no-deref", "-d").
AddDynamicArguments(refName).RunStdString(ctx, &RunOpts{Dir: repoPath})
return err
}