GitLabgitlab-org
cli
main
1package view
3import (
4 "bufio"
5 "context"
6 "errors"
7 "fmt"
8 "io"
9 "log"
10 "os"
11 "runtime/debug"
12 "strings"
13 "time"
14 "unicode/utf8"
16 "github.com/MakeNowJust/heredoc/v2"
17 "github.com/gdamore/tcell/v2"
18 "github.com/lunixbochs/vtclean"
19 "github.com/mattn/go-runewidth"
20 "github.com/rivo/tview"
21 "github.com/spf13/cobra"
22 "golang.org/x/text/cases"
23 "golang.org/x/text/language"
25 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
27 "gitlab.com/gitlab-org/cli/internal/api"
28 "gitlab.com/gitlab-org/cli/internal/cmdutils"
29 "gitlab.com/gitlab-org/cli/internal/commands/ci/ciutils"
30 "gitlab.com/gitlab-org/cli/internal/config"
31 "gitlab.com/gitlab-org/cli/internal/git"
32 "gitlab.com/gitlab-org/cli/internal/glrepo"
33 "gitlab.com/gitlab-org/cli/internal/iostreams"
34 "gitlab.com/gitlab-org/cli/internal/mcpannotations"
35 "gitlab.com/gitlab-org/cli/internal/utils"
36)
38type options struct {
39 io *iostreams.IOStreams
40 gitlabClient func() (*gitlab.Client, error)
41 baseRepo func() (glrepo.Interface, error)
42 config func() config.Config
44 refName string
45 openInBrowser bool
46 pipelineID int64
47}
49type ViewJobKind int64
51const (
52 Job ViewJobKind = iota
53 Bridge
54)
56type ViewJob struct {
57 ID int64 `json:"id"`
58 Name string `json:"name"`
59 StartedAt *time.Time `json:"started_at"`
60 FinishedAt *time.Time `json:"finished_at"`
61 ErasedAt *time.Time `json:"erased_at"`
62 Duration float64 `json:"duration"`
63 Stage string `json:"stage"`
64 Status string `json:"status"`
65 AllowFailure bool `json:"allow_failure"`
67 Kind ViewJobKind
69 OriginalJob *gitlab.Job
70 OriginalBridge *gitlab.Bridge
71}
73func ViewJobFromBridge(bridge *gitlab.Bridge) *ViewJob {
74 vj := &ViewJob{}
75 vj.ID = bridge.ID
76 vj.Name = bridge.Name
77 vj.Status = bridge.Status
78 vj.Stage = bridge.Stage
79 vj.StartedAt = bridge.StartedAt
80 vj.FinishedAt = bridge.FinishedAt
81 vj.ErasedAt = bridge.ErasedAt
82 vj.Duration = bridge.Duration
83 vj.AllowFailure = bridge.AllowFailure
84 vj.OriginalBridge = bridge
85 vj.Kind = Bridge
86 return vj
87}
89func ViewJobFromJob(job *gitlab.Job) *ViewJob {
90 vj := &ViewJob{}
91 vj.ID = job.ID
92 vj.Name = job.Name
93 vj.Status = job.Status
94 vj.Stage = job.Stage
95 vj.StartedAt = job.StartedAt
96 vj.FinishedAt = job.FinishedAt
97 vj.ErasedAt = job.ErasedAt
98 vj.Duration = job.Duration
99 vj.AllowFailure = job.AllowFailure
100 vj.OriginalJob = job
101 vj.Kind = Job
102 return vj
103}
105func NewCmdView(f cmdutils.Factory) *cobra.Command {
106 opts := options{
107 io: f.IO(),
108 gitlabClient: f.GitLabClient,
109 baseRepo: f.BaseRepo,
110 config: f.Config,
111 }
112 pipelineCIView := &cobra.Command{
113 Use: "view [<branch | tag>]",
114 Short: "View, run, retry, and cancel CI/CD pipeline jobs.",
115 Long: heredoc.Docf(`Supports viewing, running, tracing, and canceling jobs.
117 Use arrow keys to navigate jobs and logs.
119 - %[1]sEnter%[1]s to toggle through a job's logs / traces, or display a child pipeline.
120 Trigger jobs are marked with a %[1]s»%[1]s.
121 - %[1]sEsc%[1]s or %[1]sq%[1]s to close the logs or trace, or return to the parent pipeline.
122 - %[1]sCtrl+R%[1]s, %[1]sCtrl+P%[1]s to run, retry, or play a job. Use %[1]sTab%[1]s, arrow keys, or
123 %[1]sh%[1]s/%[1]sj%[1]s/%[1]sk%[1]s/%[1]sl%[1]s to navigate the modal, and %[1]sEnter%[1]s to confirm.
124 - %[1]sCtrl+D%[1]s to cancel a job. If the selected job isn't running or pending,
125 quits the CI/CD view.
126 - %[1]sCtrl+S%[1]s to show the full name of the selected job.
127 - %[1]sCtrl+Q%[1]s to quit the CI/CD view.
128 - %[1]sCtrl+Space%[1]s to suspend application and view the logs. Similar to %[1]sglab ci trace%[1]s.
129 - Supports %[1]svi%[1]s style bindings and arrow keys for navigating jobs and logs.
131 Job names too long for their box scroll while the job is selected.
132 `, "`"),
133 Annotations: map[string]string{
134 mcpannotations.Destructive: "true",
135 mcpannotations.Interactive: "true",
136 },
137 Example: heredoc.Doc(`
138 # Use the current branch
139 glab ci view
141 # View the latest pipeline on main
142 glab ci view main
144 # View the latest pipeline on main using a flag
145 glab ci view -b main
147 # View the latest pipeline on main for another project
148 glab ci view -b main -R myusername/myproject`),
149 Args: cobra.MaximumNArgs(1),
150 RunE: func(cmd *cobra.Command, args []string) error {
151 if err := opts.complete(args); err != nil {
152 return err
153 }
155 return opts.run(cmd.Context())
156 },
157 }
159 pipelineCIView.Flags().
160 StringVarP(&opts.refName, "branch", "b", "", "Check pipeline status for a branch or tag. Defaults to the current branch.")
161 pipelineCIView.Flags().BoolVarP(&opts.openInBrowser, "web", "w", false, "Open pipeline in a browser. Uses the default browser, or the browser specified in the BROWSER environment variable.")
162 pipelineCIView.Flags().Int64VarP(&opts.pipelineID, "pipelineid", "p", 0, "Check pipeline status for a specific pipeline ID.")
163 pipelineCIView.MarkFlagsMutuallyExclusive("branch", "pipelineid")
165 return pipelineCIView
166}
168func (o *options) complete(args []string) error {
169 if o.refName == "" {
170 if len(args) == 1 {
171 o.refName = args[0]
172 } else {
173 refName, err := git.CurrentBranch()
174 if err != nil {
175 return err
176 }
177 o.refName = refName
178 }
179 }
181 return nil
182}
184func (o *options) run(ctx context.Context) error {
185 // Check if we're in an interactive terminal (TTY required for TUI)
186 if !o.io.IsOutputTTY() {
187 return fmt.Errorf("ci view requires an interactive terminal (TTY).\nFor non-interactive use, try:\n - 'glab ci status' to check pipeline status\n - 'glab ci get' to view pipeline details\n - 'glab ci trace' to view job logs")
188 }
190 client, err := o.gitlabClient()
191 if err != nil {
192 return err
193 }
195 repo, err := o.baseRepo()
196 if err != nil {
197 return err
198 }
200 projectID := repo.FullName()
202 var pipeline *gitlab.Pipeline
203 if o.pipelineID != 0 {
204 pipeline, _, err = client.Pipelines.GetPipeline(projectID, o.pipelineID)
205 if err != nil {
206 return fmt.Errorf("can't get pipeline #%d info: %w", o.pipelineID, err)
207 }
208 } else {
209 // The commit's newest pipeline may belong to another branch.
210 pipeline, err = ciutils.GetPipelineWithFallback(ctx, client, projectID, o.refName, o.io)
211 if err != nil {
212 return err
213 }
214 }
216 if o.openInBrowser { // open in browser if --web flag is specified
217 if o.io.IsOutputTTY() {
218 o.io.LogErrorf("Opening %s in your browser.\n", utils.DisplayURL(pipeline.WebURL))
219 }
221 cfg := o.config()
222 browser, _ := cfg.Get(repo.RepoHost(), "browser")
223 return utils.OpenInBrowser(pipeline.WebURL, browser)
224 }
226 // The job grid, logs, cancel, and retry all read the top of this stack to
227 // decide which pipeline they are acting on.
228 pipelines = append(make([]gitlab.PipelineInfo, 0, 10), pipelineInfo(pipeline))
230 // Use terminal default colors instead of tview's hardcoded white-on-black theme.
231 tview.Styles = tview.Theme{}
233 root := tview.NewPages()
234 root.
235 SetBackgroundColor(tcell.ColorDefault).
236 SetBorderPadding(1, 1, 2, 2).
237 SetBorder(true).
238 SetTitle(fmt.Sprintf(" Pipeline #%d triggered %s by %s ", pipeline.ID, utils.TimeToPrettyTimeAgo(*pipeline.CreatedAt), pipeline.User.Name))
240 boxes = make(map[string]*tview.TextView)
241 jobsCh := make(chan []*ViewJob)
242 forceUpdateCh := make(chan bool)
243 inputCh := make(chan struct{})
245 screen, err := tcell.NewScreen()
246 if err != nil {
247 return err
248 }
249 defer func() {
250 if screen != nil {
251 screen.Fini()
252 }
253 }()
254 app := tview.NewApplication()
255 defer recoverPanic(app)
257 var navi navigator
258 app.SetInputCapture(inputCapture(ctx, app, root, &navi, inputCh, forceUpdateCh, o, client))
259 go updateJobs(app, jobsCh, forceUpdateCh, client)
260 go func() {
261 defer recoverPanic(app)
262 for {
263 app.SetFocus(root)
264 jobsView(ctx, app, jobsCh, inputCh, root, client)
265 app.Draw()
266 }
267 }()
268 if err := app.SetScreen(screen).SetRoot(root, true).SetAfterDrawFunc(linkJobsView(app)).Run(); err != nil {
269 return err
270 }
271 return nil
272}
274// Styles for making the focused button visible
275var buttonActivatedStyle = tcell.StyleDefault.Underline(true).Bold(true).Reverse(true)
277// handleBridgeJobSelection handles the user pressing Enter on a bridge job (downstream pipeline trigger).
278// It navigates to the downstream pipeline if it exists, or shows an informational modal if it doesn't.
279func handleBridgeJobSelection(app *tview.Application, root *tview.Pages, forceUpdateCh chan<- bool, navi *navigator) {
280 // If downstream pipeline exists, navigate to it
281 if curJob.OriginalBridge.DownstreamPipeline != nil {
282 pipelines = append(pipelines, *curJob.OriginalBridge.DownstreamPipeline)
283 curJob = nil
284 // Reset cursor: the child pipeline has a different jobs slice, so a stale
285 // idx/depth from the parent can index past the end and crash Navigate (#8313).
286 *navi = navigator{}
287 forceUpdateCh <- true
288 app.ForceDraw()
289 return
290 }
292 // No downstream pipeline exists yet - show informational modal
293 modalVisible = true
295 // Determine appropriate message based on job status
296 // Note: We suggest GitLab UI instead of Ctrl+R/P because bridge jobs cannot be
297 // manually triggered via the CLI - they are excluded from the run/retry commands
298 // (see line 377: if curJob.Kind != Job { break })
299 var message string
300 switch curJob.Status {
301 case string(gitlab.Manual):
302 message = fmt.Sprintf("Downstream pipeline '%s' is waiting to be triggered.\n\nStatus: %s\n\nThis trigger will create a child pipeline when it runs.\nTrigger it via the GitLab UI or wait for the pipeline to run it.", curJob.Name, curJob.Status)
303 case string(gitlab.Pending), string(gitlab.Created):
304 message = fmt.Sprintf("Downstream pipeline '%s' has not started yet.\n\nStatus: %s\n\nThis trigger will create a child pipeline when it runs.", curJob.Name, curJob.Status)
305 case string(gitlab.Skipped):
306 message = fmt.Sprintf("Downstream pipeline '%s' was skipped and won't create a child pipeline.\n\nStatus: %s", curJob.Name, curJob.Status)
307 default:
308 message = fmt.Sprintf("Downstream pipeline '%s' has not triggered a child pipeline yet.\n\nStatus: %s\n\nThe child pipeline will appear here once the trigger completes.", curJob.Name, curJob.Status)
309 }
311 modal := tview.NewModal().
312 SetBackgroundColor(tcell.ColorDefault).
313 SetText(tview.Escape(message)).
314 AddButtons([]string{"OK"}).
315 SetButtonActivatedStyle(buttonActivatedStyle).
316 SetDoneFunc(func(buttonIndex int, buttonLabel string) {
317 modalVisible = false
318 root.RemovePage("downstream-info")
319 app.ForceDraw()
320 })
321 root.AddAndSwitchToPage("downstream-info", modal, false)
322 app.ForceDraw()
323}
325// jobNamePage is the page name of the modal opened by showJobName.
326const jobNamePage = "job-name"
328// showJobName opens a modal with the full name of the selected job
329func showJobName(app *tview.Application, root *tview.Pages) {
330 modalVisible = true
331 modal := tview.NewModal().
332 SetBackgroundColor(tcell.ColorDefault).
333 SetText(tview.Escape(fmt.Sprintf("Full job name:\n%s", curJob.Name))).
334 AddButtons([]string{"OK"}).
335 SetButtonActivatedStyle(buttonActivatedStyle).
336 SetDoneFunc(func(buttonIndex int, buttonLabel string) {
337 modalVisible = false
338 root.RemovePage(jobNamePage)
339 app.ForceDraw()
340 })
341 root.AddAndSwitchToPage(jobNamePage, modal, false)
342 app.ForceDraw()
343}
345func inputCapture(
346 ctx context.Context,
347 app *tview.Application,
348 root *tview.Pages,
349 navi *navigator,
350 inputCh chan<- struct{},
351 forceUpdateCh chan<- bool,
352 opts *options,
353 apiClient *gitlab.Client,
354) func(event *tcell.EventKey) *tcell.EventKey {
355 return func(event *tcell.EventKey) *tcell.EventKey {
356 if event.Rune() == 'q' || event.Key() == tcell.KeyEscape {
357 switch {
358 case modalVisible:
359 modalVisible = !modalVisible
360 root.HidePage("yesno")
361 root.RemovePage(jobNamePage)
362 if inputCh == nil {
363 inputCh <- struct{}{}
364 }
365 case logsVisible:
366 logsVisible = !logsVisible
367 root.HidePage(logsPageKey(curJob))
368 if inputCh == nil {
369 inputCh <- struct{}{}
370 }
371 app.ForceDraw()
372 // Only a descent stacks a second pipeline; at the bottom, quit.
373 case len(pipelines) > 1:
374 pipelines = pipelines[:len(pipelines)-1]
375 curJob = nil
376 // Reset cursor: see comment in handleBridgeJobSelection (#8313).
377 *navi = navigator{}
378 forceUpdateCh <- true
379 app.ForceDraw()
380 default:
381 app.Stop()
382 return nil
383 }
384 }
385 event = normalizeViKeys(event)
386 if !modalVisible && !logsVisible && len(jobs) > 0 {
387 curJob = navi.Navigate(jobs, event)
388 root.SendToFront("jobs-" + curJob.Name)
389 if inputCh == nil {
390 inputCh <- struct{}{}
391 }
392 }
393 event = normalizeCtrlM(event)
394 switch event.Key() {
395 case tcell.KeyCtrlQ:
396 app.Stop()
397 return nil
398 case tcell.KeyCtrlD:
399 if curJob.Kind == Job && (curJob.Status == string(gitlab.Pending) || curJob.Status == string(gitlab.Running)) {
400 modalVisible = true
401 modal := tview.NewModal().
402 SetBackgroundColor(tcell.ColorDefault).
403 SetText(tview.Escape(fmt.Sprintf("Are you sure you want to cancel %s?", curJob.Name))).
404 AddButtons([]string{"✘ No", "✔ Yes"}).
405 SetButtonActivatedStyle(buttonActivatedStyle).
406 SetDoneFunc(func(buttonIndex int, buttonLabel string) {
407 modalVisible = false
408 root.RemovePage("yesno")
409 if buttonLabel == "✘ No" {
410 app.ForceDraw()
411 return
412 }
413 root.RemovePage(logsPageKey(curJob))
414 app.ForceDraw()
415 job, _, err := apiClient.Jobs.CancelJob(curProjectID(app), curJob.ID)
416 if err != nil {
417 app.Stop()
418 log.Fatal(err)
419 }
420 if job != nil {
421 curJob = ViewJobFromJob(job)
422 app.ForceDraw()
423 }
424 })
425 root.AddAndSwitchToPage("yesno", modal, false)
426 inputCh <- struct{}{}
427 app.ForceDraw()
428 return nil
429 }
430 case tcell.KeyCtrlP, tcell.KeyCtrlR:
431 if modalVisible || curJob.Kind != Job {
432 break
433 }
434 modalVisible = true
435 modal := tview.NewModal().
436 SetBackgroundColor(tcell.ColorDefault).
437 SetText(tview.Escape(fmt.Sprintf("Are you sure you want to run %s?", curJob.Name))).
438 AddButtons([]string{"✘ No", "✔ Yes"}).
439 SetButtonActivatedStyle(buttonActivatedStyle).
440 SetDoneFunc(func(buttonIndex int, buttonLabel string) {
441 modalVisible = false
442 root.RemovePage("yesno")
443 if buttonLabel != "✔ Yes" {
444 app.ForceDraw()
445 return
446 }
447 root.RemovePage(logsPageKey(curJob))
448 app.ForceDraw()
450 job, err := api.PlayOrRetryJobs(
451 apiClient,
452 curProjectID(app),
453 curJob.ID,
454 curJob.Status,
455 )
456 if err != nil {
457 app.Stop()
458 log.Fatal(err)
459 }
460 if job != nil {
461 curJob = ViewJobFromJob(job)
462 app.ForceDraw()
463 }
464 })
465 root.AddAndSwitchToPage("yesno", modal, false)
466 inputCh <- struct{}{}
467 app.ForceDraw()
468 return nil
469 case tcell.KeyCtrlS:
470 if modalVisible || curJob == nil {
471 break
472 }
473 showJobName(app, root)
474 inputCh <- struct{}{}
475 return nil
476 case tcell.KeyEnter:
477 if !modalVisible {
478 if curJob.Kind == Job {
479 logsVisible = !logsVisible
480 if !logsVisible {
481 root.HidePage(logsPageKey(curJob))
482 }
483 inputCh <- struct{}{}
484 app.ForceDraw()
485 } else {
486 // Downstream pipeline trigger selected
487 handleBridgeJobSelection(app, root, forceUpdateCh, navi)
488 }
489 return nil
490 }
491 case tcell.KeyCtrlSpace:
492 // A bridge ID is not a job ID. Enter descends into it instead.
493 if curJob.Kind != Job {
494 break
495 }
496 // curJob moves as the user navigates, so snapshot before suspending.
497 traceJob := curJob
498 traceProjectID := curProjectID(app)
499 app.Suspend(func() {
500 ctx, cancel := context.WithCancel(ctx)
501 go func() {
502 err := ciutils.RunTraceJob(
503 ctx,
504 apiClient,
505 opts.io.StdOut,
506 traceProjectID,
507 traceJob.ID,
508 ciutils.DefaultTracePollInterval,
509 )
510 if err != nil {
511 app.Stop()
512 log.Fatal(err)
513 }
514 if ctx.Err() == nil {
515 fmt.Println("\nPress <Enter> to resume the ci GUI view.")
516 }
517 }()
518 reader := bufio.NewReader(os.Stdin)
519 for {
520 r, _, err := reader.ReadRune()
521 if !errors.Is(err, io.EOF) && err != nil {
522 app.Stop()
523 log.Fatal(err)
524 }
525 if r == '\n' {
526 cancel()
527 break
528 }
529 }
530 })
531 if inputCh == nil {
532 inputCh <- struct{}{}
533 }
534 return nil
535 }
536 if inputCh == nil {
537 inputCh <- struct{}{}
538 }
539 return event
540 }
541}
543// pipelineInfo narrows a pipeline to the shape the stack holds, matching the
544// downstream pipelines that arrive from bridges.
545func pipelineInfo(p *gitlab.Pipeline) gitlab.PipelineInfo {
546 return gitlab.PipelineInfo{
547 ID: p.ID,
548 IID: p.IID,
549 ProjectID: p.ProjectID,
550 Status: p.Status,
551 Source: string(p.Source),
552 Ref: p.Ref,
553 SHA: p.SHA,
554 Name: p.Name,
555 WebURL: p.WebURL,
556 UpdatedAt: p.UpdatedAt,
557 CreatedAt: p.CreatedAt,
558 }
559}
561// curProjectID returns the project owning the pipeline being viewed. Resolve it
562// per action: descending into a child pipeline changes it.
563func curProjectID(app *tview.Application) int64 {
564 pipeline, err := curPipeline()
565 if err != nil {
566 app.Stop()
567 log.Fatalf("%v", err)
568 }
569 return pipeline.ProjectID
570}
572// logsPageKey names a job's cached trace page. Parent and child pipelines
573// reuse job names, so only the ID is unique.
574func logsPageKey(job *ViewJob) string {
575 return fmt.Sprintf("logs-%d", job.ID)
576}
578func normalizeCtrlM(event *tcell.EventKey) *tcell.EventKey {
579 if event.Key() == tcell.KeyCtrlM {
580 return tcell.NewEventKey(tcell.KeyEnter, 0, tcell.ModNone)
581 }
582 return event
583}
585var viKeys = map[rune]tcell.Key{
586 'h': tcell.KeyLeft,
587 'j': tcell.KeyDown,
588 'k': tcell.KeyUp,
589 'l': tcell.KeyRight,
590}
592func normalizeViKeys(event *tcell.EventKey) *tcell.EventKey {
593 if event.Key() != tcell.KeyRune {
594 return event
595 }
596 if key, ok := viKeys[event.Rune()]; ok {
597 return tcell.NewEventKey(key, 0, event.Modifiers())
598 }
599 return event
600}
602var (
603 logsVisible, modalVisible bool
604 curJob *ViewJob
605 jobs []*ViewJob
606 pipelines []gitlab.PipelineInfo
607 boxes map[string]*tview.TextView
609 // titleScroll marquees the name of the selected job, see titleScroller.
610 titleScroll titleScroller
611)
613const (
614 // maxTitle is the number of columns a job box gives its title. The box is
615 // drawn maxTitle+2 wide and tview draws the title between the borders.
616 maxTitle = 20
617 // statusWidth is the width of the status glyph and the space that precedes
618 // every job title, for example "✔ ".
619 statusWidth = 2
620 // scrollPause is how many redraws the marquee rests at each end of a job
621 // name before moving on, so that both ends stay readable.
622 scrollPause = 7
623)
625// titleScroller marquees the title of the selected job, so a name too long for
626// its box can still be read in full. It advances one column per redraw of the
627// jobs view.
628type titleScroller struct {
629 jobName string // name of the job being scrolled
630 offset int // leading runes of the name already scrolled past
631 pause int // redraws spent resting at the current offset
632}
634// follow points the scroller at job, restarting from the first character
635// whenever the selection moves.
636func (s *titleScroller) follow(jobName string) {
637 if s.jobName != jobName {
638 *s = titleScroller{jobName: jobName}
639 }
640}
642// scroll returns the leading part of name that fits in width display columns
643// at the current marquee offset, and advances the marquee. Names that already
644// fit are returned untouched. The offset counts runes but the window is
645// measured in columns, so a double-width rune (CJK, emoji) is never split and
646// the result never exceeds width columns.
647func (s *titleScroller) scroll(name string, width int) string {
648 runes := []rune(name)
649 if width < 1 || runewidth.StringWidth(name) <= width {
650 s.offset, s.pause = 0, 0
651 return name
652 }
653 // tailStart is the smallest offset whose remaining runes still fit in
654 // width columns: the marquee's resting place at the end of the name.
655 w, tailStart := 0, len(runes)
656 for tailStart > 0 {
657 rw := runewidth.RuneWidth(runes[tailStart-1])
658 if w+rw > width {
659 break
660 }
661 w += rw
662 tailStart--
663 }
664 if s.offset > tailStart {
665 s.offset = tailStart
666 }
668 w, end := 0, s.offset
669 for end < len(runes) {
670 rw := runewidth.RuneWidth(runes[end])
671 if w+rw > width {
672 break
673 }
674 w += rw
675 end++
676 }
677 visible := string(runes[s.offset:end])
679 atEnd := s.offset >= tailStart
680 switch {
681 case (s.offset == 0 || atEnd) && s.pause < scrollPause:
682 s.pause++
683 case atEnd:
684 s.offset, s.pause = 0, 0
685 default:
686 s.offset++
687 s.pause = 0
688 }
689 return visible
690}
692// bracketEscaper wraps a writer and escapes square brackets for tview, but preserves ANSI escape sequences.
693// This is necessary because tview interprets square brackets as color tag markers.
694// For example, [MASKED] would be treated as a color tag and stripped from display.
695// By escaping closing brackets to [], we prevent tview from parsing literal brackets as tags.
696type bracketEscaper struct {
697 io.Writer
698}
700func (b *bracketEscaper) Write(p []byte) (int, error) {
701 // Build escaped output, preserving ANSI escape sequences
702 // In tview's escaping convention, only closing ] needs to be escaped to []
703 var result strings.Builder
704 i := 0
705 for i < len(p) {
706 // Check if this is the start of an ANSI escape sequence: ESC [
707 switch {
708 case i < len(p)-1 && p[i] == '\x1b' && p[i+1] == '[':
709 // Find the end of the ANSI sequence (ends with a letter)
710 result.WriteByte(p[i]) // ESC
711 result.WriteByte(p[i+1]) // [
712 i += 2
713 // Copy the rest of the ANSI sequence
714 for i < len(p) && !((p[i] >= 'A' && p[i] <= 'Z') || (p[i] >= 'a' && p[i] <= 'z')) {
715 result.WriteByte(p[i])
716 i++
717 }
718 if i < len(p) {
719 result.WriteByte(p[i]) // Final letter
720 i++
721 }
722 case p[i] == ']':
723 // Literal closing bracket - escape it for tview by replacing with []
724 result.WriteString("[]")
725 i++
726 default:
727 result.WriteByte(p[i])
728 i++
729 }
730 }
732 // Write the escaped data to the underlying writer
733 _, err := b.Writer.Write([]byte(result.String()))
734 if err != nil {
735 return 0, err
736 }
737 // Return the number of bytes consumed from input (per io.Writer contract)
738 // We successfully processed all input bytes even though output may be longer
739 return len(p), nil
740}
742// curPipeline returns the pipeline being viewed: the top of the stack run()
743// seeds and descending into a child pipeline pushes onto.
744func curPipeline() (gitlab.PipelineInfo, error) {
745 if len(pipelines) == 0 {
746 return gitlab.PipelineInfo{}, errors.New("no pipeline is being viewed")
747 }
748 return pipelines[len(pipelines)-1], nil
749}
751// navigator manages the internal state for processing tcell.EventKeys
752type navigator struct {
753 depth, idx int
754}
756// Navigate uses the ci stages as boundaries and returns the currently focused
757// job index after processing a *tcell.EventKey
758func (n *navigator) Navigate(jobs []*ViewJob, event *tcell.EventKey) *ViewJob {
759 // Defensive clamp: callers reset navi when switching pipelines, but a stale
760 // idx left over from a larger jobs slice would otherwise panic here (#8313).
761 if n.idx >= len(jobs) {
762 n.idx = 0
763 n.depth = 0
764 }
765 stage := jobs[n.idx].Stage
766 prev, next := adjacentStages(jobs, stage)
767 switch event.Key() {
768 case tcell.KeyLeft:
769 stage = prev
770 case tcell.KeyRight:
771 stage = next
772 }
773 l, u := stageBounds(jobs, stage)
775 switch event.Key() {
776 case tcell.KeyDown:
777 n.depth++
778 if n.depth > u-l {
779 n.depth = u - l
780 }
781 case tcell.KeyUp:
782 n.depth--
783 }
784 switch event.Rune() {
785 case 'g':
786 n.depth = 0
787 case 'G':
788 n.depth = u - l
789 }
791 if n.depth < 0 {
792 n.depth = 0
793 }
794 n.idx = min(l+n.depth, u)
795 return jobs[n.idx]
796}
798func stageBounds(jobs []*ViewJob, s string) (int, int) {
799 if len(jobs) <= 1 {
800 return 0, 0
801 }
802 var l, u int
803 p := jobs[0].Stage
804 for i, v := range jobs {
805 if v.Stage != s && u != 0 {
806 return l, u
807 }
808 if v.Stage != p {
809 l = i
810 p = v.Stage
811 }
812 if v.Stage == s {
813 u = i
814 }
815 }
816 return l, u
817}
819func adjacentStages(jobs []*ViewJob, s string) (string, string) {
820 if len(jobs) == 0 {
821 return "", ""
822 }
823 p := jobs[0].Stage
825 var n string
826 for _, v := range jobs {
827 if v.Stage != s && n != "" {
828 n = v.Stage
829 return p, n
830 }
831 if v.Stage == s {
832 n = "cur"
833 }
834 if n == "" {
835 p = v.Stage
836 }
837 }
838 n = jobs[len(jobs)-1].Stage
839 return p, n
840}
842// jobStatus maps a job's status to the glyph shown in its box title and the
843// colour of the box border. Statuses with no colour of their own return
844// tcell.ColorDefault, which leaves the border as it is.
845func jobStatus(job *ViewJob) (rune, tcell.Color) {
846 switch job.Status {
847 case string(gitlab.Success):
848 return '✔', tcell.ColorGreen
849 case string(gitlab.Failed):
850 if job.AllowFailure {
851 return '!', tcell.ColorOrange
852 }
853 return '✘', tcell.ColorRed
854 case string(gitlab.Running):
855 return '●', tcell.ColorBlue
856 case string(gitlab.Pending):
857 return '●', tcell.ColorYellow
858 case string(gitlab.Manual):
859 return '■', tcell.ColorGrey
860 case string(gitlab.Canceled):
861 return 'Ø', tcell.ColorDefault
862 case string(gitlab.Skipped):
863 return '»', tcell.ColorDefault
864 }
865 return 0, tcell.ColorDefault
866}
868// jobName returns the job name as shown in its box title. Pipelines are often
869// written with a "<job>:<stage>" naming pattern to tell apart the same service
870// built in different stages, and the stage suffix tends to make the title
871// spill over the width of the box, so it is trimmed.
872func jobName(job *ViewJob) string {
873 return strings.TrimSuffix(job.Name, ":"+job.Stage)
874}
876func jobsView(
877 ctx context.Context,
878 app *tview.Application,
879 jobsCh <-chan []*ViewJob,
880 inputCh <-chan struct{},
881 root *tview.Pages,
882 apiClient *gitlab.Client,
883) {
884 select {
885 case jobs = <-jobsCh:
886 case <-inputCh:
887 case <-time.After(time.Millisecond * 250):
888 }
889 if jobs == nil {
890 jobs = <-jobsCh
891 }
892 if curJob == nil && len(jobs) > 0 {
893 curJob = jobs[0]
894 }
895 if modalVisible {
896 return
897 }
898 if logsVisible {
899 logsKey := logsPageKey(curJob)
900 if !root.SwitchToPage(logsKey).HasPage(logsKey) {
901 tv := tview.NewTextView()
902 tv.
903 SetDynamicColors(true).
904 SetBackgroundColor(tcell.ColorDefault).
905 SetBorderPadding(0, 0, 1, 1).
906 SetBorder(true)
908 // curJob moves as the user navigates, so snapshot it before the
909 // goroutine reads it.
910 traceJob := curJob
911 traceProjectID := curProjectID(app)
913 go func() {
914 // Chain: bracketEscaper -> vtclean -> ANSIWriter -> TextView
915 //
916 // The bracketEscaper must come FIRST in the chain to escape literal square
917 // brackets (like [MASKED]) before they reach tview. This prevents tview from
918 // interpreting them as color tags and removing them.
919 //
920 // Flow:
921 // 1. Raw trace with ANSI codes and [MASKED] text
922 // 2. bracketEscaper: Escapes ] to [] while preserving ANSI codes
923 // 3. vtclean: Cleans terminal control sequences, preserves ANSI colors
924 // 4. ANSIWriter: Converts ANSI codes to tview color tags
925 // 5. TextView: Displays with colors and escaped brackets
926 ansiWriter := tview.ANSIWriter(tv)
927 vtcleanWriter := vtclean.NewWriter(ansiWriter, true)
928 bracketWriter := &bracketEscaper{Writer: vtcleanWriter}
930 err := ciutils.RunTraceJob(
931 ctx,
932 apiClient,
933 bracketWriter,
934 traceProjectID,
935 traceJob.ID,
936 ciutils.DefaultTracePollInterval,
937 )
938 if err != nil {
939 app.Stop()
940 log.Fatal(err)
941 }
942 }()
943 root.AddAndSwitchToPage(logsKey, tv, true)
944 }
945 return
946 }
947 px, _, maxX, maxY := root.GetInnerRect()
948 var (
949 stages = 0
950 lastStage = ""
951 )
952 // get the number of stages
953 for _, j := range jobs {
954 if j.Stage != lastStage {
955 lastStage = j.Stage
956 stages++
957 }
958 }
959 lastStage = ""
960 var (
961 rowIdx int
962 stageIdx int
963 )
964 boxKeys := make(map[string]bool)
965 for _, j := range jobs {
966 boxX := px + (maxX / stages * stageIdx)
967 if j.Stage != lastStage {
968 stageIdx++
969 lastStage = j.Stage
970 key := "stage-" + j.Stage
971 boxKeys[key] = true
973 x, y, w, h := boxX, maxY/6-4, maxTitle+2, 3
974 b := box(root, key, x, y, w, h)
976 caser := cases.Title(language.English)
977 b.SetText(caser.String(j.Stage))
978 b.SetTextAlign(tview.AlignCenter)
979 }
980 }
981 lastStage = jobs[0].Stage
982 rowIdx = 0
983 stageIdx = 0
984 titleScroll.follow(curJob.Name)
985 for _, j := range jobs {
986 if j.Stage != lastStage {
987 rowIdx = 0
988 lastStage = j.Stage
989 stageIdx++
990 }
991 boxX := px + (maxX / stages * stageIdx)
993 key := "jobs-" + j.Name
994 boxKeys[key] = true
995 x, y, w, h := boxX, maxY/6+(rowIdx*5), maxTitle+2, 4
996 b := box(root, key, x, y, w, h)
997 // The scope of jobs to show, one or array of: created, pending, running,
998 // failed, success, canceled, skipped; showing all jobs if none provided
999 statChar, borderColor := jobStatus(j)
1000 if borderColor != tcell.ColorDefault {
1001 b.SetBorderColor(borderColor)
1002 }
1003 name := jobName(j)
1004 // Measure the escaped title, which is what tview draws: it reads an
1005 // unescaped "[step]" in a name as a colour tag and counts it as no
1006 // columns at all, so a name that overflows can pass for one that fits.
1007 title := tview.Escape(fmt.Sprintf("%c %s", statChar, name))
1008 if tview.TaggedStringWidth(title) > maxTitle {
1009 // tview default aligns center, which is nice, but if
1010 // the title is too long we want to bias towards seeing
1011 // the beginning of it
1012 b.SetTitleAlign(tview.AlignLeft)
1013 // The selected job scrolls its name so the whole of it can be
1014 // read. Every other box shows the name from the start again.
1015 if j.Name == curJob.Name {
1016 title = tview.Escape(fmt.Sprintf("%c %s", statChar, titleScroll.scroll(name, maxTitle-statusWidth)))
1017 }
1018 }
1019 b.SetTitle(title)
1021 triggerText := ""
1022 if j.Kind == Bridge {
1023 triggerText = "»"
1024 }
1025 if j.StartedAt != nil {
1026 end := time.Now()
1027 if j.FinishedAt != nil {
1028 end = *j.FinishedAt
1029 }
1030 b.SetText(triggerText + "\n" + utils.FmtDuration(end.Sub(*j.StartedAt)))
1031 b.SetTextAlign(tview.AlignRight)
1032 } else {
1033 b.SetText(triggerText)
1034 }
1035 b.SetTextAlign(tview.AlignRight)
1036 rowIdx++
1038 }
1039 for k := range boxes {
1040 if !boxKeys[k] {
1041 root.RemovePage(k)
1042 }
1043 }
1044 root.SendToFront("jobs-" + curJob.Name)
1045}
1047func box(root *tview.Pages, key string, x, y, w, h int) *tview.TextView {
1048 b, ok := boxes[key]
1049 if !ok {
1050 b = tview.NewTextView()
1051 b.
1052 SetBackgroundColor(tcell.ColorDefault).
1053 SetBorder(true)
1054 boxes[key] = b
1055 }
1056 b.SetRect(x, y, w, h)
1058 root.AddPage(key, b, false, true)
1059 return b
1060}
1062func recoverPanic(app *tview.Application) {
1063 if r := recover(); r != nil {
1064 app.Stop()
1065 log.Fatalf("%s\n%s\n", r, string(debug.Stack()))
1066 }
1067}
1069func updateJobs(
1070 app *tview.Application,
1071 jobsCh chan<- []*ViewJob,
1072 forceUpdateCh <-chan bool,
1073 apiClient *gitlab.Client,
1074) {
1075 defer recoverPanic(app)
1076 for {
1077 if modalVisible {
1078 time.Sleep(time.Second * 1)
1079 continue
1080 }
1081 var jobs []*gitlab.Job
1082 var bridges []*gitlab.Bridge
1083 pipeline, err := curPipeline()
1084 if err != nil {
1085 app.Stop()
1086 //nolint:gocritic // app.Stop() restores the terminal; the deferred recover only handles panics
1087 log.Fatalf("%v", err)
1088 }
1089 jobs, bridges, err = api.PipelineJobsWithID(
1090 apiClient,
1091 pipeline.ProjectID,
1092 pipeline.ID,
1093 )
1094 if err != nil {
1095 app.Stop()
1096 log.Fatalf("failed to find CI jobs: %v", err)
1097 }
1098 if len(jobs) == 0 && len(bridges) == 0 {
1099 app.Stop()
1100 log.Fatal("No jobs found in the pipeline. Your '.gitlab-ci.yml' file might be invalid, or the pipeline triggered no jobs.")
1101 }
1102 viewJobs := make([]*ViewJob, 0, len(jobs)+len(bridges))
1103 for _, j := range jobs {
1104 viewJobs = append(viewJobs, ViewJobFromJob(j))
1105 }
1106 for _, b := range bridges {
1107 viewJobs = append(viewJobs, ViewJobFromBridge(b))
1108 }
1109 jobsCh <- latestJobs(viewJobs)
1110 select {
1111 case <-forceUpdateCh:
1112 case <-time.After(time.Second * 5):
1113 }
1115 }
1116}
1118func linkJobsView(app *tview.Application) func(screen tcell.Screen) {
1119 return func(screen tcell.Screen) {
1120 defer recoverPanic(app)
1121 err := linkJobs(screen, jobs, boxes)
1122 if err != nil {
1123 app.Stop()
1124 log.Fatal(err)
1125 }
1126 }
1127}
1129func linkJobs(screen tcell.Screen, jobs []*ViewJob, boxes map[string]*tview.TextView) error {
1130 if logsVisible || modalVisible {
1131 return nil
1132 }
1133 for i, j := range jobs {
1134 if _, ok := boxes["jobs-"+j.Name]; !ok {
1135 return fmt.Errorf("jobs-%s not found at index: %d", jobs[i].Name, i)
1136 }
1137 }
1138 var padding int
1139 // find the amount of space between two jobs is adjacent stages
1140 for i, k := 0, 1; k < len(jobs); i, k = i+1, k+1 {
1141 if jobs[i].Stage == jobs[k].Stage {
1142 continue
1143 }
1144 x1, _, w, _ := boxes["jobs-"+jobs[i].Name].GetRect()
1145 x2, _, _, _ := boxes["jobs-"+jobs[k].Name].GetRect()
1146 stageWidth := x2 - x1 - w
1147 switch {
1148 case stageWidth <= 3:
1149 padding = 1
1150 case stageWidth <= 6:
1151 padding = 2
1152 case stageWidth > 6:
1153 padding = 3
1154 }
1155 }
1156 for i, k := 0, 1; k < len(jobs); i, k = i+1, k+1 {
1157 v1 := boxes["jobs-"+jobs[i].Name]
1158 v2 := boxes["jobs-"+jobs[k].Name]
1159 link(screen, v1.Box, v2.Box, padding,
1160 jobs[i].Stage == jobs[0].Stage, // is first stage?
1161 jobs[i].Stage == jobs[len(jobs)-1].Stage) // is last stage?
1162 }
1163 return nil
1164}
1166func link(
1167 screen tcell.Screen,
1168 v1 *tview.Box,
1169 v2 *tview.Box,
1170 padding int,
1171 firstStage, lastStage bool,
1172) {
1173 x1, y1, w, h := v1.GetRect()
1174 x2, y2, _, _ := v2.GetRect()
1176 dx, dy := x2-x1, y2-y1
1178 p := padding
1180 // drawing stages
1181 if dx != 0 {
1182 hline(screen, x1+w, y2+h/2, dx-w)
1183 if dy != 0 {
1184 // dy != 0 means the last stage had multiple jobs
1185 screen.SetContent(x1+w+p-1, y2+h/2, '╦', nil, tcell.StyleDefault)
1186 }
1187 return
1188 }
1190 // Drawing a job in the same stage
1191 // left of view
1192 if !firstStage {
1193 s, _, _ := screen.Get(x2-p, y1+h/2)
1194 if r, _ := utf8.DecodeRuneInString(s); r == '╚' {
1195 screen.SetContent(x2-p, y1+h/2, '╠', nil, tcell.StyleDefault)
1196 } else {
1197 screen.SetContent(x2-p, y1+h/2, '╦', nil, tcell.StyleDefault)
1198 }
1200 for i := 1; i < p; i++ {
1201 screen.SetContent(x2-i, y2+h/2, '═', nil, tcell.StyleDefault)
1202 }
1203 screen.SetContent(x2-p, y2+h/2, '╚', nil, tcell.StyleDefault)
1205 vline(screen, x2-p, y1+h-1, dy-1)
1206 }
1207 // right of view
1208 if !lastStage {
1209 s, _, _ := screen.Get(x2+w+p-1, y1+h/2)
1210 if r, _ := utf8.DecodeRuneInString(s); r == '┛' {
1211 screen.SetContent(x2+w+p-1, y1+h/2, '╣', nil, tcell.StyleDefault)
1212 }
1213 for i := range p - 1 {
1214 screen.SetContent(x2+w+i, y2+h/2, '═', nil, tcell.StyleDefault)
1215 }
1216 screen.SetContent(x2+w+p-1, y2+h/2, '╝', nil, tcell.StyleDefault)
1218 vline(screen, x2+w+p-1, y1+h-1, dy-1)
1219 }
1220}
1222func hline(screen tcell.Screen, x, y, l int) {
1223 for i := range l {
1224 screen.SetContent(x+i, y, '═', nil, tcell.StyleDefault)
1225 }
1226}
1228func vline(screen tcell.Screen, x, y, l int) {
1229 for i := range l {
1230 screen.SetContent(x, y+i, '║', nil, tcell.StyleDefault)
1231 }
1232}
1234// latestJobs keeps the first display position of each job and shows its latest attempt.
1235func latestJobs(jobs []*ViewJob) []*ViewJob {
1236 type jobKey struct {
1237 stage string
1238 name string
1239 }
1240 positions := make(map[jobKey]int, len(jobs))
1241 out := make([]*ViewJob, 0, len(jobs))
1242 for _, job := range jobs {
1243 key := jobKey{stage: job.Stage, name: job.Name}
1244 if position, exists := positions[key]; exists {
1245 out[position] = job
1246 continue
1247 }
1248 positions[key] = len(out)
1249 out = append(out, job)
1250 }
1251 return out
1252}
Diagnostics8 git calls · 242 ms
CallStatusSizeTime0242 ms
discover200185 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch 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=3 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 · 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=32926 git.response.cache=HIT git.response.duration_ms=2 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=44Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit2 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=2 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:02001.8 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=1857 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=tree:0 git.fetch.wants=dce174ff8c632a19d17eea99c8a9b7c37fb2b592 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=1857 git.pkt.payload.max=1830 git.sideband.band1.bytes=1830 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=1830 git.pack.trailer=fb03183b7909876778f740d196d7516811003517Open pack map
fetchtree:0200635 B · 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=635 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=517b073a0d5c32bc4e93f86de74b31d60ff8cf03 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=635 git.pkt.payload.max=608 git.sideband.band1.bytes=608 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=608 git.pack.trailer=178abb9456d874b7fd38fa21ad5cf9ca3ebcccaaOpen pack map
fetchtree:0200136 B · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=226 git.response.bytes=136 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=tree:0 git.fetch.wants=2ec338b608c87ccf92e7e6018fbb95b9d1deb7e0 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=136 git.pkt.payload.max=109 git.sideband.band1.bytes=109 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=109 git.pack.trailer=3151a1b94d81e5dbbdca76ceeede626242ec5c4cOpen pack map
fetch20011 KiB226 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=11186 git.response.cache=MISS git.response.duration_ms=226 git.fetch.wants=b5546aff9967c05c2318398af3ca197c79275bff 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=11186 git.pkt.payload.max=11159 git.sideband.band1.bytes=11159 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
- a5e2ca621c494b67
- Request
- 5bc2f606…
- 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