MCPcopy Index your code
hub / github.com/go-git/go-git / writeTo

Method writeTo

plumbing/format/diff/unified_encoder.go:323–360  ·  view source on GitHub ↗
(sb *strings.Builder, color ColorConfig)

Source from the content-addressed store, hash-verified

321}
322
323func (h *hunk) writeTo(sb *strings.Builder, color ColorConfig) {
324 sb.WriteString(color[Frag])
325 sb.WriteString("@@ -")
326
327 if h.fromCount == 1 {
328 sb.WriteString(strconv.Itoa(h.fromLine))
329 } else {
330 sb.WriteString(strconv.Itoa(h.fromLine))
331 sb.WriteByte(',')
332 sb.WriteString(strconv.Itoa(h.fromCount))
333 }
334
335 sb.WriteString(" +")
336
337 if h.toCount == 1 {
338 sb.WriteString(strconv.Itoa(h.toLine))
339 } else {
340 sb.WriteString(strconv.Itoa(h.toLine))
341 sb.WriteByte(',')
342 sb.WriteString(strconv.Itoa(h.toCount))
343 }
344
345 sb.WriteString(" @@")
346 sb.WriteString(color.Reset(Frag))
347
348 if h.ctxPrefix != "" {
349 sb.WriteByte(' ')
350 sb.WriteString(color[Func])
351 sb.WriteString(h.ctxPrefix)
352 sb.WriteString(color.Reset(Func))
353 }
354
355 sb.WriteByte('\n')
356
357 for _, op := range h.ops {
358 op.writeTo(sb, color)
359 }
360}
361
362func (h *hunk) AddOp(t Operation, ss ...string) {
363 n := len(ss)

Callers

nothing calls this directly

Calls 2

ResetMethod · 0.45
writeToMethod · 0.45

Tested by

no test coverage detected