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