GitLabgitlab-org
cli
main
1//go:build !integration
3package create
5import (
6 "context"
7 "errors"
8 "testing"
9 "time"
11 "github.com/MakeNowJust/heredoc/v2"
12 "github.com/acarl005/stripansi"
13 "github.com/stretchr/testify/assert"
14 "github.com/stretchr/testify/require"
16 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
18 "gitlab.com/gitlab-org/cli/internal/cmdutils"
19 "gitlab.com/gitlab-org/cli/internal/config"
20 "gitlab.com/gitlab-org/cli/internal/git"
21 "gitlab.com/gitlab-org/cli/internal/testing/cmdtest"
22)
24func TestMain(m *testing.M) {
25 cmdtest.InitTest(m, "project_create_test")
26}
28func TestProjectPathFromArgs(t *testing.T) {
29 t.Parallel()
31 const defaultHostname = "git.example.com"
33 tests := []struct {
34 name string
35 input string
36 wantHost string
37 wantNamespace string
38 wantProject string
39 }{
40 {
41 name: "shallow owner",
42 input: "owner/project",
43 wantHost: defaultHostname,
44 wantNamespace: "owner",
45 wantProject: "project",
46 },
47 {
48 name: "nested owner",
49 input: "top-level/subgroup/project",
50 wantHost: defaultHostname,
51 wantNamespace: "top-level/subgroup",
52 wantProject: "project",
53 },
54 {
55 name: "tertiary namespace",
56 input: "top-level/subgroup/third-level/project",
57 wantHost: defaultHostname,
58 wantNamespace: "top-level/subgroup/third-level",
59 wantProject: "project",
60 },
61 {
62 name: "tertiary namespace with explicit default host",
63 input: "git.example.com/top-level/subgroup/third-level/project",
64 wantHost: defaultHostname,
65 wantNamespace: "top-level/subgroup/third-level",
66 wantProject: "project",
67 },
68 }
70 for _, tt := range tests {
71 t.Run(tt.name, func(t *testing.T) {
72 t.Parallel()
74 host, namespace, project := projectPathFromArgs([]string{tt.input}, defaultHostname, config.NewBlankConfig())
76 assert.Equal(t, tt.wantHost, host)
77 assert.Equal(t, tt.wantNamespace, namespace)
78 assert.Equal(t, tt.wantProject, project)
79 })
80 }
81}
83func Test_projectCreateCmd(t *testing.T) {
84 // Note: Cannot use t.Parallel() because tests modify package-level mock functions
85 // Save original functions to restore after tests
86 origCreateProject := createProject
87 origCurrentUser := currentUser
88 origAddRemote := addRemote
89 origGitInitializer := gitInitializer
90 origRepoInitializer := repoInitializer
91 origRepoCloner := repoCloner
93 defer func() {
94 createProject = origCreateProject
95 currentUser = origCurrentUser
96 addRemote = origAddRemote
97 gitInitializer = origGitInitializer
98 repoInitializer = origRepoInitializer
99 repoCloner = origRepoCloner
100 }()
102 testCases := []struct {
103 Name string
104 Args []string
105 ExpectedStdout []string
106 ExpectedStderr []string
107 SetupMocks func()
108 wantErr bool
109 }{
110 {
111 Name: "Create project with only repo name - success (creates subdirectory)",
112 Args: []string{"reponame"},
113 ExpectedStdout: []string{
114 "Created project on GitLab: reponame -",
115 },
116 SetupMocks: func() {
117 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
118 return &gitlab.Project{
119 ID: 1,
120 Name: *opts.Name,
121 Path: *opts.Path,
122 NameWithNamespace: *opts.Name,
123 WebURL: "https://gitlab.com/username/reponame",
124 SSHURLToRepo: "git@gitlab.com:username/" + *opts.Path + ".git",
125 }, nil
126 }
127 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
128 return &gitlab.User{
129 ID: 1,
130 Username: "username",
131 Name: "name",
132 }, nil
133 }
134 addRemote = func(name, url string) (*git.Remote, error) {
135 return &git.Remote{Name: name}, nil
136 }
137 gitInitializer = func() error {
138 return nil
139 }
140 repoInitializer = func(projectPath, remoteURL string) error {
141 return nil
142 }
143 repoCloner = func(cloneURL, target, remoteName string) error {
144 return nil
145 }
146 },
147 },
148 {
149 Name: "Create project with slash suffix",
150 Args: []string{"reponame/"},
151 ExpectedStdout: []string{
152 "Created project on GitLab: reponame -",
153 },
154 SetupMocks: func() {
155 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
156 return &gitlab.Project{
157 ID: 1,
158 Name: *opts.Name,
159 Path: *opts.Path,
160 NameWithNamespace: *opts.Name,
161 WebURL: "https://gitlab.com/username/reponame",
162 SSHURLToRepo: "git@gitlab.com:username/" + *opts.Path + ".git",
163 }, nil
164 }
165 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
166 return &gitlab.User{
167 ID: 1,
168 Username: "username",
169 Name: "name",
170 }, nil
171 }
172 addRemote = func(name, url string) (*git.Remote, error) {
173 return &git.Remote{Name: name}, nil
174 }
175 gitInitializer = func() error {
176 return nil
177 }
178 repoInitializer = func(projectPath, remoteURL string) error {
179 return nil
180 }
181 repoCloner = func(cloneURL, target, remoteName string) error {
182 return nil
183 }
184 },
185 },
186 {
187 Name: "Create project with --skipGitInit flag",
188 Args: []string{"test-repo", "--skipGitInit"},
189 ExpectedStdout: []string{
190 "Created project on GitLab: test-repo -",
191 },
192 SetupMocks: func() {
193 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
194 return &gitlab.Project{
195 ID: 1,
196 Name: *opts.Name,
197 Path: *opts.Path,
198 NameWithNamespace: *opts.Name,
199 WebURL: "https://gitlab.com/username/test-repo",
200 SSHURLToRepo: "git@gitlab.com:username/" + *opts.Path + ".git",
201 }, nil
202 }
203 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
204 return &gitlab.User{
205 ID: 1,
206 Username: "username",
207 Name: "name",
208 }, nil
209 }
210 addRemote = func(name, url string) (*git.Remote, error) {
211 return &git.Remote{Name: name}, nil
212 }
213 gitInitializer = func() error {
214 return nil
215 }
216 repoInitializer = func(projectPath, remoteURL string) error {
217 return nil
218 }
219 repoCloner = func(cloneURL, target, remoteName string) error {
220 return nil
221 }
222 },
223 },
224 {
225 Name: "GitLab API fails - fatal error",
226 Args: []string{"failing-repo"},
227 SetupMocks: func() {
228 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
229 return nil, errors.New("API error")
230 }
231 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
232 return &gitlab.User{
233 ID: 1,
234 Username: "username",
235 Name: "name",
236 }, nil
237 }
238 addRemote = func(name, url string) (*git.Remote, error) {
239 return &git.Remote{Name: name}, nil
240 }
241 gitInitializer = func() error {
242 return nil
243 }
244 repoInitializer = func(projectPath, remoteURL string) error {
245 return nil
246 }
247 repoCloner = func(cloneURL, target, remoteName string) error {
248 return nil
249 }
250 },
251 wantErr: true, // API failures should error
252 },
253 {
254 Name: "GitLab returns invalid project web URL",
255 Args: []string{"invalid-url-repo"},
256 SetupMocks: func() {
257 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
258 return &gitlab.Project{
259 NameWithNamespace: "username/invalid-url-repo",
260 WebURL: "http://[::1",
261 }, nil
262 }
263 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
264 return &gitlab.User{ID: 1, Username: "username"}, nil
265 }
266 },
267 wantErr: true,
268 },
269 {
270 Name: "Create project with name - NO_PROMPT does not create subdirectory by default",
271 Args: []string{"new-project"},
272 ExpectedStdout: []string{
273 "Created project on GitLab: username/new-project -",
274 },
275 SetupMocks: func() {
276 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
277 return &gitlab.Project{
278 ID: 1,
279 Name: *opts.Name,
280 Path: *opts.Path,
281 NameWithNamespace: "username/" + *opts.Name,
282 WebURL: "https://gitlab.com/username/" + *opts.Name,
283 SSHURLToRepo: "git@gitlab.com:username/" + *opts.Path + ".git",
284 }, nil
285 }
286 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
287 return &gitlab.User{
288 ID: 1,
289 Username: "username",
290 Name: "name",
291 }, nil
292 }
293 addRemote = func(name, url string) (*git.Remote, error) {
294 return &git.Remote{Name: name}, nil
295 }
296 gitInitializer = func() error {
297 return nil
298 }
299 repoInitializer = func(projectPath, remoteURL string) error {
300 return nil
301 }
302 repoCloner = func(cloneURL, target, remoteName string) error {
303 return nil
304 }
305 },
306 wantErr: false,
307 },
308 }
310 for _, tc := range testCases {
311 t.Run(tc.Name, func(t *testing.T) {
312 // Note: Cannot use t.Parallel() here because tests share and modify package-level mocks
313 // Setup mocks for this test
314 tc.SetupMocks()
316 io, _, stdout, stderr := cmdtest.TestIOStreams()
317 f := cmdtest.NewTestFactory(io, cmdtest.WithConfig(config.NewFromString(heredoc.Doc(`
318 hosts:
319 gitlab.com:
320 username: monalisa
321 token: OTOKEN
322 no_prompt: true
323 `))))
325 cmd := NewCmdCreate(f)
326 cmdutils.EnableRepoOverride(cmd, f)
327 cmd.SetArgs(tc.Args)
329 _, err := cmd.ExecuteC()
331 if tc.wantErr {
332 require.Error(t, err)
333 } else {
334 require.NoError(t, err)
335 }
337 out := stripansi.Strip(stdout.String())
338 errOut := stripansi.Strip(stderr.String())
340 for _, msg := range tc.ExpectedStdout {
341 assert.Contains(t, out, msg, "Expected stdout to contain: %s", msg)
342 }
344 for _, msg := range tc.ExpectedStderr {
345 assert.Contains(t, errOut, msg, "Expected stderr to contain: %s", msg)
346 }
347 })
348 }
349}
351// Test_projectCreateCmd_InCurrentDirectory tests the scenario where we run glab repo create
352// without arguments, which creates the project in the current directory and runs git operations
353func Test_projectCreateCmd_InCurrentDirectory(t *testing.T) {
354 // Note: Cannot use t.Parallel() because tests modify package-level mock functions
355 // Save original functions to restore after tests
356 origCreateProject := createProject
357 origCurrentUser := currentUser
358 origAddRemote := addRemote
359 origGitInitializer := gitInitializer
360 origRepoCloner := repoCloner
362 defer func() {
363 createProject = origCreateProject
364 currentUser = origCurrentUser
365 addRemote = origAddRemote
366 gitInitializer = origGitInitializer
367 repoCloner = origRepoCloner
368 }()
370 testCases := []struct {
371 Name string
372 Args []string
373 ExpectedStdout []string
374 ExpectedStderr []string
375 SetupMocks func()
376 wantErr bool
377 }{
378 {
379 Name: "Create project in current dir - remote already exists (main bug fix)",
380 ExpectedStdout: []string{
381 "Created project on GitLab:",
382 },
383 ExpectedStderr: []string{
384 "Warning: Could not add remote: remote origin already exists",
385 },
386 SetupMocks: func() {
387 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
388 return &gitlab.Project{
389 ID: 1,
390 Name: "test-project",
391 NameWithNamespace: "username/test-project",
392 WebURL: "https://gitlab.com/username/test-project",
393 SSHURLToRepo: "git@gitlab.com:username/test-project.git",
394 }, nil
395 }
396 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
397 return &gitlab.User{
398 ID: 1,
399 Username: "username",
400 Name: "name",
401 }, nil
402 }
403 addRemote = func(name, url string) (*git.Remote, error) {
404 return nil, errors.New("remote origin already exists. git: exit status 3")
405 }
406 gitInitializer = func() error {
407 return nil
408 }
409 repoCloner = func(cloneURL, target, remoteName string) error {
410 return nil
411 }
412 },
413 wantErr: false, // Should not error, just warn
414 },
415 {
416 Name: "Create project in current dir (already git init'd) - add remote succeeds",
417 ExpectedStdout: []string{
418 "Created project on GitLab:",
419 "Added remote",
420 },
421 SetupMocks: func() {
422 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
423 return &gitlab.Project{
424 ID: 1,
425 Name: "test-project",
426 NameWithNamespace: "username/test-project",
427 WebURL: "https://gitlab.com/username/test-project",
428 SSHURLToRepo: "git@gitlab.com:username/test-project.git",
429 }, nil
430 }
431 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
432 return &gitlab.User{
433 ID: 1,
434 Username: "username",
435 Name: "name",
436 }, nil
437 }
438 addRemote = func(name, url string) (*git.Remote, error) {
439 return &git.Remote{Name: name}, nil
440 }
441 gitInitializer = func() error {
442 // Should not be called since we're already in a git repo
443 t.Error("gitInitializer should not be called when already in a git repository")
444 return nil
445 }
446 repoCloner = func(cloneURL, target, remoteName string) error {
447 t.Error("repoCloner should not be called when already in a git repository")
448 return nil
449 }
450 },
451 wantErr: false,
452 },
453 {
454 Name: "Create project with --readme (already git init'd) - adds remote only",
455 Args: []string{"--readme"},
456 ExpectedStdout: []string{
457 "Created project on GitLab:",
458 "Added remote",
459 },
460 SetupMocks: func() {
461 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
462 return &gitlab.Project{
463 ID: 1,
464 Name: "test-project",
465 NameWithNamespace: "username/test-project",
466 WebURL: "https://gitlab.com/username/test-project",
467 SSHURLToRepo: "git@gitlab.com:username/test-project.git",
468 }, nil
469 }
470 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
471 return &gitlab.User{ID: 1, Username: "username", Name: "name"}, nil
472 }
473 addRemote = func(name, url string) (*git.Remote, error) {
474 return &git.Remote{Name: name}, nil
475 }
476 gitInitializer = func() error {
477 t.Error("gitInitializer should not be called when already in a git repository")
478 return nil
479 }
480 repoCloner = func(cloneURL, target, remoteName string) error {
481 t.Error("repoCloner should not be called when already in a git repository")
482 return nil
483 }
484 },
485 wantErr: false,
486 },
487 }
489 for _, tc := range testCases {
490 t.Run(tc.Name, func(t *testing.T) {
491 // Note: Cannot use t.Parallel() here because tests share and modify package-level mocks
492 // Setup mocks for this test
493 tc.SetupMocks()
495 io, _, stdout, stderr := cmdtest.TestIOStreams()
496 f := cmdtest.NewTestFactory(io, cmdtest.WithConfig(config.NewFromString(heredoc.Doc(`
497 hosts:
498 gitlab.com:
499 username: monalisa
500 token: OTOKEN
501 no_prompt: true
502 `))))
504 cmd := NewCmdCreate(f)
505 cmdutils.EnableRepoOverride(cmd, f)
506 args := tc.Args
507 if args == nil {
508 args = []string{}
509 }
510 cmd.SetArgs(args)
512 _, err := cmd.ExecuteC()
514 if tc.wantErr {
515 require.Error(t, err)
516 } else {
517 require.NoError(t, err)
518 }
520 out := stripansi.Strip(stdout.String())
521 errOut := stripansi.Strip(stderr.String())
523 for _, msg := range tc.ExpectedStdout {
524 assert.Contains(t, out, msg, "Expected stdout to contain: %s", msg)
525 }
527 for _, msg := range tc.ExpectedStderr {
528 assert.Contains(t, errOut, msg, "Expected stderr to contain: %s", msg)
529 }
530 })
531 }
532}
534// --skipGitInit promises to skip "both 'git init' and cloning". Two paths did not
535// honour it, and they fail differently depending on whether a project name is given,
536// so both are covered here.
537func Test_projectCreateCmd_SkipGitInit(t *testing.T) {
538 // Cannot use t.Parallel(): these tests replace package-level mocks and chdir.
539 origCreateProject := createProject
540 origCurrentUser := currentUser
541 origAddRemote := addRemote
542 origGitInitializer := gitInitializer
543 origRepoCloner := repoCloner
544 origRepoInitializer := repoInitializer
546 t.Cleanup(func() {
547 createProject = origCreateProject
548 currentUser = origCurrentUser
549 addRemote = origAddRemote
550 gitInitializer = origGitInitializer
551 repoCloner = origRepoCloner
552 repoInitializer = origRepoInitializer
553 })
555 stubAPI := func() {
556 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
557 return &gitlab.Project{
558 ID: 1,
559 Name: "test-project",
560 Path: "test-project",
561 NameWithNamespace: "username/test-project",
562 WebURL: "https://gitlab.com/username/test-project",
563 SSHURLToRepo: "git@gitlab.com:username/test-project.git",
564 }, nil
565 }
566 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
567 return &gitlab.User{ID: 1, Username: "username", Name: "name"}, nil
568 }
569 }
571 t.Run("no project name, not a Git repository: does not touch the remote", func(t *testing.T) {
572 // An empty temp dir makes `git rev-parse --git-dir` fail, so isGitInitialized
573 // is false — the exact situation in which `git remote add` printed
574 // "fatal: not a git repository" while the command still exited 0.
575 t.Chdir(t.TempDir())
577 stubAPI()
578 addRemoteCalled := false
579 addRemote = func(name, url string) (*git.Remote, error) {
580 addRemoteCalled = true
581 return nil, errors.New("fatal: not a git repository")
582 }
583 gitInitCalled := false
584 gitInitializer = func() error {
585 gitInitCalled = true
586 return nil
587 }
589 io, _, stdout, stderr := cmdtest.TestIOStreams()
590 f := cmdtest.NewTestFactory(io, cmdtest.WithConfig(config.NewFromString(heredoc.Doc(`
591 hosts:
592 gitlab.com:
593 username: monalisa
594 token: OTOKEN
595 no_prompt: true
596 `))))
598 cmd := NewCmdCreate(f)
599 cmdutils.EnableRepoOverride(cmd, f)
600 cmd.SetArgs([]string{"--skipGitInit"})
602 _, err := cmd.ExecuteC()
603 require.NoError(t, err)
605 assert.False(t, addRemoteCalled, "addRemote must not run outside a Git repository")
606 assert.False(t, gitInitCalled, "--skipGitInit must not run git init")
607 assert.Contains(t, stripansi.Strip(stdout.String()), "Created project on GitLab:")
608 assert.NotContains(t, stripansi.Strip(stderr.String()), "Could not add remote")
609 })
611 t.Run("with a project name: no prompt and no local setup", func(t *testing.T) {
612 t.Chdir(t.TempDir())
614 stubAPI()
615 addRemote = func(name, url string) (*git.Remote, error) {
616 return nil, errors.New("addRemote should not be reached")
617 }
618 clonerCalled := false
619 repoCloner = func(cloneURL, target, remoteName string) error {
620 clonerCalled = true
621 return nil
622 }
623 initializerCalled := false
624 repoInitializer = func(projectPath, remote string) error {
625 initializerCalled = true
626 return nil
627 }
629 // A TTY with prompts enabled is what made the old code prompt and then run
630 // the local setup that --skipGitInit says it skips.
631 io, _, stdout, _ := cmdtest.TestIOStreams(cmdtest.WithTestIOStreamsAsTTY(true))
632 f := cmdtest.NewTestFactory(io, cmdtest.WithConfig(config.NewFromString(heredoc.Doc(`
633 hosts:
634 gitlab.com:
635 username: monalisa
636 token: OTOKEN
637 `))))
639 cmd := NewCmdCreate(f)
640 cmdutils.EnableRepoOverride(cmd, f)
641 cmd.SetArgs([]string{"test-project", "--skipGitInit"})
643 // The prompt reads from the command's context. With --skipGitInit honoured
644 // nothing blocks and this finishes in milliseconds; if the flag is ignored
645 // the confirm waits on a TTY nobody is typing into, so the deadline turns
646 // what would otherwise be a hung CI job into a plain failure here.
647 ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
648 defer cancel()
650 _, err := cmd.ExecuteContextC(ctx)
651 require.NoError(t, err)
652 require.NoError(t, ctx.Err(), "--skipGitInit still prompted: the confirm blocked until the deadline")
654 assert.False(t, clonerCalled, "--skipGitInit must not clone")
655 assert.False(t, initializerCalled, "--skipGitInit must not initialize a local repository")
656 assert.Contains(t, stripansi.Strip(stdout.String()), "Created project on GitLab:")
657 assert.NotContains(t, stripansi.Strip(stdout.String()), "Initialized repository")
658 })
659}
661func Test_projectCreateCmd_TagsSentAsTopics(t *testing.T) {
662 // Cannot use t.Parallel(): this test replaces package-level mocks and chdir.
663 origCreateProject := createProject
664 origCurrentUser := currentUser
666 t.Cleanup(func() {
667 createProject = origCreateProject
668 currentUser = origCurrentUser
669 })
671 t.Chdir(t.TempDir())
673 var gotOpts *gitlab.CreateProjectOptions
674 createProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
675 gotOpts = opts
676 return &gitlab.Project{
677 ID: 1,
678 Name: "test-project",
679 Path: "test-project",
680 NameWithNamespace: "username/test-project",
681 SSHURLToRepo: "git@gitlab.com:username/test-project.git",
682 WebURL: "https://gitlab.com/username/test-project",
683 }, nil
684 }
685 currentUser = func(client *gitlab.Client) (*gitlab.User, error) {
686 return &gitlab.User{ID: 1, Username: "username", Name: "name"}, nil
687 }
689 io, _, _, _ := cmdtest.TestIOStreams()
690 f := cmdtest.NewTestFactory(io, cmdtest.WithConfig(config.NewFromString(heredoc.Doc(`
691 hosts:
692 gitlab.com:
693 username: monalisa
694 token: OTOKEN
695 no_prompt: true
696 `))))
698 cmd := NewCmdCreate(f)
699 cmdutils.EnableRepoOverride(cmd, f)
700 cmd.SetArgs([]string{"test-project", "--skipGitInit", "--tag", "go", "--tag", "cli"})
702 _, err := cmd.ExecuteC()
703 require.NoError(t, err)
705 require.NotNil(t, gotOpts)
706 require.NotNil(t, gotOpts.Topics)
707 assert.Equal(t, []string{"go", "cli"}, *gotOpts.Topics)
708}
Diagnostics9 git calls · 269 ms
CallStatusSizeTime0269 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=44Open pack map
fetchtree:0 · deepen 1200706 B · 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=706 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=tree:0 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=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=706 git.pkt.payload.max=606 git.sideband.band1.bytes=606 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=606 git.pack.trailer=5b8940d8a309b9f86f08953120610ba63124325eOpen 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 · 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=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=fb03183b7909876778f740d196d7516811003517Open pack map
fetchtree:0200614 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=614 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=3a89d0cfc8e81880c982180388e42e561a0b7eee 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=614 git.pkt.payload.max=587 git.sideband.band1.bytes=587 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=587 git.pack.trailer=eb8250f8e8340ff2fafc22c5aba90db34fd906a9Open pack map
fetchtree:0200146 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=146 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=36190c1e41d9d7100992fb1024e710443f9e7622 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=06bc37d1848912e665a98db6e5476c114b644397Open pack map
fetch2003.5 KiB254 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=254 git.response.bytes=3604 git.response.cache=MISS git.response.duration_ms=254 git.fetch.wants=6a731a2181c6d9212dafebf764131893fbef81b1 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=3604 git.pkt.payload.max=3577 git.sideband.band1.bytes=3577 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
- a5ea564848d47089
- Request
- 18a767e5…
- 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