GitLabgitlab-org

cli

main
ply6 git calls32 ms96 KiB5 cachedprotocol v2
85 lines2.1 KiBRaw
1package text
3import (
4 "bytes"
5 "strings"
6)
8// Truncate resizes the string with the given length. It ellipses with '...' when the string's length exceeds
9// the desired length or pads spaces to the right of the string when length is smaller than desired
10func Truncate(s string, length int) string {
11 slen := StringWidth(s)
12 n := length
13 if slen == n {
14 return s
15 }
16 if slen > n && n < 3 {
17 return strings.Repeat(".", max(n, 0))
18 }
19 // Pads only when length of the string smaller than len needed
20 s = PadRight(s, n, ' ')
22 if slen > n {
23 buf := bytes.Buffer{}
24 w := 0
25 dotsWritten := 0
27 hyperlinkMatches := hyperlinkOSCRegexp.FindAllStringIndex(s, -1)
29 // append a faked match so that we always have something in
30 // hyperlinkMatches[0] and can avoid nil checks
31 hyperlinkMatches = append(hyperlinkMatches, []int{len(s), len(s)})
33 // Labelled because the switches below turn a bare break into a break of
34 // the switch rather than of this loop.
35 truncate:
36 for i, r := range s {
37 startPos := hyperlinkMatches[0][0]
38 endPos := hyperlinkMatches[0][1]
40 switch {
41 case i >= startPos && i < endPos:
42 // write runes inside hyperlink OSC sequences - this doesn't count
43 // against our grapheme total
44 buf.WriteRune(r)
45 case w == 0:
46 // always write the first character
47 buf.WriteRune(r)
48 w += RuneWidth(r)
49 default:
50 rw := RuneWidth(r)
52 switch {
53 case w+rw <= n-3:
54 // if we have room before the ellipsis, go ahead and write it
55 buf.WriteRune(r)
56 w += rw
57 case dotsWritten < 3:
58 buf.WriteRune('.')
59 w++
60 dotsWritten++
61 default:
62 break truncate
63 }
64 }
66 if i == endPos-1 {
67 // we're at the end of this hyperlink OSC sequence - get ready
68 // to check for the next one
69 hyperlinkMatches = hyperlinkMatches[1:]
70 }
71 }
73 // if we currently have an "open" hyperlink OSC sequence, we need to write
74 // a closing sequence
75 nextOSC := s[hyperlinkMatches[0][0]:hyperlinkMatches[0][1]]
76 isNextOSCClosing := nextOSC == "\x1b]8;;\x1b\\"
78 if isNextOSCClosing {
79 buf.WriteString(nextOSC)
80 }
82 s = buf.String()
83 }
84 return s
Diagnostics6 git calls · 32 ms
CallStatusSizeTime032 ms
discover200185 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=185
git.server.agent=git/2.56.g1891de4-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=185
git.pkt.payload.max=35
ls-refs20058 KiB · hit9 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=9
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:0 · deepen 1020032 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetchtree:0200252 B · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=252
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=e9b19a1e1947873c86e10228c1cf4366871bf7bb
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=252
git.pkt.payload.max=225
git.sideband.band1.bytes=225
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=225
git.pack.trailer=6cbb7e25b03d265a9ed411cfa3dc8c4b4af06409
Open pack map
fetch2001.0 KiB · hit18 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=18
git.response.bytes=1030
git.response.cache=HIT
git.response.duration_ms=18
git.fetch.wants=ec5ee393b22686fadf2d6063342f0d1a2a163939
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1030
git.pkt.payload.max=1003
git.sideband.band1.bytes=1003
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://gitlab.com/gitlab-org/cli
Ref
refs/heads/main
Commit
0dd7574dce9e385c5c30540e6c15657adc6bdce9
cf-ray
a5e1d836da31a151
Request
adb284fd…
Protocol
v2 · sha1
Agent
git/2.56.g1891de4-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format