in internal/command/githttp/push.go [91:122]
func (c *PushCommand) readFromStdin(pw *io.PipeWriter) {
var needsPackData bool
scanner := pktline.NewScanner(c.ReadWriter.In)
for scanner.Scan() {
line := scanner.Bytes()
_, err := pw.Write(line)
if err != nil {
log.WithError(err).Error("failed to write line")
}
if pktline.IsFlush(line) {
break
}
if !needsPackData && !pktline.IsRefRemoval(line) {
needsPackData = true
}
}
if needsPackData {
_, err := io.Copy(pw, c.ReadWriter.In)
if err != nil {
log.WithError(err).Error("failed to copy")
}
}
err := pw.Close()
if err != nil {
log.WithError(err).Error("failed to close writer")
}
}