GitLabgitlab-org

cli

main
ply8 git calls257 ms101 KiB5 cachedprotocol v2
570 lines17 KiBRaw
1//go:build !integration
3package update
5import (
6 "bytes"
7 "errors"
8 "fmt"
9 "testing"
11 "github.com/google/shlex"
12 "github.com/spf13/cobra"
13 "github.com/stretchr/testify/assert"
14 "github.com/stretchr/testify/require"
15 "go.uber.org/mock/gomock"
17 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
18 gitlabtesting "gitlab.com/gitlab-org/api/client-go/v3/testing"
20 "gitlab.com/gitlab-org/cli/internal/api"
21 "gitlab.com/gitlab-org/cli/internal/cmdutils"
22 "gitlab.com/gitlab-org/cli/internal/glrepo"
23 "gitlab.com/gitlab-org/cli/internal/testing/cmdtest"
26func Test_NewCmdUpdate(t *testing.T) {
27 tests := []struct {
28 name string
29 cli string
30 wants options
31 stdinTTY bool
32 wantsErr bool
33 }{
34 {
35 name: "invalid type",
36 cli: "cool_secret -g coolGroup -t 'mV'",
37 wantsErr: true,
38 },
39 {
40 name: "value argument and value flag specified",
41 cli: `cool_secret value -v"another value"`,
42 wantsErr: true,
43 },
44 {
45 name: "no name",
46 cli: "",
47 wantsErr: true,
48 },
49 {
50 name: "no value, stdin is terminal",
51 cli: "cool_secret",
52 stdinTTY: true,
53 wantsErr: true,
54 },
55 {
56 name: "protected var",
57 cli: `cool_secret -v"a secret" -p`,
58 wants: options{
59 key: "cool_secret",
60 protected: true,
61 value: "a secret",
62 group: "",
63 typ: "env_var",
64 scope: "*",
65 },
66 },
67 {
68 name: "protected var in group",
69 cli: `cool_secret --group coolGroup -v"cool"`,
70 wants: options{
71 key: "cool_secret",
72 protected: false,
73 value: "cool",
74 group: "coolGroup",
75 typ: "env_var",
76 scope: "*",
77 },
78 },
79 {
80 name: "raw variable with flag",
81 cli: `cool_secret -r -v"$variable_name"`,
82 wants: options{
83 key: "cool_secret",
84 value: "$variable_name",
85 raw: true,
86 group: "",
87 scope: "*",
88 typ: "env_var",
89 },
90 },
91 {
92 name: "raw variable with flag in group",
93 cli: `cool_secret -r --group coolGroup -v"$variable_name"`,
94 wants: options{
95 key: "cool_secret",
96 value: "$variable_name",
97 raw: true,
98 group: "coolGroup",
99 scope: "*",
100 typ: "env_var",
101 },
102 },
103 {
104 name: "raw is false by default",
105 cli: `cool_secret -v"$variable_name"`,
106 wants: options{
107 key: "cool_secret",
108 value: "$variable_name",
109 raw: false,
110 group: "",
111 scope: "*",
112 typ: "env_var",
113 },
114 },
115 {
116 name: "var with description",
117 cli: `cool_secret -d"description"`,
118 wants: options{
119 key: "cool_secret",
120 raw: false,
121 group: "",
122 scope: "*",
123 typ: "env_var",
124 description: "description",
125 },
126 },
127 {
128 name: "leading numbers in name",
129 cli: `123_TOKEN -v"cool"`,
130 wants: options{
131 key: "123_TOKEN",
132 protected: false,
133 value: "cool",
134 group: "",
135 scope: "*",
136 typ: "env_var",
137 },
138 },
139 {
140 name: "invalid characters in name",
141 cli: `BAD-SECRET -v"cool"`,
142 wantsErr: true,
143 },
144 }
146 for _, tt := range tests {
147 t.Run(tt.name, func(t *testing.T) {
148 io, _, _, _ := cmdtest.TestIOStreams()
149 f := cmdtest.NewTestFactory(io)
151 io.IsInTTY = tt.stdinTTY
153 argv, err := shlex.Split(tt.cli)
154 require.NoError(t, err)
156 var gotOpts *options
157 cmd := NewCmdUpdate(f, func(opts *options) error {
158 gotOpts = opts
159 return nil
160 })
161 cmd.SetArgs(argv)
162 cmd.SetIn(&bytes.Buffer{})
163 cmd.SetOut(&bytes.Buffer{})
164 cmd.SetErr(&bytes.Buffer{})
166 _, err = cmd.ExecuteC()
167 if tt.wantsErr {
168 require.Error(t, err)
169 return
170 }
171 require.NoError(t, err)
173 assert.Equal(t, tt.wants.key, gotOpts.key)
174 assert.Equal(t, tt.wants.value, gotOpts.value)
175 assert.Equal(t, tt.wants.group, gotOpts.group)
176 assert.Equal(t, tt.wants.protected, gotOpts.protected)
177 assert.Equal(t, tt.wants.raw, gotOpts.raw)
178 assert.Equal(t, tt.wants.masked, gotOpts.masked)
179 assert.Equal(t, tt.wants.typ, gotOpts.typ)
180 assert.Equal(t, tt.wants.description, gotOpts.description)
181 assert.Equal(t, tt.wants.scope, gotOpts.scope)
182 })
183 }
186func Test_updateRun_project(t *testing.T) {
187 // GIVEN
188 testClient := gitlabtesting.NewTestClient(t)
189 testClient.MockProjectVariables.EXPECT().
190 UpdateVariable("owner/repo", "TEST_VARIABLE", gomock.Any(), gomock.Any()).
191 Return(&gitlab.ProjectVariable{
192 Key: "TEST_VARIABLE",
193 Value: "foo",
194 VariableType: "env_var",
195 Protected: false,
196 Masked: false,
197 }, nil, nil)
199 io, _, stdout, _ := cmdtest.TestIOStreams()
201 opts := &options{
202 apiClient: func(repoHost string) (*api.Client, error) {
203 return cmdtest.NewTestApiClient(t, nil, "", "gitlab.com", api.WithGitLabClient(testClient.Client)), nil
204 },
205 baseRepo: func() (glrepo.Interface, error) {
206 return glrepo.New("owner", "repo", "gitlab.com"), nil
207 },
208 io: io,
209 key: "TEST_VARIABLE",
210 value: "foo",
211 scope: "*",
212 }
214 // WHEN
215 err := opts.run(t.Context())
217 // THEN
218 require.NoError(t, err)
219 assert.Equal(t, "✓ Updated variable TEST_VARIABLE for project owner/repo with scope *.\n", stdout.String())
222func Test_updateRun_group(t *testing.T) {
223 // GIVEN
224 testClient := gitlabtesting.NewTestClient(t)
225 testClient.MockGroupVariables.EXPECT().
226 GetVariable("mygroup", "TEST_VARIABLE", &gitlab.GetGroupVariableOptions{
227 Filter: &gitlab.VariableFilter{EnvironmentScope: "*"},
228 }, gomock.Any()).
229 Return(&gitlab.GroupVariable{Key: "TEST_VARIABLE", EnvironmentScope: "*"}, nil, nil)
230 testClient.MockGroupVariables.EXPECT().
231 UpdateVariable("mygroup", "TEST_VARIABLE", gomock.Any(), gomock.Any()).
232 Return(&gitlab.GroupVariable{
233 Key: "TEST_VARIABLE",
234 Value: "blargh",
235 VariableType: "env_var",
236 Protected: false,
237 Masked: false,
238 }, nil, nil)
240 io, _, stdout, _ := cmdtest.TestIOStreams()
242 opts := &options{
243 apiClient: func(repoHost string) (*api.Client, error) {
244 return cmdtest.NewTestApiClient(t, nil, "", "gitlab.com", api.WithGitLabClient(testClient.Client)), nil
245 },
246 baseRepo: func() (glrepo.Interface, error) {
247 return glrepo.New("owner", "repo", "gitlab.com"), nil
248 },
249 io: io,
250 key: "TEST_VARIABLE",
251 value: "blargh",
252 group: "mygroup",
253 scope: "*",
254 }
256 // WHEN
257 err := opts.run(t.Context())
259 // THEN
260 require.NoError(t, err)
261 assert.Equal(t, "✓ Updated variable TEST_VARIABLE for group mygroup with scope *.\n", stdout.String())
264func Test_updateGroupScope(t *testing.T) {
265 t.Parallel()
267 apiErr := errors.New("group variable update failed")
268 for _, tt := range []struct {
269 name string
270 cli string
271 scope string
272 stdin string
273 typ *gitlab.VariableTypeValue
274 protected *bool
275 masked *bool
276 raw *bool
277 description *string
278 apiErr error
279 }{
280 {name: "default scope", cli: "TEST_VARIABLE -g mygroup -v value", scope: "*"},
281 {name: "explicit wildcard", cli: "TEST_VARIABLE -g mygroup -s '*' -v value", scope: "*"},
282 {name: "production scope", cli: "TEST_VARIABLE --group mygroup --scope prod -v value", scope: "prod"},
283 {name: "wildcard environment", cli: "TEST_VARIABLE -g mygroup -s 'review/*' -v value", scope: "review/*"},
284 {name: "protected file from stdin", cli: "TEST_VARIABLE -p --scope prod -g mygroup -t file", scope: "prod", stdin: "value", typ: new(gitlab.FileVariableType), protected: new(true)},
285 {name: "explicit false attributes", cli: "TEST_VARIABLE -g mygroup -s prod -v value --protected=false --masked=false --raw=false", scope: "prod", protected: new(false), masked: new(false), raw: new(false)},
286 {name: "explicit true attributes", cli: "TEST_VARIABLE -g mygroup -s prod -v value -p -m -r", scope: "prod", protected: new(true), masked: new(true), raw: new(true)},
287 {name: "explicit empty description", cli: `TEST_VARIABLE -g mygroup -s prod -v value -d ""`, scope: "prod", description: new("")},
288 {name: "description only", cli: `TEST_VARIABLE -g mygroup -s prod -v value -d "new description"`, scope: "prod", description: new("new description")},
289 {name: "explicit default type", cli: "TEST_VARIABLE -g mygroup -s prod -v value -t env_var", scope: "prod", typ: new(gitlab.EnvVariableType)},
290 {name: "API error", cli: "TEST_VARIABLE -g mygroup -s prod -v value", scope: "prod", apiErr: apiErr},
291 } {
292 t.Run(tt.name, func(t *testing.T) {
293 t.Parallel()
294 tc := gitlabtesting.NewTestClient(t)
295 tc.MockGroupVariables.EXPECT().GetVariable("mygroup", "TEST_VARIABLE", &gitlab.GetGroupVariableOptions{
296 Filter: &gitlab.VariableFilter{EnvironmentScope: tt.scope},
297 }, gomock.Any()).Return(&gitlab.GroupVariable{Key: "TEST_VARIABLE", EnvironmentScope: tt.scope}, nil, nil)
298 tc.MockGroupVariables.EXPECT().UpdateVariable("mygroup", "TEST_VARIABLE", &gitlab.UpdateGroupVariableOptions{
299 Value: new("value"),
300 VariableType: tt.typ,
301 Masked: tt.masked,
302 Protected: tt.protected,
303 Raw: tt.raw,
304 EnvironmentScope: new(tt.scope),
305 Filter: &gitlab.VariableFilter{EnvironmentScope: tt.scope},
306 Description: tt.description,
307 }, gomock.Any()).Return(nil, nil, tt.apiErr)
308 exec := cmdtest.SetupCmdForTest(t, func(f cmdutils.Factory) *cobra.Command {
309 return NewCmdUpdate(f, nil)
310 }, false, cmdtest.WithApiClient(cmdtest.NewTestApiClient(t, nil, "", "gitlab.com", api.WithGitLabClient(tc.Client))), cmdtest.WithStdin(tt.stdin))
312 out, err := exec(tt.cli)
313 if tt.apiErr != nil {
314 require.ErrorIs(t, err, tt.apiErr)
315 assert.Empty(t, out.String())
316 return
317 }
318 require.NoError(t, err)
319 assert.Equal(t, fmt.Sprintf("✓ Updated variable TEST_VARIABLE for group mygroup with scope %s.\n", tt.scope), out.String())
320 assert.Empty(t, out.Stderr())
321 })
322 }
325func Test_updateGroupScopePreflight(t *testing.T) {
326 t.Parallel()
328 for _, tt := range []struct {
329 name string
330 scope string
331 variable *gitlab.GroupVariable
332 lookupErr error
333 wantErr string
334 }{
335 {
336 name: "mistyped scope returns 404",
337 scope: "prdo",
338 lookupErr: errors.New("404 group variable not found"),
339 wantErr: "404 group variable not found",
340 },
341 {
342 name: "API returns a different scope",
343 scope: "prdo",
344 variable: &gitlab.GroupVariable{
345 Key: "TEST_VARIABLE", EnvironmentScope: "*",
346 },
347 wantErr: `group variable "TEST_VARIABLE" does not exist in scope "prdo"`,
348 },
349 {
350 name: "nil lookup response",
351 scope: "prod",
352 wantErr: `group variable "TEST_VARIABLE" does not exist in scope "prod"`,
353 },
354 {
355 name: "read access denied",
356 scope: "prod",
357 lookupErr: errors.New("403 forbidden"),
358 wantErr: "403 forbidden",
359 },
360 } {
361 t.Run(tt.name, func(t *testing.T) {
362 t.Parallel()
364 tc := gitlabtesting.NewTestClient(t)
365 tc.MockGroupVariables.EXPECT().GetVariable("mygroup", "TEST_VARIABLE", &gitlab.GetGroupVariableOptions{
366 Filter: &gitlab.VariableFilter{EnvironmentScope: tt.scope},
367 }, gomock.Any()).Return(tt.variable, nil, tt.lookupErr)
368 // No UpdateVariable expectation: attempting a write must fail this test.
370 exec := cmdtest.SetupCmdForTest(t, func(f cmdutils.Factory) *cobra.Command {
371 return NewCmdUpdate(f, nil)
372 }, false, cmdtest.WithApiClient(cmdtest.NewTestApiClient(t, nil, "", "gitlab.com", api.WithGitLabClient(tc.Client))))
374 out, err := exec(fmt.Sprintf("TEST_VARIABLE -g mygroup -s %s -v changed", tt.scope))
375 require.ErrorContains(t, err, tt.wantErr)
376 assert.Empty(t, out.String())
377 assert.Empty(t, out.Stderr())
378 })
379 }
382func Test_NewCmdUpdate_changedFlags(t *testing.T) {
383 tests := []struct {
384 name string
385 cli string
386 want options
387 }{
388 {
389 name: "no optional flags",
390 cli: `cool_secret -v"a secret"`,
391 want: options{},
392 },
393 {
394 name: "protected only",
395 cli: `cool_secret -v"a secret" -p`,
396 want: options{protectedChanged: true},
397 },
398 {
399 name: "explicitly disabled boolean flag counts as changed",
400 cli: `cool_secret -v"a secret" --protected=false --masked=false --raw=false`,
401 want: options{protectedChanged: true, maskedChanged: true, rawChanged: true},
402 },
403 {
404 name: "type and description",
405 cli: `cool_secret -v"a secret" -t file -d ""`,
406 want: options{typeChanged: true, descriptionChanged: true},
407 },
408 }
410 for _, tt := range tests {
411 t.Run(tt.name, func(t *testing.T) {
412 io, _, _, _ := cmdtest.TestIOStreams()
413 f := cmdtest.NewTestFactory(io)
415 argv, err := shlex.Split(tt.cli)
416 require.NoError(t, err)
418 var gotOpts *options
419 cmd := NewCmdUpdate(f, func(opts *options) error {
420 gotOpts = opts
421 return nil
422 })
423 cmd.SetArgs(argv)
424 cmd.SetIn(&bytes.Buffer{})
425 cmd.SetOut(&bytes.Buffer{})
426 cmd.SetErr(&bytes.Buffer{})
428 _, err = cmd.ExecuteC()
429 require.NoError(t, err)
431 assert.Equal(t, tt.want.typeChanged, gotOpts.typeChanged)
432 assert.Equal(t, tt.want.protectedChanged, gotOpts.protectedChanged)
433 assert.Equal(t, tt.want.maskedChanged, gotOpts.maskedChanged)
434 assert.Equal(t, tt.want.rawChanged, gotOpts.rawChanged)
435 assert.Equal(t, tt.want.descriptionChanged, gotOpts.descriptionChanged)
436 })
437 }
440func Test_updateRun_project_onlySendsChangedAttributes(t *testing.T) {
441 tests := []struct {
442 name string
443 cli string
444 check func(t *testing.T, got *gitlab.UpdateProjectVariableOptions)
445 }{
446 {
447 name: "value only leaves every other attribute unset",
448 cli: `TEST_VARIABLE -v"foo"`,
449 check: func(t *testing.T, got *gitlab.UpdateProjectVariableOptions) {
450 t.Helper()
451 assert.Equal(t, "foo", *got.Value)
452 assert.Nil(t, got.VariableType)
453 assert.Nil(t, got.Protected)
454 assert.Nil(t, got.Masked)
455 assert.Nil(t, got.Raw)
456 assert.Nil(t, got.Description)
457 },
458 },
459 {
460 name: "only the passed attributes are sent",
461 cli: `TEST_VARIABLE -v"foo" -p -d"new description"`,
462 check: func(t *testing.T, got *gitlab.UpdateProjectVariableOptions) {
463 t.Helper()
464 require.NotNil(t, got.Protected)
465 assert.True(t, *got.Protected)
466 require.NotNil(t, got.Description)
467 assert.Equal(t, "new description", *got.Description)
468 assert.Nil(t, got.VariableType)
469 assert.Nil(t, got.Masked)
470 assert.Nil(t, got.Raw)
471 },
472 },
473 {
474 name: "attributes can be turned off explicitly",
475 cli: `TEST_VARIABLE -v"foo" --protected=false --masked=false --raw=false`,
476 check: func(t *testing.T, got *gitlab.UpdateProjectVariableOptions) {
477 t.Helper()
478 require.NotNil(t, got.Protected)
479 assert.False(t, *got.Protected)
480 require.NotNil(t, got.Masked)
481 assert.False(t, *got.Masked)
482 require.NotNil(t, got.Raw)
483 assert.False(t, *got.Raw)
484 },
485 },
486 {
487 name: "type and an empty description are sent when passed",
488 cli: `TEST_VARIABLE -v"foo" -t file -d ""`,
489 check: func(t *testing.T, got *gitlab.UpdateProjectVariableOptions) {
490 t.Helper()
491 require.NotNil(t, got.VariableType)
492 assert.Equal(t, gitlab.FileVariableType, *got.VariableType)
493 require.NotNil(t, got.Description)
494 assert.Empty(t, *got.Description)
495 },
496 },
497 }
499 for _, tt := range tests {
500 t.Run(tt.name, func(t *testing.T) {
501 var got *gitlab.UpdateProjectVariableOptions
502 testClient := gitlabtesting.NewTestClient(t)
503 testClient.MockProjectVariables.EXPECT().
504 UpdateVariable("owner/repo", "TEST_VARIABLE", gomock.Any(), gomock.Any()).
505 DoAndReturn(func(_ any, _ string, opt *gitlab.UpdateProjectVariableOptions, _ ...gitlab.RequestOptionFunc) (*gitlab.ProjectVariable, *gitlab.Response, error) {
506 got = opt
507 return &gitlab.ProjectVariable{Key: "TEST_VARIABLE"}, nil, nil
508 })
510 io, _, _, _ := cmdtest.TestIOStreams()
511 f := cmdtest.NewTestFactory(io,
512 cmdtest.WithApiClient(cmdtest.NewTestApiClient(t, nil, "", "gitlab.com", api.WithGitLabClient(testClient.Client))),
513 cmdtest.WithBaseRepo("owner", "repo", "gitlab.com"),
514 )
516 argv, err := shlex.Split(tt.cli)
517 require.NoError(t, err)
519 cmd := NewCmdUpdate(f, nil)
520 cmd.SetArgs(argv)
521 cmd.SetIn(&bytes.Buffer{})
522 cmd.SetOut(&bytes.Buffer{})
523 cmd.SetErr(&bytes.Buffer{})
525 _, err = cmd.ExecuteC()
526 require.NoError(t, err)
527 require.NotNil(t, got)
528 tt.check(t, got)
529 })
530 }
533func Test_updateRun_group_onlySendsChangedAttributes(t *testing.T) {
534 var got *gitlab.UpdateGroupVariableOptions
535 testClient := gitlabtesting.NewTestClient(t)
536 testClient.MockGroupVariables.EXPECT().
537 GetVariable("mygroup", "TEST_VARIABLE", &gitlab.GetGroupVariableOptions{
538 Filter: &gitlab.VariableFilter{EnvironmentScope: "*"},
539 }, gomock.Any()).
540 Return(&gitlab.GroupVariable{Key: "TEST_VARIABLE", EnvironmentScope: "*"}, nil, nil)
541 testClient.MockGroupVariables.EXPECT().
542 UpdateVariable("mygroup", "TEST_VARIABLE", gomock.Any(), gomock.Any()).
543 DoAndReturn(func(_ any, _ string, opt *gitlab.UpdateGroupVariableOptions, _ ...gitlab.RequestOptionFunc) (*gitlab.GroupVariable, *gitlab.Response, error) {
544 got = opt
545 return &gitlab.GroupVariable{Key: "TEST_VARIABLE"}, nil, nil
546 })
548 io, _, _, _ := cmdtest.TestIOStreams()
549 f := cmdtest.NewTestFactory(io,
550 cmdtest.WithApiClient(cmdtest.NewTestApiClient(t, nil, "", "gitlab.com", api.WithGitLabClient(testClient.Client))),
551 cmdtest.WithBaseRepo("owner", "repo", "gitlab.com"),
552 )
554 cmd := NewCmdUpdate(f, nil)
555 cmd.SetArgs([]string{"TEST_VARIABLE", "-v", "foo", "--group", "mygroup", "-m"})
556 cmd.SetIn(&bytes.Buffer{})
557 cmd.SetOut(&bytes.Buffer{})
558 cmd.SetErr(&bytes.Buffer{})
560 _, err := cmd.ExecuteC()
561 require.NoError(t, err)
562 require.NotNil(t, got)
564 require.NotNil(t, got.Masked)
565 assert.True(t, *got.Masked)
566 assert.Nil(t, got.Protected)
567 assert.Nil(t, got.Raw)
568 assert.Nil(t, got.VariableType)
569 assert.Nil(t, got.Description)
Diagnostics8 git calls · 257 ms
CallStatusSizeTime0257 ms
discover200185 B4 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 KiB3 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=UPDATING
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
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=2
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: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=44
Open pack map
fetchtree:02001.8 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=5
git.response.bytes=1857
git.response.cache=HIT
git.response.duration_ms=2
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:0200375 B · hit5 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=5
git.response.bytes=375
git.response.cache=HIT
git.response.duration_ms=5
git.fetch.filter=tree:0
git.fetch.wants=210e8ccdc9766a94adae919c6922ea88d77a8fb1
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=375
git.pkt.payload.max=348
git.sideband.band1.bytes=348
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=348
git.pack.trailer=8c3972a32424b06b4c572b8aa869b28eca201985
Open pack map
fetchtree:0200138 B · hit5 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=239
git.response.bytes=138
git.response.cache=HIT
git.response.duration_ms=5
git.fetch.filter=tree:0
git.fetch.wants=82e9c2bc0610e79e6ed8b3383ab3bdfa6ef24385
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=138
git.pkt.payload.max=111
git.sideband.band1.bytes=111
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=111
git.pack.trailer=afabf17e523d1096228b6cb0eaca23458d7c608f
Open pack map
fetch2003.4 KiB239 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3498
git.response.cache=MISS
git.response.duration_ms=239
git.fetch.wants=a16a889d0c7294cf0a7d8ea47571b276e8531d40
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=3498
git.pkt.payload.max=3471
git.sideband.band1.bytes=3471
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
a5e1abf709052c38
Request
ee2e47ba…
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