Fast implementation of Git in pure Go codeberg.org/lindenii/furgit
git go
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

object/store/dual: Satisfy WriterQuarantiner

Runxi Yu 048d36ef 33a57ddd

+27 -21
+1
object/store/dual/dual.go
··· 32 32 _ objectstore.PackWriter = (*Dual)(nil) 33 33 _ objectstore.ObjectQuarantiner = (*Dual)(nil) 34 34 _ objectstore.PackQuarantiner = (*Dual)(nil) 35 + _ objectstore.WriterQuarantiner = (*Dual)(nil) 35 36 )
+8 -13
object/store/dual/dual_test.go
··· 117 117 repo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 118 118 store := newDualStore(t, repo, algo) 119 119 120 - quarantiner, ok := any(store).(objectstore.PackQuarantiner) 120 + quarantiner, ok := any(store).(objectstore.WriterQuarantiner) 121 121 if !ok { 122 - t.Fatal("dual does not implement PackQuarantiner") 122 + t.Fatal("dual does not implement WriterQuarantiner") 123 123 } 124 124 125 - quarantine, err := quarantiner.BeginPackQuarantine(objectstore.PackQuarantineOptions{}) 125 + quarantine, err := quarantiner.BeginQuarantine(objectstore.QuarantineOptions{}) 126 126 if err != nil { 127 - t.Fatalf("BeginPackQuarantine: %v", err) 127 + t.Fatalf("BeginQuarantine: %v", err) 128 128 } 129 129 130 130 err = quarantine.WritePack(bytes.NewReader(packBytes), objectstore.PackWriteOptions{RequireTrailingEOF: true}) ··· 219 219 repo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 220 220 store := newDualStore(t, repo, algo) 221 221 222 - quarantiner := any(store).(objectstore.ObjectQuarantiner) 223 - quarantine, err := quarantiner.BeginObjectQuarantine(objectstore.ObjectQuarantineOptions{}) 222 + quarantiner := any(store).(objectstore.WriterQuarantiner) 223 + quarantine, err := quarantiner.BeginQuarantine(objectstore.QuarantineOptions{}) 224 224 if err != nil { 225 - t.Fatalf("BeginObjectQuarantine: %v", err) 225 + t.Fatalf("BeginQuarantine: %v", err) 226 226 } 227 227 228 - packQ, ok := any(quarantine).(objectstore.PackQuarantine) 229 - if !ok { 230 - t.Fatal("object quarantine does not also implement PackQuarantine") 231 - } 232 - 233 - err = packQ.WritePack(bytes.NewReader(packBytes), objectstore.PackWriteOptions{RequireTrailingEOF: true}) 228 + err = quarantine.WritePack(bytes.NewReader(packBytes), objectstore.PackWriteOptions{RequireTrailingEOF: true}) 234 229 if err != nil { 235 230 t.Fatalf("quarantine.WritePack: %v", err) 236 231 }
+1
object/store/dual/quarantine.go
··· 19 19 var ( 20 20 _ objectstore.ObjectQuarantine = (*quarantine)(nil) 21 21 _ objectstore.PackQuarantine = (*quarantine)(nil) 22 + _ objectstore.WriterQuarantine = (*quarantine)(nil) 22 23 ) 23 24 24 25 func newQuarantine(
+17 -8
object/store/dual/quarantine_begin.go
··· 2 2 3 3 import objectstore "codeberg.org/lindenii/furgit/object/store" 4 4 5 - // TODO: This doesn't actually make sense. We need a combined quarantine. 5 + // BeginQuarantine creates one coordinated dual quarantine spanning both stores. 6 + // 7 + // Labels: Deps-Borrowed, Life-Parent, Close-No. 8 + func (dual *Dual) BeginQuarantine(opts objectstore.QuarantineOptions) (objectstore.WriterQuarantine, error) { 9 + return dual.beginQuarantine(opts) 10 + } 6 11 7 12 // BeginObjectQuarantine creates one coordinated dual quarantine spanning both 8 13 // stores and returns it as an object-wise quarantine. 9 14 // 10 15 // Labels: Deps-Borrowed, Life-Parent, Close-No. 11 - func (dual *Dual) BeginObjectQuarantine(_ objectstore.ObjectQuarantineOptions) (objectstore.ObjectQuarantine, error) { 12 - quarantine, err := dual.beginQuarantine() 16 + func (dual *Dual) BeginObjectQuarantine(opts objectstore.ObjectQuarantineOptions) (objectstore.ObjectQuarantine, error) { 17 + quarantine, err := dual.beginQuarantine(objectstore.QuarantineOptions{ 18 + Object: opts, 19 + }) 13 20 if err != nil { 14 21 return nil, err 15 22 } ··· 21 28 // stores and returns it as a pack-wise quarantine. 22 29 // 23 30 // Labels: Deps-Borrowed, Life-Parent, Close-No. 24 - func (dual *Dual) BeginPackQuarantine(_ objectstore.PackQuarantineOptions) (objectstore.PackQuarantine, error) { 25 - quarantine, err := dual.beginQuarantine() 31 + func (dual *Dual) BeginPackQuarantine(opts objectstore.PackQuarantineOptions) (objectstore.PackQuarantine, error) { 32 + quarantine, err := dual.beginQuarantine(objectstore.QuarantineOptions{ 33 + Pack: opts, 34 + }) 26 35 if err != nil { 27 36 return nil, err 28 37 } ··· 30 39 return quarantine, nil 31 40 } 32 41 33 - func (dual *Dual) beginQuarantine() (*quarantine, error) { 34 - objectQ, err := dual.object.BeginObjectQuarantine(objectstore.ObjectQuarantineOptions{}) 42 + func (dual *Dual) beginQuarantine(opts objectstore.QuarantineOptions) (*quarantine, error) { 43 + objectQ, err := dual.object.BeginObjectQuarantine(opts.Object) 35 44 if err != nil { 36 45 return nil, err 37 46 } 38 47 39 - packQ, err := dual.pack.BeginPackQuarantine(objectstore.PackQuarantineOptions{}) 48 + packQ, err := dual.pack.BeginPackQuarantine(opts.Pack) 40 49 if err != nil { 41 50 _ = objectQ.Discard() 42 51