GitLabgitlab-org

cli

main
ply6 git calls41 ms101 KiB5 cachedprotocol v2
728 lines19 KiBRaw
1package iostreams
3import (
4 "bufio"
5 "context"
6 "errors"
7 "fmt"
8 "io"
9 "os"
10 "os/exec"
11 "regexp"
12 "slices"
13 "strings"
14 "time"
16 tea "charm.land/bubbletea/v2"
17 "charm.land/huh/v2"
18 "github.com/briandowns/spinner"
19 "github.com/charmbracelet/colorprofile"
20 "github.com/google/shlex"
21 "github.com/muesli/termenv"
23 "gitlab.com/gitlab-org/cli/internal/dbg"
24 "gitlab.com/gitlab-org/cli/internal/theme"
25 "gitlab.com/gitlab-org/cli/internal/utils"
28// ErrUserCancelled is returned when the user cancels a prompt (e.g., by pressing Ctrl+C)
29var ErrUserCancelled = errors.New("user cancelled")
31type IOStreams struct {
32 In io.ReadCloser
33 StdOut io.Writer
34 StdErr io.Writer
36 IsaTTY bool // stdout is a tty
37 IsErrTTY bool // stderr is a tty
38 IsInTTY bool // stdin is a tty
39 promptDisabled bool // disable prompting for input
41 pagerCommand string
42 pagerProcess *os.Process
43 systemStdOut io.Writer
45 spinner *spinner.Spinner
47 backgroundColor string
49 displayHyperlinks string
51 // colorMode is the requested color behavior (the `color` config key).
52 // Empty means ColorModeAuto.
53 colorMode ColorMode
55 // colorProfile is colorMode resolved against the environment and TTY
56 // state: NoTTY when color is off, the terminal tier when on. Output paths
57 // read it rather than re-detecting.
58 colorProfile colorprofile.Profile
60 // colorEnabledOverride, when non-nil, forces colorProfile on or off to match the given
61 // value instead of deriving it from the environment and TTY state. It is
62 // intended for tests that need a deterministic color state without
63 // mutating process-wide env (see WithColorEnabled).
64 colorEnabledOverride *bool
66 programOptions []tea.ProgramOption
68 // JQ is the filter applied to JSON output by PrintJSON. It is always
69 // non-nil so callers can pass &s.JQ to cobra's Flags().Var without nil
70 // checks; IsActive reports whether a --jq expression has been supplied.
71 JQ *JQFilter
73 // outputFormat is recorded by cmdutils.EnableJSONOutput during flag
74 // parsing, so that code holding no *cobra.Command can still honour the
75 // requested format. One command runs per process.
76 outputFormat string
79var controlCharRegEx = regexp.MustCompile(`(\x1b\[)((?:(\d*)(;*))*)([A-Za-l,n-z])`)
81// IOStreamsOption represents a function that configures io streams
82type IOStreamsOption func(*IOStreams)
84func WithStdin(stdin io.ReadCloser, isTTY bool) IOStreamsOption {
85 return func(i *IOStreams) {
86 if stdin != nil {
87 i.In = stdin
88 }
89 i.IsInTTY = isTTY
90 }
93func WithStdout(stdout io.Writer, isTTY bool) IOStreamsOption {
94 return func(i *IOStreams) {
95 if stdout != nil {
96 i.StdOut = stdout
97 i.systemStdOut = stdout // TODO: is this really correct?!
98 }
99 i.IsaTTY = isTTY
100 }
103func WithStderr(stderr io.Writer, isTTY bool) IOStreamsOption {
104 return func(i *IOStreams) {
105 if stderr != nil {
106 i.StdErr = stderr
107 }
108 i.IsErrTTY = isTTY
109 }
112// WithColorEnabled forces color on or off, overriding the environment- and
113// TTY-based detection. It lets tests fix a deterministic color state without
114// mutating process-wide env such as NO_COLOR.
115func WithColorEnabled(enabled bool) IOStreamsOption {
116 return func(i *IOStreams) {
117 i.colorEnabledOverride = &enabled
118 }
121// WithColorMode sets the initial ColorMode (whether to color) from the
122// `color` config key.
123func WithColorMode(mode ColorMode) IOStreamsOption {
124 return func(i *IOStreams) {
125 i.colorMode = mode
126 }
129func WithProgramOptions(opts ...tea.ProgramOption) IOStreamsOption {
130 return func(i *IOStreams) {
131 i.programOptions = append(i.programOptions, opts...)
132 }
135func WithPagerCommand(command string) IOStreamsOption {
136 return func(i *IOStreams) {
137 i.pagerCommand = command
138 }
141func WithDisplayHyperLinks(displayHyperlinks string) IOStreamsOption {
142 return func(i *IOStreams) {
143 if displayHyperlinks != "" {
144 i.displayHyperlinks = displayHyperlinks
145 }
146 }
149func New(options ...IOStreamsOption) *IOStreams {
150 iostreams := &IOStreams{
151 // static configuration that we don't need to change in tests.
152 displayHyperlinks: "auto",
153 JQ: &JQFilter{},
154 }
156 // Apply options
157 for _, option := range options {
158 option(iostreams)
159 }
161 // configure static fields that rely on option functions
162 iostreams.applyColorMode(iostreams.colorMode)
164 return iostreams
167// ColorMode returns the effective ColorMode (whether to color). An unset
168// mode reports ColorModeAuto, since that is the behavior it produces.
169func (s *IOStreams) ColorMode() ColorMode {
170 if s.colorMode == "" {
171 return ColorModeAuto
172 }
173 return s.colorMode
176// SetColorMode applies mode to this IOStreams and re-resolves the color
177// profile.
178func (s *IOStreams) SetColorMode(mode ColorMode) {
179 s.applyColorMode(mode)
182// applyColorMode resolves colorProfile for mode. A colorEnabledOverride, set
183// by tests through WithColorEnabled, always wins over the resolved profile.
184func (s *IOStreams) applyColorMode(mode ColorMode) {
185 s.colorMode = mode
186 s.colorProfile = resolveColorProfile(mode, s.IsaTTY && s.IsErrTTY)
188 if s.colorEnabledOverride != nil {
189 s.colorProfile = profileIf(*s.colorEnabledOverride)
190 }
193func stripControlCharacters(input string) string {
194 return controlCharRegEx.ReplaceAllString(input, "^[[$2$5")
197func writePagerOutput(dst io.Writer, src io.Reader) error {
198 reader := bufio.NewReader(src)
200 for {
201 line, readErr := reader.ReadString('\n')
202 if line != "" {
203 line = strings.TrimSuffix(line, "\n")
204 line = strings.TrimSuffix(line, "\r")
205 if _, err := fmt.Fprintln(dst, stripControlCharacters(line)); err != nil {
206 return err
207 }
208 }
210 if errors.Is(readErr, io.EOF) {
211 return nil
212 }
213 if readErr != nil {
214 return readErr
215 }
216 }
219func (s *IOStreams) PromptEnabled() bool {
220 if s.promptDisabled {
221 return false
222 }
223 return s.IsOutputTTY()
226func (s *IOStreams) ColorEnabled() bool {
227 return s.colorProfile > colorprofile.ASCII
230func (s *IOStreams) Is256ColorSupported() bool {
231 return colorTier() >= colorprofile.ANSI256
234func (s *IOStreams) SetPrompt(promptDisabled string) {
235 switch promptDisabled {
236 case "true", "1":
237 s.promptDisabled = true
238 case "false", "0":
239 s.promptDisabled = false
240 }
243// SetOutputFormat records the output format the running command was invoked
244// with, as parsed from its --output/-F flag.
245func (s *IOStreams) SetOutputFormat(format string) {
246 s.outputFormat = format
249// IsJSONOutput reports whether the running command was asked to emit JSON.
250func (s *IOStreams) IsJSONOutput() bool {
251 return s.outputFormat == "json"
254func (s *IOStreams) SetPager(cmd string) {
255 s.pagerCommand = cmd
258func (s *IOStreams) StartPager() error {
259 if strings.TrimSpace(s.pagerCommand) == "" || s.pagerCommand == "cat" || !s.IsaTTY {
260 return nil
261 }
263 pagerArgs, err := shlex.Split(s.pagerCommand)
264 if err != nil {
265 return err
266 }
268 pagerEnv := os.Environ()
269 for i, v := range slices.Backward(pagerEnv) {
270 if strings.HasPrefix(v, "PAGER=") {
271 pagerEnv = append(pagerEnv[0:i], pagerEnv[i+1:]...)
272 }
273 }
275 pagerEnv = append(pagerEnv, "LESSSECURE=1")
277 // Only use `-r` (all raw control chars) when hyperlinks are forced on;
278 // otherwise `-R` (color escapes only) avoids letting unexpected sequences
279 // through to less.
280 if s.displayHyperlinks == "always" {
281 pagerEnv = append(pagerEnv, "LESS=FrX")
282 } else if _, ok := os.LookupEnv("LESS"); !ok {
283 pagerEnv = append(pagerEnv, "LESS=FRX")
284 }
285 if _, ok := os.LookupEnv("LV"); !ok {
286 pagerEnv = append(pagerEnv, "LV=-c")
287 }
289 pagerCmd := exec.Command(pagerArgs[0], pagerArgs[1:]...)
290 pagerCmd.Env = pagerEnv
291 pagerCmd.Stdout = s.StdOut
292 pagerCmd.Stderr = s.StdErr
293 pagedOut, err := pagerCmd.StdinPipe()
294 if err != nil {
295 return err
296 }
298 pipeReader, pipeWriter := io.Pipe()
299 s.StdOut = pipeWriter
301 // TODO: Unfortunately, trying to add an error channel introduces a wait that locks up the code.
302 // We should eventually add some error reporting for the go function
304 go func() {
305 defer pagedOut.Close()
306 if err := writePagerOutput(pagedOut, pipeReader); err != nil {
307 dbg.Debugf("pager output error: %v", err)
308 }
309 }()
311 err = pagerCmd.Start()
312 if err != nil {
313 return err
314 }
315 s.pagerProcess = pagerCmd.Process
317 go func() {
318 _, _ = s.pagerProcess.Wait()
319 _ = pipeWriter.Close()
320 }()
322 return nil
325func (s *IOStreams) StopPager() {
326 if s.pagerProcess == nil {
327 return
328 }
330 if closer, ok := s.StdOut.(io.WriteCloser); ok {
331 _ = closer.Close()
332 }
333 _, _ = s.pagerProcess.Wait()
334 s.StdOut = s.systemStdOut
335 s.pagerProcess = nil
338func (s *IOStreams) StartSpinner(format string, a ...any) {
339 if s.IsOutputTTY() {
340 s.spinner = spinner.New(spinner.CharSets[9], 100*time.Millisecond, spinner.WithWriter(s.StdErr))
341 if format != "" {
342 s.spinner.Suffix = fmt.Sprintf(" "+format, a...)
343 }
344 s.spinner.Start()
345 }
348func (s *IOStreams) StopSpinner(format string, a ...any) {
349 if s.spinner != nil {
350 s.spinner.Suffix = ""
351 s.spinner.FinalMSG = fmt.Sprintf(format, a...)
352 s.spinner.Stop()
353 s.spinner = nil
354 }
357func (s *IOStreams) TerminalWidth() int {
358 return TerminalWidth(s.StdOut)
361// IsOutputTTY returns true if both stdout and stderr are TTYs.
362// Use this for output formatting decisions (tables vs plain text).
363// For interactive prompts, use PromptEnabled() or IsInteractive() instead.
364func (s *IOStreams) IsOutputTTY() bool {
365 return s.IsErrTTY && s.IsaTTY
368// IsInteractive returns true if the environment supports interactive prompts that require user input.
369// This checks if stdin is a TTY and prompts are enabled (stdout/stderr are TTYs and prompts are not
370// disabled with GLAB_NO_PROMPT or the no_prompt config).
371// Use this before displaying interactive forms/menus that need to read user input (e.g., huh forms).
372func (s *IOStreams) IsInteractive() bool {
373 return s.IsInTTY && s.PromptEnabled()
376// CanPrompt returns true if the environment can show a prompt and read the answer.
377// Unlike IsInteractive, it does not require stdout to be a TTY, so it works when
378// stdout is piped. Use this for yes/no consent prompts that write to stderr.
379func (s *IOStreams) CanPrompt() bool {
380 return !s.promptDisabled && s.IsInTTY && s.IsErrTTY
383// ResolveBackgroundColor resolves the glamour style to render markdown with,
384// given style (typically the `glamour_style` config value). A resolved value
385// of "auto" (whether passed in directly or via GLAB_GLAMOUR_STYLE/
386// GLAMOUR_STYLE) triggers real terminal-background detection instead of
387// being forwarded to glamour, which has no style by that name. Any other
388// resolved value (a named style like "dark"/"light"/"notty", or a path to a
389// custom style file) is returned as-is.
390func (s *IOStreams) ResolveBackgroundColor(style string) string {
391 resolvedStyle := style
393 styleEnvVar := os.Getenv("GLAB_GLAMOUR_STYLE")
394 deprecatedStyleEnvVar := os.Getenv("GLAMOUR_STYLE")
395 switch {
396 case styleEnvVar != "":
397 resolvedStyle = styleEnvVar
398 case deprecatedStyleEnvVar != "":
399 utils.PrintDeprecationWarning("GLAMOUR_STYLE")
400 resolvedStyle = deprecatedStyleEnvVar
401 }
403 if s.ColorMode() == ColorModeNever {
404 s.backgroundColor = "none"
405 return "none"
406 }
408 if resolvedStyle != "auto" {
409 s.backgroundColor = resolvedStyle
410 return resolvedStyle
411 }
413 if !s.ColorEnabled() || s.pagerProcess != nil {
414 s.backgroundColor = "none"
415 return "none"
416 }
418 if termenv.HasDarkBackground() {
419 s.backgroundColor = "dark"
420 return "dark"
421 }
423 s.backgroundColor = "light"
424 return "light"
427func (s *IOStreams) BackgroundColor() string {
428 if s.backgroundColor == "" {
429 return "none"
430 }
431 return s.backgroundColor
434// DisplayHyperlinks returns the current hyperlink display mode.
435// One of "always", "auto", or "never".
436func (s *IOStreams) DisplayHyperlinks() string {
437 return s.displayHyperlinks
440func (s *IOStreams) SetDisplayHyperlinks(displayHyperlinks string) {
441 s.displayHyperlinks = displayHyperlinks
444func (s *IOStreams) shouldDisplayHyperlinks() bool {
445 switch s.displayHyperlinks {
446 case "always":
447 return true
448 case "auto":
449 return s.IsaTTY && s.pagerProcess == nil
450 default:
451 return false
452 }
455func (s *IOStreams) Hyperlink(displayText, targetURL string) string {
456 if !s.shouldDisplayHyperlinks() {
457 return displayText
458 }
460 openSequence := fmt.Sprintf("\x1b]8;;%s\x1b\\", targetURL)
461 closeSequence := "\x1b]8;;\x1b\\"
463 return openSequence + displayText + closeSequence
466func (s *IOStreams) Confirm(ctx context.Context, result *bool, title string) error {
467 return s.Run(ctx,
468 huh.NewConfirm().
469 Title(title).
470 Affirmative("Yes!").
471 Negative("No.").
472 Value(result))
475func (s *IOStreams) Input(ctx context.Context, result *string, title, placeholder string, validator func(string) error) error {
476 input := huh.NewInput().
477 Title(title).
478 Value(result)
480 if placeholder != "" {
481 input = input.Placeholder(placeholder)
482 }
483 if validator != nil {
484 input = input.Validate(validator)
485 }
487 return s.Run(ctx, input)
490func (s *IOStreams) InputWithDescription(ctx context.Context, result *string, title, description, placeholder string, validator func(string) error) error {
491 input := huh.NewInput().
492 Title(title).
493 Description(description).
494 Value(result)
496 if placeholder != "" {
497 input = input.Placeholder(placeholder)
498 }
499 if validator != nil {
500 input = input.Validate(validator)
501 }
503 return s.Run(ctx, input)
506func (s *IOStreams) Password(ctx context.Context, result *string, title string, validator func(string) error) error {
507 input := huh.NewInput().
508 Title(title).
509 EchoMode(huh.EchoModePassword).
510 Value(result)
512 if validator != nil {
513 input = input.Validate(validator)
514 }
516 return s.Run(ctx, input)
519func (s *IOStreams) Select(ctx context.Context, result *string, title string, options []string) error {
520 return s.Run(ctx,
521 huh.NewSelect[string]().
522 Title(title).
523 Options(huh.NewOptions(options...)...).
524 Value(result))
527func (s *IOStreams) MultiSelect(ctx context.Context, result *[]string, title string, options []string) error {
528 // Set a reasonable height limit for the multiselect to ensure it displays properly
529 limit := min(len(options), 10)
531 return s.Run(ctx,
532 huh.NewMultiSelect[string]().
533 Title(title).
534 Options(huh.NewOptions(options...)...).
535 Filterable(true).
536 Limit(limit).
537 Value(result))
540func (s *IOStreams) Multiline(ctx context.Context, result *string, title, placeholder string) error {
541 text := huh.NewText().
542 Title(title).
543 Value(result)
545 if placeholder != "" {
546 text = text.Placeholder(placeholder)
547 }
549 return s.Run(ctx, text)
552func (s *IOStreams) Editor(ctx context.Context, result *string, title, description, defaultContent, editorCmd string) error {
553 // Set the default content if provided - MUST be done before Value(result)
554 if defaultContent != "" {
555 *result = defaultContent
556 }
558 text := huh.NewText().
559 Title(title).
560 Value(result).
561 ExternalEditor(true).
562 EditorExtension(".md")
564 // Set the description (help text) if provided
565 if description != "" {
566 text = text.Description(description)
567 }
569 // Set the editor command if provided
570 if editorCmd != "" {
571 // Parse editor command with arguments and pass to huh's variadic Editor method
572 editorParts := utils.ParseEditorCommand(editorCmd)
573 if len(editorParts) > 0 {
574 text = text.Editor(editorParts...)
575 }
576 }
578 return s.Run(ctx, text)
581// DirectEditor opens an external editor with the given content in a temporary file,
582// waits for the editor to close, and returns the edited content. This is useful when
583// the user explicitly requests to use an external editor (e.g., via -d- flag).
584func (s *IOStreams) DirectEditor(ctx context.Context, result *string, defaultContent, editorCmd string) error {
585 // Create a temporary file with the default content
586 tmpFile, err := os.CreateTemp(os.TempDir(), "*.md")
587 if err != nil {
588 return fmt.Errorf("failed to create temp file: %w", err)
589 }
590 tmpPath := tmpFile.Name()
591 defer os.Remove(tmpPath)
593 // Write the default content to the temp file
594 if defaultContent != "" {
595 if _, err := tmpFile.WriteString(defaultContent); err != nil {
596 _ = tmpFile.Close() // Best effort cleanup
597 return fmt.Errorf("failed to write to temp file: %w", err)
598 }
599 }
600 if err := tmpFile.Close(); err != nil {
601 return fmt.Errorf("failed to close temp file: %w", err)
602 }
604 // Determine which editor to use
605 editor := editorCmd
606 if editor == "" {
607 // Fall back to environment variables in order of preference
608 switch {
609 case os.Getenv("VISUAL") != "":
610 editor = os.Getenv("VISUAL")
611 case os.Getenv("EDITOR") != "":
612 editor = os.Getenv("EDITOR")
613 default:
614 editor = "nano"
615 }
616 }
618 // Parse editor command and args using shlex to handle quoted arguments
619 editorParts, err := shlex.Split(editor)
620 if err != nil || len(editorParts) == 0 {
621 return fmt.Errorf("failed to parse editor command: %w", err)
622 }
624 // Build command with editor args and temp file path
625 cmd := exec.CommandContext(ctx, editorParts[0], append(editorParts[1:], tmpPath)...)
627 // Connect the editor to the terminal
628 cmd.Stdin = s.In
629 cmd.Stdout = s.StdOut
630 cmd.Stderr = s.StdErr
632 // Run the editor
633 if err := cmd.Run(); err != nil {
634 return fmt.Errorf("failed to run editor: %w", err)
635 }
637 // Read the edited content back
638 editedContent, err := os.ReadFile(tmpPath)
639 if err != nil {
640 return fmt.Errorf("failed to read edited content: %w", err)
641 }
643 *result = string(editedContent)
644 return nil
647func (s *IOStreams) Run(ctx context.Context, field huh.Field) error {
648 group := huh.NewGroup(field)
650 // Show help for Text and MultiSelect fields since they have non-obvious keybindings
651 showHelp := false
652 if _, isText := field.(*huh.Text); isText {
653 showHelp = true
654 }
655 if _, isMultiSelect := field.(*huh.MultiSelect[string]); isMultiSelect {
656 showHelp = true
657 }
659 form := huh.NewForm(group).
660 WithShowHelp(showHelp).
661 WithTheme(theme.HuhTheme())
662 s.applyFormIO(form)
664 err := form.RunWithContext(ctx)
666 if errors.Is(err, huh.ErrUserAborted) {
667 fmt.Fprintln(s.StdErr, "Cancelled.")
668 return ErrUserCancelled
669 }
671 return err
674// RunForm runs a multi-field form with all fields in a single group.
675// This allows users to navigate between fields and provides a better UX than running
676// individual prompts in sequence.
677func (s *IOStreams) RunForm(ctx context.Context, fields ...huh.Field) error {
678 if len(fields) == 0 {
679 return nil
680 }
682 group := huh.NewGroup(fields...)
684 showHelp := false
685 for _, field := range fields {
686 if _, isText := field.(*huh.Text); isText {
687 showHelp = true
688 break
689 }
690 if _, isMultiSelect := field.(*huh.MultiSelect[string]); isMultiSelect {
691 showHelp = true
692 break
693 }
694 }
696 form := huh.NewForm(group).
697 WithShowHelp(showHelp).
698 WithTheme(theme.HuhTheme())
699 s.applyFormIO(form)
701 err := form.RunWithContext(ctx)
703 if errors.Is(err, huh.ErrUserAborted) {
704 fmt.Fprintln(s.StdErr, "Cancelled.")
705 return ErrUserCancelled
706 }
708 return err
711func (s *IOStreams) applyFormIO(form *huh.Form) {
712 if len(s.programOptions) > 0 {
713 opts := []tea.ProgramOption{
714 tea.WithInput(nopCloseReader{s.In}),
715 tea.WithOutput(s.StdOut),
716 }
717 opts = append(opts, s.programOptions...)
718 form.WithProgramOptions(opts...)
719 } else {
720 form.WithInput(s.In).WithOutput(s.StdOut)
721 }
724type nopCloseReader struct {
725 io.Reader
728func (nopCloseReader) Close() error { return nil }
Diagnostics6 git calls · 41 ms
CallStatusSizeTime041 ms
discover200185 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
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 · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=3
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
fetchtree:0 · deepen 1020032 KiB · hit3 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=3
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
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit4 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=4
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:0200432 B · hit3 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=432
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=a79e8e89fbedf0d57724da455f6326f6e79de3b5
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=432
git.pkt.payload.max=405
git.sideband.band1.bytes=405
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=405
git.pack.trailer=6b5f558fa7a37603ce66aafb676f53aedcb02370
Open pack map
fetch2005.9 KiB · hit31 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=31
git.response.bytes=6039
git.response.cache=HIT
git.response.duration_ms=31
git.fetch.wants=a985db9e7b1dfffd73fe269985407a4f6f5efe5c
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=6039
git.pkt.payload.max=6012
git.sideband.band1.bytes=6012
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
a5e2c8366b0b4b67
Request
1134bf67…
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