commands: move lock verification for refs
This commit is contained in:
parent
44832addfe
commit
8a1b0fb997
@ -51,7 +51,6 @@ func prePushCommand(cmd *cobra.Command, args []string) {
|
||||
Exit("Invalid remote name %q: %s", args[0], err)
|
||||
}
|
||||
|
||||
updates := prePushRefs(os.Stdin)
|
||||
ctx := newUploadContext(prePushDryRun)
|
||||
gitscanner, err := ctx.buildGitScanner()
|
||||
if err != nil {
|
||||
@ -59,6 +58,9 @@ func prePushCommand(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
defer gitscanner.Close()
|
||||
|
||||
updates := prePushRefs(os.Stdin)
|
||||
verifyLocksForUpdates(ctx.lockVerifier, updates)
|
||||
|
||||
for _, update := range updates {
|
||||
if err := uploadLeftOrAll(gitscanner, ctx, update); err != nil {
|
||||
Print("Error scanning for Git LFS files in %+v", update.Left())
|
||||
|
@ -74,6 +74,8 @@ func uploadsBetweenRefAndRemote(ctx *uploadContext, refnames []string) {
|
||||
Exit("Error getting local refs.")
|
||||
}
|
||||
|
||||
verifyLocksForUpdates(ctx.lockVerifier, updates)
|
||||
|
||||
for _, update := range updates {
|
||||
if err = uploadLeftOrAll(gitscanner, ctx, update); err != nil {
|
||||
Print("Error scanning for Git LFS files in the %q ref", update.Left().Name)
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/git-lfs/git-lfs/lfsapi"
|
||||
"github.com/git-lfs/git-lfs/locking"
|
||||
"github.com/git-lfs/git-lfs/tq"
|
||||
"github.com/rubyist/tracerx"
|
||||
)
|
||||
|
||||
type verifyState byte
|
||||
@ -21,6 +22,15 @@ const (
|
||||
verifyStateDisabled
|
||||
)
|
||||
|
||||
func verifyLocksForUpdates(lv *lockVerifier, updates []*refUpdate) {
|
||||
lv.Verify(cfg.RemoteRefName())
|
||||
/*
|
||||
for _, update := range updates {
|
||||
lv.Verify(update.Right().Name)
|
||||
}
|
||||
// */
|
||||
}
|
||||
|
||||
// lockVerifier verifies locked files before updating one or more refs.
|
||||
type lockVerifier struct {
|
||||
endpoint lfsapi.Endpoint
|
||||
@ -43,6 +53,7 @@ func (lv *lockVerifier) Verify(ref string) {
|
||||
return
|
||||
}
|
||||
|
||||
tracerx.Printf("LOCK VERIFY %q", ref)
|
||||
lockClient := newLockClient()
|
||||
ours, theirs, err := lockClient.VerifiableLocks(ref, 0)
|
||||
if err != nil {
|
||||
|
@ -70,9 +70,6 @@ func newUploadContext(dryRun bool) *uploadContext {
|
||||
ctx.meter = buildProgressMeter(ctx.DryRun)
|
||||
ctx.tq = newUploadQueue(ctx.Manifest, ctx.Remote, tq.WithProgress(ctx.meter), tq.DryRun(ctx.DryRun))
|
||||
ctx.committerName, ctx.committerEmail = cfg.CurrentCommitter()
|
||||
|
||||
ctx.lockVerifier.Verify(cfg.RemoteRefName())
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user