Skip to content

Commit

Permalink
feat: support batch response error message
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Oct 26, 2023
1 parent f1efb47 commit 29d6979
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 8 additions & 1 deletion transfer/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ package transfer
// BatchItem is a Git LFS batch item.
type BatchItem struct {
Pointer
Args Args

// Present is used to determine the action to take for the batch item.
Present bool

// Args is an optional oid-line key-value pairs.
Args Args

// Error is an optional error message.
Error string
}
19 changes: 12 additions & 7 deletions transfer/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,18 @@ func (p *Processor) BatchData(op string, presentAction string, missingAction str
}
oids := make([]string, 0)
for _, item := range batch {
action := missingAction
if item.Present {
action = presentAction
}
line := fmt.Sprintf("%s %s", item.Pointer, action)
if len(item.Args) > 0 {
line = fmt.Sprintf("%s %s", line, item.Args)
var line string
if item.Error != "" {
line = fmt.Sprintf("message %s", item.Error)
} else {
action := missingAction
if item.Present {
action = presentAction
}
line = fmt.Sprintf("%s %s", item.Pointer, action)
if len(item.Args) > 0 {
line = fmt.Sprintf("%s %s", line, item.Args)
}
}
oids = append(oids, line)
}
Expand Down

0 comments on commit 29d6979

Please sign in to comment.