GitLabgitlab-org

cli

main
ply8 git calls295 ms102 KiB6 cachedprotocol v2
700 lines18 KiBRaw
1//go:build !integration
3package view
5import (
6 "bytes"
7 "context"
8 "encoding/json"
9 "errors"
10 "fmt"
11 "net/http"
12 "regexp"
13 "strings"
14 "testing"
15 "time"
17 "github.com/MakeNowJust/heredoc/v2"
18 "github.com/acarl005/stripansi"
19 "github.com/spf13/cobra"
20 "github.com/stretchr/testify/assert"
21 "github.com/stretchr/testify/require"
22 "go.uber.org/mock/gomock"
24 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
25 gitlabtesting "gitlab.com/gitlab-org/api/client-go/v3/testing"
27 "gitlab.com/gitlab-org/cli/internal/api"
28 "gitlab.com/gitlab-org/cli/internal/cmdutils"
29 "gitlab.com/gitlab-org/cli/internal/commands/issuable"
30 "gitlab.com/gitlab-org/cli/internal/config"
31 "gitlab.com/gitlab-org/cli/internal/iostreams"
32 "gitlab.com/gitlab-org/cli/internal/testing/cmdtest"
35var (
36 f cmdutils.Factory
37 stdout *bytes.Buffer
38 stderr *bytes.Buffer
39 io *iostreams.IOStreams
42var testConfig = config.NewFromString(heredoc.Doc(`
43 hosts:
44 gitlab.com:
45 username: monalisa
46 token: OTOKEN
47`))
49type issuableData struct {
50 title string
51 description string
52 issueType issuable.IssueType
53 labels gitlab.Labels
56var testIssuables = map[int]issuableData{
57 13: {
58 title: "Incident title",
59 description: "Incident body",
60 issueType: issuable.TypeIncident,
61 labels: gitlab.Labels{"test", "incident"},
62 },
63 14: {
64 title: "Issue title",
65 description: "Issue body",
66 issueType: issuable.TypeIssue,
67 labels: gitlab.Labels{"test", "bug"},
68 },
69 225: {
70 title: "Incident title",
71 description: "Incident body",
72 issueType: issuable.TypeIncident,
73 labels: gitlab.Labels{"test", "incident"},
74 },
77func TestMain(m *testing.M) {
78 io, _, stdout, stderr = cmdtest.TestIOStreams(cmdtest.WithTestIOStreamsAsTTY(true))
79 f = cmdtest.NewTestFactory(io, cmdtest.WithConfig(config.NewFromString(heredoc.Doc(`
80 hosts:
81 gitlab.com:
82 username: monalisa
83 token: OTOKEN
84 `))))
86 timer, _ := time.Parse(time.RFC3339, "2014-11-12T11:45:26.371Z")
87 api.GetIssue = func(client *gitlab.Client, projectID any, issueID int64) (*gitlab.Issue, error) {
88 if projectID == "" || projectID == "WRONG_REPO" || projectID == "expected_err" {
89 return nil, fmt.Errorf("error expected")
90 }
92 // Use projectID directly instead of f.BaseRepo() to support per-test factories
93 repoPath, ok := projectID.(string)
94 if !ok {
95 return nil, fmt.Errorf("unexpected projectID type: %T", projectID)
96 }
98 testIssuable := testIssuables[int(issueID)]
99 issueType := string(testIssuable.issueType)
101 return &gitlab.Issue{
102 ID: issueID,
103 IID: issueID,
104 Title: testIssuable.title,
105 Labels: testIssuable.labels,
106 State: "opened",
107 Description: testIssuable.description,
108 References: &gitlab.IssueReferences{
109 Full: fmt.Sprintf("%s#%d", repoPath, issueID),
110 },
111 Milestone: &gitlab.Milestone{
112 Title: "MilestoneTitle",
113 },
114 Assignees: []*gitlab.IssueAssignee{
115 {
116 Username: "mona",
117 },
118 {
119 Username: "lisa",
120 },
121 },
122 Author: &gitlab.IssueAuthor{
123 ID: issueID,
124 Name: "John Dev Wick",
125 Username: "jdwick",
126 },
127 WebURL: fmt.Sprintf("https://gitlab.com/%s/-/issues/%d", repoPath, issueID),
128 CreatedAt: &timer,
129 UserNotesCount: 2,
130 IssueType: &issueType,
131 }, nil
132 }
133 cmdtest.InitTest(m, "mr_view_test")
136func TestNewCmdView(t *testing.T) {
137 tests := []struct {
138 name string
139 issueID int
140 viewIssueType issuable.IssueType
141 isTTY bool
142 }{
143 {"incident_view", 13, issuable.TypeIncident, true},
144 {"issue_view", 14, issuable.TypeIssue, true},
145 {"incident_view_no_tty", 13, issuable.TypeIncident, false},
146 {"issue_view_no_tty", 14, issuable.TypeIssue, false},
147 {"incident_view_with_issue_id", 14, issuable.TypeIncident, true},
148 {"issue_view_view_with_incident_id", 13, issuable.TypeIssue, true},
149 {"incident_view_with_issue_id_no_tty", 14, issuable.TypeIncident, false},
150 {"issue_view_view_with_incident_id_no_tty", 13, issuable.TypeIssue, false},
151 }
153 for _, tt := range tests {
154 t.Run(tt.name, func(t *testing.T) {
155 testIssuable := testIssuables[tt.issueID]
156 oldListIssueNotes := listIssueNotes
157 timer, _ := time.Parse(time.RFC3339, "2014-11-12T11:45:26.371Z")
158 listIssueNotes = func(_ context.Context, client *gitlab.Client, projectID any, issueID int64, opts *gitlab.ListIssueNotesOptions) ([]*gitlab.Note, error) {
159 if projectID == "PROJECT_MR_WITH_EMPTY_NOTE" {
160 return []*gitlab.Note{}, nil
161 }
162 return []*gitlab.Note{
163 {
164 ID: 1,
165 Body: "Note Body",
166 Title: "Note Title",
167 Author: gitlab.NoteAuthor{
168 ID: 1,
169 Username: "johnwick",
170 Name: "John Wick",
171 },
172 System: false,
173 CreatedAt: &timer,
174 NoteableID: 0,
175 },
176 {
177 ID: 1,
178 Body: fmt.Sprintf("Marked %s as stale", testIssuable.issueType),
179 Title: "",
180 Author: gitlab.NoteAuthor{
181 ID: 1,
182 Username: "johnwick",
183 Name: "John Wick",
184 },
185 System: true,
186 CreatedAt: &timer,
187 NoteableID: 0,
188 },
189 }, nil
190 }
192 exec := cmdtest.SetupCmdForTest(t, func(f cmdutils.Factory) *cobra.Command {
193 cmd := NewCmdView(f, tt.viewIssueType)
194 cmdutils.EnableRepoOverride(cmd, f)
195 return cmd
196 }, tt.isTTY,
197 cmdtest.WithConfig(testConfig),
198 )
200 result, err := exec(fmt.Sprintf("%d -c -s -R cli-automated-testing/test", tt.issueID))
201 require.NoError(t, err)
203 out := stripansi.Strip(result.String())
204 outErr := stripansi.Strip(result.Stderr())
206 viewIncidentWithIssueID := tt.viewIssueType == issuable.TypeIncident && testIssuable.issueType != issuable.TypeIncident
207 wantErrorMsg := "Incident not found, but an issue with the provided ID exists. Run `glab issue view <id>` to view.\n"
209 if tt.isTTY {
210 if viewIncidentWithIssueID {
211 require.Equal(t, wantErrorMsg, outErr)
212 } else {
213 require.Empty(t, outErr)
214 require.Contains(t, out, fmt.Sprintf("%s #%d", testIssuable.title, tt.issueID))
215 require.Contains(t, out, testIssuable.description)
216 assert.Contains(t, out, fmt.Sprintf("https://gitlab.com/cli-automated-testing/test/-/issues/%d", tt.issueID))
217 assert.Contains(t, out, fmt.Sprintf("johnwick Marked %s as stale", testIssuable.issueType))
218 }
219 } else {
220 if viewIncidentWithIssueID {
221 assert.Equal(t, wantErrorMsg, outErr)
222 } else {
223 expectedOutputs := []string{
224 fmt.Sprintf(`title:\t%s`, testIssuable.title),
225 `assignees:\tmona, lisa`,
226 `author:\tjdwick`,
227 `state:\topen`,
228 `comments:\t2`,
229 fmt.Sprintf(`labels:\t%s`, strings.Join([]string(testIssuable.labels), ", ")),
230 `milestone:\tMilestoneTitle\n`,
231 `--`,
232 testIssuable.description,
233 }
235 assert.Empty(t, outErr)
236 t.Helper()
237 var r *regexp.Regexp
238 for _, l := range expectedOutputs {
239 r = regexp.MustCompile(l)
240 if !r.MatchString(out) {
241 t.Errorf("output did not match regexp /%s/\n> output\n%s\n", r, out)
242 return
243 }
244 }
245 }
246 }
248 listIssueNotes = oldListIssueNotes
249 })
250 }
253func Test_listIssueNotes(t *testing.T) {
254 t.Parallel()
256 lastPageResponse := &gitlab.Response{
257 Response: &http.Response{StatusCode: http.StatusOK},
258 }
259 nextPageResponse := &gitlab.Response{
260 Response: &http.Response{StatusCode: http.StatusOK},
261 NextPage: 2,
262 }
264 t.Run("collects notes from all pages", func(t *testing.T) {
265 t.Parallel()
267 testClient := gitlabtesting.NewTestClient(t)
269 gomock.InOrder(
270 testClient.MockNotes.EXPECT().
271 ListIssueNotes("OWNER/REPO", int64(14), gomock.Any(), gomock.Any()).
272 Return([]*gitlab.Note{{ID: 1}, {ID: 2}}, nextPageResponse, nil),
273 testClient.MockNotes.EXPECT().
274 ListIssueNotes("OWNER/REPO", int64(14), gomock.Any(), gomock.Any()).
275 Return([]*gitlab.Note{{ID: 3}}, lastPageResponse, nil),
276 )
278 notes, err := listIssueNotes(t.Context(), testClient.Client, "OWNER/REPO", 14, &gitlab.ListIssueNotesOptions{})
279 require.NoError(t, err)
280 require.Len(t, notes, 3)
281 assert.Equal(t, int64(1), notes[0].ID)
282 assert.Equal(t, int64(3), notes[2].ID)
283 })
285 t.Run("returns an error from a later page", func(t *testing.T) {
286 t.Parallel()
288 testClient := gitlabtesting.NewTestClient(t)
289 wantErr := errors.New("api unavailable")
291 gomock.InOrder(
292 testClient.MockNotes.EXPECT().
293 ListIssueNotes("OWNER/REPO", int64(14), gomock.Any(), gomock.Any()).
294 Return([]*gitlab.Note{{ID: 1}}, nextPageResponse, nil),
295 testClient.MockNotes.EXPECT().
296 ListIssueNotes("OWNER/REPO", int64(14), gomock.Any(), gomock.Any()).
297 Return(nil, nil, wantErr),
298 )
300 notes, err := listIssueNotes(t.Context(), testClient.Client, "OWNER/REPO", 14, &gitlab.ListIssueNotesOptions{})
301 require.ErrorIs(t, err, wantErr)
302 assert.Nil(t, notes)
303 })
306func Test_rawIssuePreview(t *testing.T) {
307 // NOTE: we need to force disable colors, otherwise we'd need ANSI sequences in our test output assertions.
308 t.Setenv("NO_COLOR", "true")
310 issueType := string(issuable.TypeIssue)
311 incidentType := string(issuable.TypeIncident)
313 fakeNote1 := &gitlab.Note{}
314 fakeNote1.Author.Username = "bob"
315 fakeNote2 := &gitlab.Note{}
316 fakeNote2.Author.Username = "alice"
318 time1, _ := time.Parse(time.RFC3339, "2023-03-09T16:50:20.111Z")
319 time2, _ := time.Parse(time.RFC3339, "2023-03-09T16:52:30.222Z")
321 io, _, _, _ = cmdtest.TestIOStreams(cmdtest.WithTestIOStreamsAsTTY(true))
323 tests := []struct {
324 name string
325 opts *options
326 want []string
327 }{
328 {
329 "issue_default",
330 &options{
331 io: io,
332 issue: &gitlab.Issue{
333 Title: "Issue title",
334 State: "opened",
335 Author: &gitlab.IssueAuthor{Username: "alice"},
336 Labels: gitlab.Labels{"label1", "label2"},
337 Assignees: []*gitlab.IssueAssignee{{Username: "Alice"}, {Username: "Bob"}},
338 UserNotesCount: 2,
339 Description: "Issue description",
340 IssueType: &issueType,
341 Milestone: &gitlab.Milestone{Title: "Milestone 5"},
342 },
343 showComments: false,
344 },
345 []string{
346 "title:\tIssue title",
347 "state:\topen",
348 "author:\talice",
349 "labels:\tlabel1, label2",
350 "comments:\t2",
351 "assignees:\tAlice, Bob",
352 "milestone:\tMilestone 5",
353 "--",
354 "Issue description",
355 },
356 },
357 {
358 "issue_show_comments_no_comments",
359 &options{
360 io: io,
361 issue: &gitlab.Issue{
362 Title: "Issue title",
363 Author: &gitlab.IssueAuthor{Username: "alice"},
364 UserNotesCount: 2,
365 Description: "Issue description",
366 IssueType: &issueType,
367 Milestone: &gitlab.Milestone{Title: "Milestone 5"},
368 },
369 showComments: true,
370 },
371 []string{
372 "title:\tIssue title",
373 "state:\t",
374 "author:\talice",
375 "labels:\t",
376 "comments:\t2",
377 "assignees:\t",
378 "milestone:\tMilestone 5",
379 "--",
380 "Issue description",
381 "\n--\ncomments/notes:\n",
382 "There are no comments on this issue.",
383 },
384 },
385 {
386 "incident_show_comments_no_comments",
387 &options{
388 io: io,
389 issue: &gitlab.Issue{
390 Title: "Incident title",
391 Author: &gitlab.IssueAuthor{Username: "alice"},
392 UserNotesCount: 2,
393 Description: "Incident description",
394 IssueType: &incidentType,
395 Milestone: &gitlab.Milestone{Title: "Milestone 5"},
396 },
397 showComments: true,
398 },
399 []string{
400 "title:\tIncident title",
401 "state:\t",
402 "author:\talice",
403 "labels:\t",
404 "comments:\t2",
405 "assignees:\t",
406 "milestone:\tMilestone 5",
407 "--",
408 "Incident description",
409 "\n--\ncomments/notes:\n",
410 "There are no comments on this incident.",
411 },
412 },
413 {
414 "issue_show_comments_with_comments_and_system_notes",
415 &options{
416 io: io,
417 issue: &gitlab.Issue{
418 Title: "Issue title",
419 Author: &gitlab.IssueAuthor{Username: "alice"},
420 UserNotesCount: 2,
421 Description: "Issue description",
422 IssueType: &issueType,
423 Milestone: &gitlab.Milestone{Title: "Milestone 5"},
424 },
425 showComments: true,
426 showSystemLogs: true,
427 notes: []*gitlab.Note{
428 {
429 System: true,
430 Author: fakeNote1.Author,
431 Body: "assigned to @alice",
432 CreatedAt: &time1,
433 },
434 {
435 System: false,
436 Author: fakeNote1.Author,
437 Body: "Some comment",
438 CreatedAt: &time1,
439 },
440 {
441 System: false,
442 Author: fakeNote2.Author,
443 Body: "Another comment",
444 CreatedAt: &time2,
445 },
446 },
447 },
448 []string{
449 "title:\tIssue title",
450 "state:\t",
451 "author:\talice",
452 "labels:\t",
453 "comments:\t2",
454 "assignees:\t",
455 "milestone:\tMilestone 5",
456 "--",
457 "Issue description",
458 "\n--\ncomments/notes:\n",
459 fmt.Sprintf("bob assigned to @alice %s", time1),
460 "",
461 fmt.Sprintf("bob commented %s", time1),
462 "Some comment",
463 "",
464 fmt.Sprintf("alice commented %s", time2),
465 "Another comment",
466 "",
467 },
468 },
469 }
471 for _, tt := range tests {
472 t.Run(tt.name, func(t *testing.T) {
473 want := strings.Join(tt.want, "\n") + "\n"
474 got := rawIssuePreview(tt.opts)
476 require.Equal(t, want, got)
477 })
478 }
481func Test_labelsList(t *testing.T) {
482 tests := []struct {
483 name string
484 opts *options
485 want string
486 }{
487 {
488 "no labels",
489 &options{issue: &gitlab.Issue{Labels: gitlab.Labels{}}},
490 "",
491 },
492 {
493 "one label",
494 &options{issue: &gitlab.Issue{Labels: gitlab.Labels{"label1"}}},
495 "label1",
496 },
497 {
498 "two labels",
499 &options{issue: &gitlab.Issue{Labels: gitlab.Labels{"label1", "label2"}}},
500 "label1, label2",
501 },
502 }
504 for _, test := range tests {
505 t.Run(test.name, func(t *testing.T) {
506 got := labelsList(test.opts)
508 if test.want != got {
509 t.Errorf(`want "%s"; got "%s"`, test.want, got)
510 }
511 })
512 }
515func Test_assigneesList(t *testing.T) {
516 tests := []struct {
517 name string
518 opts *options
519 want string
520 }{
521 {
522 "no assignee",
523 &options{issue: &gitlab.Issue{Assignees: []*gitlab.IssueAssignee{}}},
524 "",
525 },
526 {
527 "one assignee",
528 &options{issue: &gitlab.Issue{Assignees: []*gitlab.IssueAssignee{{Username: "Alice"}}}},
529 "Alice",
530 },
531 {
532 "two assignees",
533 &options{issue: &gitlab.Issue{Assignees: []*gitlab.IssueAssignee{{Username: "Alice"}, {Username: "Bob"}}}},
534 "Alice, Bob",
535 },
536 }
538 for _, test := range tests {
539 t.Run(test.name, func(t *testing.T) {
540 got := assigneesList(test.opts)
542 if test.want != got {
543 t.Errorf(`want "%s"; got "%s"`, test.want, got)
544 }
545 })
546 }
549func Test_printTTYIssuePreview_closed(t *testing.T) {
550 createdAt, _ := time.Parse(time.RFC3339, "2014-11-12T11:45:26.371Z")
551 closedAt, _ := time.Parse(time.RFC3339, "2015-01-15T09:00:00.000Z")
552 issueType := string(issuable.TypeIssue)
554 tests := []struct {
555 name string
556 issue *gitlab.Issue
557 wantContains []string
558 wantOmits []string
559 }{
560 {
561 name: "closed_issue_with_nil_closed_by_does_not_panic",
562 issue: &gitlab.Issue{
563 Title: "Closed issue",
564 State: "closed",
565 Author: &gitlab.IssueAuthor{Username: "alice"},
566 CreatedAt: &createdAt,
567 IssueType: &issueType,
568 ClosedBy: nil,
569 ClosedAt: nil,
570 },
571 wantOmits: []string{"Closed by:"},
572 },
573 {
574 name: "closed_issue_with_closed_by_and_closed_at",
575 issue: &gitlab.Issue{
576 Title: "Closed issue",
577 State: "closed",
578 Author: &gitlab.IssueAuthor{Username: "alice"},
579 CreatedAt: &createdAt,
580 IssueType: &issueType,
581 ClosedBy: &gitlab.IssueCloser{Username: "bob"},
582 ClosedAt: &closedAt,
583 },
584 wantContains: []string{"Closed by: bob "},
585 },
586 {
587 name: "closed_issue_with_closed_by_but_no_closed_at",
588 issue: &gitlab.Issue{
589 Title: "Closed issue",
590 State: "closed",
591 Author: &gitlab.IssueAuthor{Username: "alice"},
592 CreatedAt: &createdAt,
593 IssueType: &issueType,
594 ClosedBy: &gitlab.IssueCloser{Username: "bob"},
595 ClosedAt: nil,
596 },
597 wantContains: []string{"Closed by: bob\n"},
598 },
599 }
601 for _, tt := range tests {
602 t.Run(tt.name, func(t *testing.T) {
603 ios, _, stdout, _ := cmdtest.TestIOStreams(cmdtest.WithTestIOStreamsAsTTY(true))
604 opts := &options{io: ios, issue: tt.issue}
606 require.NotPanics(t, func() { printTTYIssuePreview(opts) })
608 out := stripansi.Strip(stdout.String())
609 for _, want := range tt.wantContains {
610 assert.Contains(t, out, want)
611 }
612 for _, omit := range tt.wantOmits {
613 assert.NotContains(t, out, omit)
614 }
615 })
616 }
619func TestIssueViewJSON(t *testing.T) {
620 exec := cmdtest.SetupCmdForTest(t, func(f cmdutils.Factory) *cobra.Command {
621 return NewCmdView(f, issuable.TypeIssue)
622 }, false,
623 cmdtest.WithConfig(testConfig),
624 )
626 output, err := exec("1 -F json")
627 require.NoError(t, err)
629 assert.True(t, json.Valid([]byte(output.String())))
630 assert.Empty(t, output.Stderr())
633func Test_issuePreview_timeTracking(t *testing.T) {
634 createdAt, _ := time.Parse(time.RFC3339, "2014-11-12T11:45:26.371Z")
635 issueType := string(issuable.TypeIssue)
637 tests := []struct {
638 name string
639 timeStats *gitlab.TimeStats
640 wantTTY []string
641 wantRaw []string
642 wantOmits []string
643 }{
644 {
645 name: "no time stats",
646 timeStats: nil,
647 wantOmits: []string{"Time tracking:", "time_estimate:", "time_spent:"},
648 },
649 {
650 name: "nothing tracked",
651 timeStats: &gitlab.TimeStats{},
652 wantOmits: []string{"Time tracking:", "time_estimate:", "time_spent:"},
653 },
654 {
655 name: "time spent only",
656 timeStats: &gitlab.TimeStats{HumanTotalTimeSpent: "1h 30m", TotalTimeSpent: 5400},
657 wantTTY: []string{"Time tracking: 1h 30m spent\n"},
658 wantRaw: []string{"time_spent:\t1h 30m\n"},
659 wantOmits: []string{"estimated", "time_estimate:"},
660 },
661 {
662 name: "time spent and estimate",
663 timeStats: &gitlab.TimeStats{
664 HumanTotalTimeSpent: "1h 30m", TotalTimeSpent: 5400,
665 HumanTimeEstimate: "2d", TimeEstimate: 57600,
666 },
667 wantTTY: []string{"Time tracking: 1h 30m spent of 2d estimated\n"},
668 wantRaw: []string{"time_estimate:\t2d\n", "time_spent:\t1h 30m\n"},
669 },
670 }
672 for _, tt := range tests {
673 t.Run(tt.name, func(t *testing.T) {
674 ios, _, stdout, _ := cmdtest.TestIOStreams(cmdtest.WithTestIOStreamsAsTTY(true))
675 opts := &options{io: ios, issue: &gitlab.Issue{
676 Title: "Issue title",
677 State: "opened",
678 Author: &gitlab.IssueAuthor{Username: "alice"},
679 CreatedAt: &createdAt,
680 IssueType: &issueType,
681 TimeStats: tt.timeStats,
682 }}
684 printTTYIssuePreview(opts)
685 tty := stripansi.Strip(stdout.String())
686 raw := rawIssuePreview(opts)
688 for _, want := range tt.wantTTY {
689 assert.Contains(t, tty, want)
690 }
691 for _, want := range tt.wantRaw {
692 assert.Contains(t, raw, want)
693 }
694 for _, omit := range tt.wantOmits {
695 assert.NotContains(t, tty, omit)
696 assert.NotContains(t, raw, omit)
697 }
698 })
699 }
Diagnostics8 git calls · 295 ms
CallStatusSizeTime0295 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 · 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 · 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:02001.8 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=1857
git.response.cache=HIT
git.response.duration_ms=3
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=fb03183b7909876778f740d196d7516811003517
Open pack map
fetchtree:0200347 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=347
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=73f6a798386c4a4df64da0b5349881ded38885ca
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=347
git.pkt.payload.max=320
git.sideband.band1.bytes=320
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=320
git.pack.trailer=93ed36ed1884d41429801c50b3bb5d32ef1307a5
Open pack map
fetchtree:0200146 B · hit6 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=6
git.response.bytes=146
git.response.cache=HIT
git.response.duration_ms=6
git.fetch.filter=tree:0
git.fetch.wants=76f74c7ffb6e1a64159176b8d07902c6f1372aa4
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=146
git.pkt.payload.max=119
git.sideband.band1.bytes=119
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=119
git.pack.trailer=a5b18fdffd274e7e74004f293f0ecce889495839
Open pack map
fetch2004.3 KiB277 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=277
git.response.bytes=4440
git.response.cache=MISS
git.response.duration_ms=277
git.fetch.wants=ca8bf2fcace89a04a295d9377ad60aec1548d36e
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=4440
git.pkt.payload.max=4413
git.sideband.band1.bytes=4413
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
a5e2ebd80d874bc2
Request
cc01af1e…
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