(ctx context.Context, base *Snapshot, baseID, commit ksuid.KSUID)
| 367 | } |
| 368 | |
| 369 | func (s *Store) PatchOfPath(ctx context.Context, base *Snapshot, baseID, commit ksuid.KSUID) (*Patch, error) { |
| 370 | path, err := s.PathRange(ctx, commit, baseID) |
| 371 | if err != nil { |
| 372 | return nil, err |
| 373 | } |
| 374 | patch := NewPatch(base) |
| 375 | if len(path) < 2 { |
| 376 | // There are no changes past the base. Return the empty patch. |
| 377 | return patch, nil |
| 378 | } |
| 379 | // Play objects in forward order skipping over the last path element |
| 380 | // as that is the base and the difference is relative to it. |
| 381 | for k := len(path) - 2; k >= 0; k-- { |
| 382 | o, err := s.Get(ctx, path[k]) |
| 383 | if err != nil { |
| 384 | return nil, err |
| 385 | } |
| 386 | for _, action := range o.Actions { |
| 387 | if err := PlayAction(patch, action); err != nil { |
| 388 | return nil, err |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | return patch, nil |
| 393 | } |
| 394 | |
| 395 | // FindNearestToTs finds the last commit that is greater than or equal to ts. |
| 396 | func (s *Store) FindNearestToTs(ctx context.Context, tail ksuid.KSUID, ts nano.Ts) (ksuid.KSUID, error) { |
no test coverage detected