ParseObjectIDWithPath interprets the given ID string (which could be an object ID optionally followed by nested path specification) and returns corresponding object.ID.
(ctx context.Context, rep repo.Repository, objectIDWithPath string)
| 18 | // ParseObjectIDWithPath interprets the given ID string (which could be an object ID optionally followed by |
| 19 | // nested path specification) and returns corresponding object.ID. |
| 20 | func ParseObjectIDWithPath(ctx context.Context, rep repo.Repository, objectIDWithPath string) (object.ID, error) { |
| 21 | parts := strings.Split(objectIDWithPath, "/") |
| 22 | |
| 23 | oid, err := object.ParseID(parts[0]) |
| 24 | if err != nil { |
| 25 | return object.EmptyID, errors.Wrapf(err, "can't parse object ID %v", objectIDWithPath) |
| 26 | } |
| 27 | |
| 28 | if len(parts) == 1 { |
| 29 | return oid, nil |
| 30 | } |
| 31 | |
| 32 | return parseNestedObjectID(ctx, AutoDetectEntryFromObjectID(ctx, rep, oid, ""), parts[1:]) |
| 33 | } |
| 34 | |
| 35 | // GetNestedEntry returns nested entry with a given name path. |
| 36 | func GetNestedEntry(ctx context.Context, startingDir fs.Entry, pathElements []string) (fs.Entry, error) { |
no test coverage detected