GitLabgitlab-org

cli

main
ply6 git calls272 ms99 KiB3 cachedprotocol v2
1205 lines36 KiBRaw
1//go:build !integration
3package glrepo
5import (
6 "context"
7 "errors"
8 "fmt"
9 "io"
10 "testing"
12 tea "charm.land/bubbletea/v2"
13 "git.sr.ht/~timofurrer/ugh"
14 "github.com/hashicorp/go-multierror"
15 "github.com/stretchr/testify/assert"
16 "github.com/stretchr/testify/require"
18 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
20 "gitlab.com/gitlab-org/cli/internal/api"
21 "gitlab.com/gitlab-org/cli/internal/config"
22 "gitlab.com/gitlab-org/cli/internal/git"
23 "gitlab.com/gitlab-org/cli/internal/glinstance"
24 "gitlab.com/gitlab-org/cli/internal/iostreams"
27const (
28 testConsoleWidth = 120
29 testConsoleHeight = 40
32func testIOStreamsWithConsole(t *testing.T, c *ugh.Console) (*iostreams.IOStreams, func()) {
33 t.Helper()
35 appInR, appInW := io.Pipe()
36 appOutR, appOutW := io.Pipe()
38 ctx, cancel := context.WithCancel(t.Context())
39 wait := c.Start(ctx, appOutR, appInW)
41 ios := iostreams.New(
42 iostreams.WithStdin(appInR, true),
43 iostreams.WithStdout(appOutW, true),
44 iostreams.WithStderr(io.Discard, true),
45 iostreams.WithProgramOptions(tea.WithWindowSize(testConsoleWidth, testConsoleHeight)),
46 )
48 cleanup := func() {
49 appInW.Close()
50 appOutW.Close()
51 appOutR.Close()
52 cancel()
53 wait()
54 }
56 return ios, cleanup
59func Test_RemoteForRepo(t *testing.T) {
60 r := &ResolvedRemotes{
61 remotes: Remotes{
62 &Remote{
63 Remote: &git.Remote{
64 Name: "upstream",
65 },
66 Repo: NewWithHost("profclems", "glab", "gitlab.com"),
67 },
68 &Remote{
69 Remote: &git.Remote{
70 Name: "origin",
71 },
72 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
73 },
74 },
75 }
76 testCases := []struct {
77 name string
78 input Interface
79 output *Remote // Expected remote if there is a match
80 wantErr string // Expected error
81 }{
82 {
83 name: "match upstream",
84 input: NewWithHost("profclems", "glab", "gitlab.com"),
85 output: &Remote{
86 Remote: &git.Remote{
87 Name: "upstream",
88 },
89 Repo: NewWithHost("profclems", "glab", "gitlab.com"),
90 },
91 },
92 {
93 name: "match origin",
94 input: NewWithHost("maxice8", "glab", "gitlab.com"),
95 output: &Remote{
96 Remote: &git.Remote{
97 Name: "origin",
98 },
99 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
100 },
101 },
102 {
103 name: "no match via Hostname",
104 input: NewWithHost("profclems", "glab", "gitlab.extradomain.com"),
105 wantErr: "not found",
106 },
107 {
108 name: "no match via Username",
109 input: NewWithHost("noexist", "glab", "gitlab.com"),
110 wantErr: "not found",
111 },
112 {
113 name: "no match via Name",
114 input: NewWithHost("profclems", "maxice8", "gitlab.com"),
115 wantErr: "not found",
116 },
117 }
118 for _, tC := range testCases {
119 t.Run(tC.name, func(t *testing.T) {
120 got, err := r.RemoteForRepo(tC.input)
121 if tC.wantErr == "" && err != nil {
122 t.Errorf("RemoteForRepo() unexpected error = %s", err)
123 }
124 if tC.wantErr != "" {
125 if tC.wantErr != err.Error() {
126 t.Errorf("RemoteForRepo() expected error = %s, got = %s", tC.wantErr, err)
127 }
128 } else {
129 // Make sure both return all the exact same thing
130 assert.Equal(t, tC.output.Name, got.Name)
131 assert.Equal(t, tC.output.Remote.Name, got.Remote.Name)
132 assert.Equal(t, tC.output.Repo.FullName(), got.Repo.FullName())
133 assert.Equal(t, tC.output.Repo.RepoHost(), got.Repo.RepoHost())
134 }
135 })
136 }
139func Test_ResolveRemotesToRepos(t *testing.T) {
140 rem := &ResolvedRemotes{
141 remotes: Remotes{
142 &Remote{
143 Remote: &git.Remote{
144 Name: "origin",
145 },
146 Repo: NewWithHost("profclems", "glab", "gitlab.com"),
147 },
148 },
149 apiClient: &gitlab.Client{},
150 }
152 // Test the normal and most expected usage
153 t.Run("simple", func(t *testing.T) {
154 r, err := ResolveRemotesToRepos(rem.remotes, rem.apiClient, glinstance.DefaultHostname, config.NewBlankConfig())
155 require.NoError(t, err)
157 assert.Equal(t, rem.apiClient, r.apiClient)
159 assert.Len(t, r.remotes, 1)
161 for i := range r.remotes {
162 assert.Equal(t, r.remotes[i].Name, rem.remotes[i].Name)
163 assert.Equal(t, r.remotes[i].Repo.FullName(), rem.remotes[i].Repo.FullName())
164 assert.Equal(t, r.remotes[i].Repo.RepoHost(), rem.remotes[i].Repo.RepoHost())
165 }
166 })
169func Test_resolveNetwork(t *testing.T) {
170 rem := &ResolvedRemotes{
171 remotes: Remotes{
172 &Remote{
173 Remote: &git.Remote{
174 Name: "origin",
175 },
176 Repo: NewWithHost("profclems", "glab", "gitlab.com"),
177 },
178 },
179 apiClient: &gitlab.Client{},
180 }
182 // Override api.GetProject to not use the network
183 mockAPIGetProject := func(_ *gitlab.Client, ProjectID any) (*gitlab.Project, error) {
184 proj := &gitlab.Project{
185 PathWithNamespace: fmt.Sprint(ProjectID),
186 }
187 return proj, nil
188 }
190 t.Run("simple", func(t *testing.T) {
191 // Make our own copy of rem we can modify
192 rem := *rem
194 api.GetProject = mockAPIGetProject
196 err := resolveNetwork(&rem)
198 require.NoError(t, err)
199 assert.Len(t, rem.network, len(rem.remotes))
200 for i := range rem.network {
201 assert.Equal(t, rem.remotes[i].Repo.FullName(), rem.network[i].PathWithNamespace)
202 }
203 })
205 t.Run("API call failed", func(t *testing.T) {
206 // Make our own copy of rem we can modify
207 rem := *rem
209 // Override api.GetProject so it doesn't mess with other tests
210 originalGetProject := api.GetProject
211 defer func() {
212 api.GetProject = originalGetProject
213 }()
214 api.GetProject = func(_ *gitlab.Client, ProjectID any) (*gitlab.Project, error) {
215 return nil, assert.AnError
216 }
218 err := resolveNetwork(&rem)
220 require.Error(t, err)
221 require.ErrorIs(t, err, assert.AnError)
222 assert.Empty(t, rem.network)
223 })
225 t.Run("MaxRemotesForLookup limit", func(t *testing.T) {
226 // Make our own copy of rem we can modify
227 rem := *rem
229 api.GetProject = mockAPIGetProject
231 for i := range maxRemotesForLookup {
232 rem.remotes = append(rem.remotes, rem.remotes[i])
233 }
234 // Make sure we have at least one more remote than the limit set from maxRemotesForLookup
235 assert.Len(t, rem.remotes, maxRemotesForLookup+1)
237 err := resolveNetwork(&rem)
239 require.NoError(t, err)
240 assert.Len(t, rem.network, maxRemotesForLookup)
241 for i := range rem.network {
242 assert.Equal(t, rem.remotes[i].Repo.FullName(), rem.network[i].PathWithNamespace)
243 }
244 })
247func Test_BaseRepo(t *testing.T) {
248 // Make it a function that must be called by each test so none of them overlap
249 rem := func() ResolvedRemotes {
250 rem := &ResolvedRemotes{
251 remotes: Remotes{
252 &Remote{
253 Remote: &git.Remote{
254 Name: "upstream",
255 },
256 Repo: NewWithHost("profclems", "glab", "gitlab.com"),
257 },
258 },
259 apiClient: &gitlab.Client{},
260 network: []gitlab.Project{
261 {
262 ID: 1,
263 PathWithNamespace: "profclems/glab",
264 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
265 },
266 },
267 }
268 return *rem
269 }
271 mockGitlabProject := func(i any) gitlab.Project {
272 p := &gitlab.Project{
273 PathWithNamespace: fmt.Sprint(i),
274 HTTPURLToRepo: fmt.Sprintf("https://gitlab.com/%s", i),
275 }
276 return *p
277 }
279 // Override git.SetRemoteResolution so it doesn't mess with the user configs
280 originalSetRemoteResolution := git.SetRemoteResolution
281 defer func() {
282 git.SetRemoteResolution = originalSetRemoteResolution
283 }()
284 git.SetRemoteResolution = func(_, _ string) error {
285 return nil
286 }
288 // Override api.GetProject so it doesn't mess with other tests
289 originalGetProject := api.GetProject
290 defer func() {
291 api.GetProject = originalGetProject
292 }()
293 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
294 p := mockGitlabProject(projectID)
295 return &p, nil
296 }
298 t.Run("Resolved->base", func(t *testing.T) {
299 localRem := rem()
301 // Set a base resolution
302 localRem.remotes[0].Resolved = "base"
304 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
305 require.NoError(t, err)
307 assert.Equal(t, localRem.remotes[0].FullName(), got.FullName())
308 assert.Equal(t, localRem.remotes[0].RepoHost(), got.RepoHost())
309 })
311 t.Run("Resolved->base:", func(t *testing.T) {
312 localRem := rem()
314 expectedResolution := NewWithHost("maxice8", "glab", "gitlab.com")
316 // Set a base resolution
317 localRem.remotes[0].Resolved = "base: gitlab.com/maxice8/glab"
319 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
320 require.NoError(t, err)
322 assert.Equal(t, expectedResolution.FullName(), got.FullName())
323 assert.Equal(t, expectedResolution.RepoHost(), got.RepoHost())
324 })
326 t.Run("Resolved->base: (invalid)", func(t *testing.T) {
327 localRem := rem()
329 // Set a base resolution
330 localRem.remotes[0].Resolved = "base:NotAnActualValidValue"
332 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
333 assert.Nil(t, got)
334 assert.EqualError(t, err, `expected the "[HOST/]OWNER/[NAMESPACE/]REPO" format, got "NotAnActualValidValue"`)
335 })
337 t.Run("Resolved->backwards-compatibility", func(t *testing.T) {
338 localRem := rem()
340 expectedResolution := NewWithHost("maxice8", "glab", "gitlab.com")
342 // Set a base resolution
343 localRem.remotes[0].Resolved = "gitlab.com/maxice8/glab"
345 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
346 require.NoError(t, err)
348 assert.Equal(t, expectedResolution.FullName(), got.FullName())
349 assert.Equal(t, expectedResolution.RepoHost(), got.RepoHost())
350 })
352 t.Run("Resolved->backwards-compatibility: (invalid)", func(t *testing.T) {
353 localRem := rem()
355 // Set a base resolution
356 localRem.remotes[0].Resolved = "NotAnActualValidValue"
358 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
359 assert.Nil(t, got)
360 assert.EqualError(t, err, `expected the "[HOST/]OWNER/[NAMESPACE/]REPO" format, got "NotAnActualValidValue"`)
361 })
363 t.Run("ResolvedBase->base (new field)", func(t *testing.T) {
364 localRem := rem()
366 // Set the new ResolvedBase field
367 localRem.remotes[0].ResolvedBase = "base"
369 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
370 require.NoError(t, err)
372 assert.Equal(t, localRem.remotes[0].FullName(), got.FullName())
373 assert.Equal(t, localRem.remotes[0].RepoHost(), got.RepoHost())
374 })
376 t.Run("ResolvedBase->base: (new field with prefix)", func(t *testing.T) {
377 localRem := rem()
379 expectedResolution := NewWithHost("example", "glab", "gitlab.com")
381 // Set the new ResolvedBase field with prefix
382 localRem.remotes[0].ResolvedBase = "base: gitlab.com/example/glab"
384 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
385 require.NoError(t, err)
387 assert.Equal(t, expectedResolution.FullName(), got.FullName())
388 assert.Equal(t, expectedResolution.RepoHost(), got.RepoHost())
389 })
391 t.Run("ResolvedBase takes precedence over Resolved", func(t *testing.T) {
392 localRem := rem()
394 expectedResolution := NewWithHost("example", "glab", "gitlab.com")
396 // Set both fields - new field should win
397 localRem.remotes[0].ResolvedBase = "base: gitlab.com/example/glab"
398 localRem.remotes[0].Resolved = "base: gitlab.com/different/repo"
400 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
401 require.NoError(t, err)
403 // Should use ResolvedBase, not Resolved
404 assert.Equal(t, expectedResolution.FullName(), got.FullName())
405 assert.Equal(t, expectedResolution.RepoHost(), got.RepoHost())
406 })
408 t.Run("Prompt==false", func(t *testing.T) {
409 localRem := rem()
411 got, err := localRem.BaseRepo(t.Context(), iostreams.New())
412 require.NoError(t, err)
414 assert.Equal(t, localRem.remotes[0].FullName(), got.FullName())
415 assert.Equal(t, localRem.remotes[0].RepoHost(), got.RepoHost())
416 })
418 t.Run("Consult the network 1 repo", func(t *testing.T) {
419 localRem := rem()
421 // Prompt must be true otherwise we won't reach the code we want to test
422 got, err := localRem.BaseRepo(t.Context(), iostreams.New(iostreams.WithStdout(nil, true), iostreams.WithStderr(nil, true)))
423 require.NoError(t, err)
425 assert.Equal(t, localRem.remotes[0].FullName(), got.FullName())
426 assert.Equal(t, localRem.remotes[0].RepoHost(), got.RepoHost())
427 })
429 t.Run("Consult the network, no remotes", func(t *testing.T) {
430 localRem := rem()
432 // Wipe out all remotes
433 localRem.remotes = Remotes{}
434 localRem.network = nil
436 _, err := localRem.BaseRepo(t.Context(), iostreams.New(iostreams.WithStdout(nil, true), iostreams.WithStderr(nil, true)))
437 assert.EqualError(t, err, "no GitLab Projects found from remotes")
438 })
440 t.Run("Consult the network, multiple projects, pick origin", func(t *testing.T) {
441 localRem := rem()
443 originRemote := &Remote{
444 Remote: &git.Remote{Name: "origin"},
445 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
446 }
448 originNetwork := gitlab.Project{
449 ID: 2,
450 PathWithNamespace: "maxice8/glab",
451 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
452 }
454 localRem.remotes = append(localRem.remotes, originRemote)
455 localRem.network = append(localRem.network, originNetwork)
457 // Mock the prompt
458 c := ugh.New(t)
459 c.Expect(ugh.SelectRegexp("Which should be the base repository")).
460 Do(ugh.SelectIndex(1))
461 ios, cleanup := testIOStreamsWithConsole(t, c)
462 t.Cleanup(cleanup)
464 got, err := localRem.BaseRepo(t.Context(), ios)
465 require.NoError(t, err)
467 assert.Equal(t, originRemote.Repo.FullName(), got.FullName())
468 assert.Equal(t, originRemote.Repo.RepoHost(), got.RepoHost())
469 })
471 t.Run("Consult the network, multiple projects, pick upstream", func(t *testing.T) {
472 localRem := rem()
474 originRemote := &Remote{
475 Remote: &git.Remote{Name: "origin"},
476 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
477 }
479 originNetwork := gitlab.Project{
480 ID: 2,
481 PathWithNamespace: "maxice8/glab",
482 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
483 }
485 localRem.remotes = append(localRem.remotes, originRemote)
486 localRem.network = append(localRem.network, originNetwork)
488 // Mock the prompt
489 c := ugh.New(t)
490 c.Expect(ugh.SelectRegexp("Which should be the base repository")).
491 Do(ugh.SelectIndex(0))
492 ios, cleanup := testIOStreamsWithConsole(t, c)
493 t.Cleanup(cleanup)
495 got, err := localRem.BaseRepo(t.Context(), ios)
496 require.NoError(t, err)
498 assert.Equal(t, localRem.remotes[0].Repo.FullName(), got.FullName())
499 assert.Equal(t, localRem.remotes[0].Repo.RepoHost(), got.RepoHost())
500 })
502 t.Run("Consult the network, one forked project, get fork", func(t *testing.T) {
503 localRem := rem()
505 originRemote := &Remote{
506 Remote: &git.Remote{Name: "origin"},
507 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
508 }
510 originNetwork := gitlab.Project{
511 ID: 2,
512 PathWithNamespace: "maxice8/glab",
513 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
514 ForkedFromProject: &gitlab.ForkParent{
515 ID: 1,
516 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
517 PathWithNamespace: "profclems/glab",
518 },
519 }
521 localRem.remotes = Remotes{originRemote}
522 localRem.network = []gitlab.Project{originNetwork}
524 // Mock the prompt
525 c := ugh.New(t)
526 c.Expect(ugh.SelectRegexp("Which should be the base repository")).
527 Do(ugh.SelectIndex(1))
528 ios, cleanup := testIOStreamsWithConsole(t, c)
529 t.Cleanup(cleanup)
531 got, err := localRem.BaseRepo(t.Context(), ios)
532 require.NoError(t, err)
534 assert.Equal(t, originRemote.Repo.FullName(), got.FullName())
535 assert.Equal(t, originRemote.Repo.RepoHost(), got.RepoHost())
536 })
538 t.Run("Consult the network, one forked project, get upstream", func(t *testing.T) {
539 localRem := rem()
541 originRemote := &Remote{
542 Remote: &git.Remote{Name: "origin"},
543 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
544 }
546 originNetwork := gitlab.Project{
547 ID: 2,
548 PathWithNamespace: "maxice8/glab",
549 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
550 ForkedFromProject: &gitlab.ForkParent{
551 ID: 1,
552 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
553 PathWithNamespace: "profclems/glab",
554 },
555 }
557 localRem.remotes = Remotes{originRemote}
558 localRem.network = []gitlab.Project{originNetwork}
560 // Mock the prompt
561 c := ugh.New(t)
562 c.Expect(ugh.SelectRegexp("Which should be the base repository")).
563 Do(ugh.SelectIndex(0))
564 ios, cleanup := testIOStreamsWithConsole(t, c)
565 t.Cleanup(cleanup)
567 got, err := localRem.BaseRepo(t.Context(), ios)
568 require.NoError(t, err)
570 assert.Equal(t, "profclems/glab", got.FullName())
571 assert.Equal(t, "gitlab.com", got.RepoHost())
572 })
574 t.Run("Consult the network, all calls fail", func(t *testing.T) {
575 // Override api.GetProject so it doesn't mess with other tests
576 originalGetProject := api.GetProject
577 defer func() {
578 api.GetProject = originalGetProject
579 }()
580 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
581 return nil, assert.AnError
582 }
583 localRem := rem()
585 originRemote := &Remote{
586 Remote: &git.Remote{Name: "origin"},
587 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
588 }
590 localRem.remotes = append(localRem.remotes, originRemote)
591 localRem.network = nil
593 // Prompt must be true otherwise we won't reach the code we want to test
594 _, err := localRem.BaseRepo(t.Context(), iostreams.New(iostreams.WithStdout(nil, true), iostreams.WithStderr(nil, true)))
595 multierr := func() *multierror.Error {
596 target := &multierror.Error{}
597 _ = errors.As(err, &target)
598 return target
599 }()
600 assert.Len(t, multierr.Errors, 2)
601 assert.ErrorIs(t, err, assert.AnError, "Unexpected error type")
602 })
604 t.Run("Consult the network, some, but not all, calls fail", func(t *testing.T) {
605 // Override api.GetProject so it doesn't mess with other tests
606 originalGetProject := api.GetProject
607 defer func() {
608 api.GetProject = originalGetProject
609 }()
610 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
611 if projectID == "profclems/glab" {
612 return &gitlab.Project{
613 ID: 1,
614 PathWithNamespace: "profclems/glab",
615 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
616 }, nil
617 }
618 return nil, assert.AnError
619 }
620 localRem := rem()
622 originRemote := &Remote{
623 Remote: &git.Remote{Name: "origin"},
624 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
625 }
627 localRem.remotes = append(localRem.remotes, originRemote)
628 localRem.network = nil
630 // Prompt must be true otherwise we won't reach the code we want to test
631 _, err := localRem.BaseRepo(t.Context(), iostreams.New(iostreams.WithStdout(nil, true), iostreams.WithStderr(nil, true)))
632 assert.NoError(t, err)
633 })
635 t.Run("Host mismatch: API host differs from git remote host", func(t *testing.T) {
636 // This test verifies our fix for the host mismatch bug
637 // where the API returns a different host than the git remote
638 // Git remote uses git.example.com, but API returns api.example.com
639 localRem := &ResolvedRemotes{
640 remotes: Remotes{
641 &Remote{
642 Remote: &git.Remote{
643 Name: "origin",
644 },
645 Repo: NewWithHost("owner", "repo", "git.example.com"), // Git remote uses git host
646 },
647 },
648 apiClient: &gitlab.Client{},
649 network: []gitlab.Project{
650 {
651 ID: 1,
652 PathWithNamespace: "owner/repo",
653 HTTPURLToRepo: "https://api.example.com/owner/repo.git", // API returns api.example.com, different from git remote's git.example.com
654 },
655 },
656 }
658 // Override git.SetRemoteResolution so it doesn't mess with the user configs
659 originalSetRemoteResolution := git.SetRemoteResolution
660 defer func() {
661 git.SetRemoteResolution = originalSetRemoteResolution
662 }()
663 git.SetRemoteResolution = func(_, _ string) error {
664 return nil
665 }
667 // Override api.GetProject so it doesn't mess with other tests
668 originalGetProject := api.GetProject
669 defer func() {
670 api.GetProject = originalGetProject
671 }()
672 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
673 p := &gitlab.Project{
674 PathWithNamespace: fmt.Sprint(projectID),
675 HTTPURLToRepo: "https://api.example.com/owner/repo.git", // API returns api.example.com, different from git remote's git.example.com
676 }
677 return p, nil
678 }
680 ios := iostreams.New(iostreams.WithStdout(io.Discard, true), iostreams.WithStderr(io.Discard, true))
682 got, err := localRem.BaseRepo(t.Context(), ios)
683 require.NoError(t, err)
685 // The fix should ensure we use the git remote host, not the API host
686 assert.Equal(t, "owner/repo", got.FullName())
687 assert.Equal(t, "git.example.com", got.RepoHost()) // Should use git remote host, not API host
688 })
690 t.Run("Host mismatch with subfolder: API host differs from git remote host and includes subfolder", func(t *testing.T) {
691 // This test verifies the split-host + subfolder bug (Issue #8197)
692 // where the API returns a different host than the git remote AND includes a subfolder
693 // Git remote uses git.example.com, but API returns api.example.com/gitlab/owner/repo.git
695 // Mock config with subfolder - using CORRECT config pattern (API hostname as key)
696 cfg := config.NewFromString(`---
697hosts:
698 api.example.com:
699 token: TEST_TOKEN
700 ssh_host: git.example.com
701 subfolder: gitlab
702`)
704 localRem := &ResolvedRemotes{
705 remotes: Remotes{
706 &Remote{
707 Remote: &git.Remote{
708 Name: "origin",
709 },
710 Repo: NewWithHost("owner", "repo", "git.example.com"), // Git remote uses git host
711 },
712 },
713 apiClient: &gitlab.Client{},
714 defaultHostname: "gitlab.com",
715 cfg: cfg,
716 network: []gitlab.Project{
717 {
718 ID: 1,
719 PathWithNamespace: "owner/repo", // API provides correct path WITHOUT subfolder
720 HTTPURLToRepo: "https://api.example.com/gitlab/owner/repo.git", // URL includes subfolder
721 },
722 },
723 }
725 // Override git.SetRemoteResolution so it doesn't mess with the user configs
726 originalSetRemoteResolution := git.SetRemoteResolution
727 defer func() {
728 git.SetRemoteResolution = originalSetRemoteResolution
729 }()
730 git.SetRemoteResolution = func(_, _ string) error {
731 return nil
732 }
734 // Override api.GetProject so it doesn't mess with other tests
735 originalGetProject := api.GetProject
736 defer func() {
737 api.GetProject = originalGetProject
738 }()
739 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
740 p := &gitlab.Project{
741 PathWithNamespace: "owner/repo", // API returns correct path
742 HTTPURLToRepo: "https://api.example.com/gitlab/owner/repo.git",
743 }
744 return p, nil
745 }
747 ios := iostreams.New(iostreams.WithStdout(nil, true), iostreams.WithStderr(nil, true))
749 got, err := localRem.BaseRepo(t.Context(), ios)
750 require.NoError(t, err)
752 // The fix should ensure we get the correct path WITHOUT the subfolder prefix
753 assert.Equal(t, "owner/repo", got.FullName())
754 assert.Equal(t, "git.example.com", got.RepoHost())
755 })
758func Test_HeadRepo(t *testing.T) {
759 // Make it a function that must be called by each test so none of them overlap
760 rem := func() ResolvedRemotes {
761 rem := &ResolvedRemotes{
762 remotes: Remotes{
763 &Remote{
764 Remote: &git.Remote{
765 Name: "upstream",
766 },
767 Repo: NewWithHost("profclems", "glab", "gitlab.com"),
768 },
769 },
770 apiClient: &gitlab.Client{},
771 network: []gitlab.Project{
772 {
773 ID: 1,
774 PathWithNamespace: "profclems/glab",
775 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
776 },
777 },
778 }
779 return *rem
780 }
782 mockGitlabProject := func(i any) gitlab.Project {
783 p := &gitlab.Project{
784 PathWithNamespace: fmt.Sprint(i),
785 HTTPURLToRepo: fmt.Sprintf("https://gitlab.com/%s", i),
786 }
787 return *p
788 }
790 // Override git.SetRemoteResolution so it doesn't mess with the user configs
791 originalSetRemoteResolution := git.SetRemoteResolution
792 defer func() {
793 git.SetRemoteResolution = originalSetRemoteResolution
794 }()
795 git.SetRemoteResolution = func(_, _ string) error {
796 return nil
797 }
799 // Override api.GetProject so it doesn't mess with other tests
800 originalGetProject := api.GetProject
801 defer func() {
802 api.GetProject = originalGetProject
803 }()
804 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
805 p := mockGitlabProject(projectID)
806 return &p, nil
807 }
809 t.Run("Resolved->head", func(t *testing.T) {
810 localRem := rem()
812 // Set a head resolution
813 localRem.remotes[0].Resolved = "head"
815 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
816 require.NoError(t, err)
818 assert.Equal(t, localRem.remotes[0].FullName(), got.FullName())
819 assert.Equal(t, localRem.remotes[0].RepoHost(), got.RepoHost())
820 })
822 t.Run("Resolved->head:", func(t *testing.T) {
823 localRem := rem()
825 expectedResolution := NewWithHost("maxice8", "glab", "gitlab.com")
827 // Set a base resolution
828 localRem.remotes[0].Resolved = "head: gitlab.com/maxice8/glab"
830 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
831 require.NoError(t, err)
833 assert.Equal(t, expectedResolution.FullName(), got.FullName())
834 assert.Equal(t, expectedResolution.RepoHost(), got.RepoHost())
835 })
837 t.Run("Resolved->head: (invalid)", func(t *testing.T) {
838 localRem := rem()
840 // Set a base resolution
841 localRem.remotes[0].Resolved = "head:NotAnActualValidValue"
843 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
844 assert.Nil(t, got)
845 assert.EqualError(t, err, `expected the "[HOST/]OWNER/[NAMESPACE/]REPO" format, got "NotAnActualValidValue"`)
846 })
848 t.Run("ResolvedHead->head (new field)", func(t *testing.T) {
849 localRem := rem()
851 // Set the new ResolvedHead field
852 localRem.remotes[0].ResolvedHead = "head"
854 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
855 require.NoError(t, err)
857 assert.Equal(t, localRem.remotes[0].FullName(), got.FullName())
858 assert.Equal(t, localRem.remotes[0].RepoHost(), got.RepoHost())
859 })
861 t.Run("ResolvedHead->head: (new field with prefix)", func(t *testing.T) {
862 localRem := rem()
864 expectedResolution := NewWithHost("example", "glab", "gitlab.com")
866 // Set the new ResolvedHead field with prefix
867 localRem.remotes[0].ResolvedHead = "head: gitlab.com/example/glab"
869 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
870 require.NoError(t, err)
872 assert.Equal(t, expectedResolution.FullName(), got.FullName())
873 assert.Equal(t, expectedResolution.RepoHost(), got.RepoHost())
874 })
876 t.Run("ResolvedHead takes precedence over Resolved", func(t *testing.T) {
877 localRem := rem()
879 expectedResolution := NewWithHost("example", "glab", "gitlab.com")
881 // Set both fields - new field should win
882 localRem.remotes[0].ResolvedHead = "head: gitlab.com/example/glab"
883 localRem.remotes[0].Resolved = "head: gitlab.com/different/repo"
885 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
886 require.NoError(t, err)
888 // Should use ResolvedHead, not Resolved
889 assert.Equal(t, expectedResolution.FullName(), got.FullName())
890 assert.Equal(t, expectedResolution.RepoHost(), got.RepoHost())
891 })
893 t.Run("Prompt==false", func(t *testing.T) {
894 localRem := rem()
896 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
897 require.NoError(t, err)
899 assert.Equal(t, localRem.remotes[0].FullName(), got.FullName())
900 })
902 t.Run("Consult the network 1 repo", func(t *testing.T) {
903 localRem := rem()
905 // Prompt must be true otherwise we won't reach the code we want to test
906 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
907 require.NoError(t, err)
909 assert.Equal(t, got.FullName(), localRem.remotes[0].FullName())
910 })
912 t.Run("Consult the network, more than 1 forked repo, pick the fork", func(t *testing.T) {
913 localRem := rem()
915 originRemote := &Remote{
916 Remote: &git.Remote{Name: "origin"},
917 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
918 }
920 originNetwork := gitlab.Project{
921 ID: 2,
922 PathWithNamespace: "maxice8/glab",
923 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
924 ForkedFromProject: &gitlab.ForkParent{
925 ID: 1,
926 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
927 PathWithNamespace: "profclems/glab",
928 },
929 }
931 localRem.remotes = Remotes{originRemote}
932 localRem.network = []gitlab.Project{originNetwork}
934 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
935 require.NoError(t, err)
937 assert.Equal(t, "maxice8/glab", got.FullName())
938 })
940 t.Run("Consult the network, fork of a fork, pick the local fork", func(t *testing.T) {
941 localRem := rem()
942 originRemote := &Remote{
943 Remote: &git.Remote{Name: "origin"},
944 Repo: NewWithHost("group/sub", "project", "gitlab.com"),
945 }
946 parent := mockGitlabProject("group/sub/template")
947 parent.ForkedFromProject = &gitlab.ForkParent{PathWithNamespace: "group/base"}
948 project := mockGitlabProject("group/sub/project")
949 project.ForkedFromProject = &gitlab.ForkParent{PathWithNamespace: parent.PathWithNamespace}
950 localRem.remotes = Remotes{originRemote}
951 localRem.network = []gitlab.Project{project}
953 getProject := api.GetProject
954 t.Cleanup(func() { api.GetProject = getProject })
955 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
956 require.Equal(t, parent.PathWithNamespace, projectID)
957 return &parent, nil
958 }
960 ios := iostreams.New()
961 require.False(t, ios.PromptEnabled())
962 got, err := localRem.HeadRepo(t.Context(), ios)
963 require.NoError(t, err)
964 require.NotNil(t, got)
965 assert.Equal(t, "group/sub/project", got.FullName())
966 assert.Equal(t, "gitlab.com", got.RepoHost())
967 })
969 t.Run("Consult the network, no fork with a local remote, pick the first", func(t *testing.T) {
970 localRem := rem()
971 originRemote := &Remote{
972 Remote: &git.Remote{Name: "origin"},
973 Repo: NewWithHost("other", "project", "gitlab.com"),
974 }
975 project := mockGitlabProject("group/fork")
976 project.ForkedFromProject = &gitlab.ForkParent{PathWithNamespace: "group/base"}
977 localRem.remotes = Remotes{originRemote, localRem.remotes[0]}
978 localRem.network = []gitlab.Project{project}
980 ios := iostreams.New()
981 require.False(t, ios.PromptEnabled())
982 got, err := localRem.HeadRepo(t.Context(), ios)
983 require.NoError(t, err)
984 assert.Same(t, localRem.remotes[0], got)
985 })
987 t.Run("Consult the network, more than 1 repo, pick the first", func(t *testing.T) {
988 localRem := rem()
990 originRemote := &Remote{
991 Remote: &git.Remote{Name: "origin"},
992 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
993 }
995 originNetwork := gitlab.Project{
996 ID: 2,
997 PathWithNamespace: "maxice8/glab",
998 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
999 }
1001 localRem.remotes = append(localRem.remotes, originRemote)
1002 localRem.network = append(localRem.network, originNetwork)
1004 got, err := localRem.HeadRepo(t.Context(), iostreams.New())
1005 require.NoError(t, err)
1007 assert.Equal(t, "profclems/glab", got.FullName())
1008 })
1010 t.Run("Consult the network, no remotes", func(t *testing.T) {
1011 localRem := rem()
1013 // Wipe out all remotes
1014 localRem.remotes = Remotes{}
1015 localRem.network = nil
1017 _, err := localRem.HeadRepo(t.Context(), iostreams.New(iostreams.WithStdout(nil, true), iostreams.WithStderr(nil, true)))
1018 assert.EqualError(t, err, "no GitLab Projects found from remotes")
1019 })
1021 t.Run("Consult the network, multiple projects, pick origin", func(t *testing.T) {
1022 localRem := rem()
1024 originRemote := &Remote{
1025 Remote: &git.Remote{Name: "origin"},
1026 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
1029 originNetwork := gitlab.Project{
1030 ID: 2,
1031 PathWithNamespace: "maxice8/glab",
1032 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
1035 localRem.remotes = append(localRem.remotes, originRemote)
1036 localRem.network = append(localRem.network, originNetwork)
1038 // Mock the prompt
1039 c := ugh.New(t)
1040 c.Expect(ugh.SelectRegexp("Which should be the head repository")).
1041 Do(ugh.SelectIndex(1))
1042 ios, cleanup := testIOStreamsWithConsole(t, c)
1043 t.Cleanup(cleanup)
1044 got, err := localRem.HeadRepo(t.Context(), ios)
1045 require.NoError(t, err)
1047 assert.Equal(t, originRemote.Repo.FullName(), got.FullName())
1048 assert.Equal(t, originRemote.Repo.RepoHost(), got.RepoHost())
1049 })
1051 t.Run("Consult the network, multiple projects, pick upstream", func(t *testing.T) {
1052 localRem := rem()
1054 originRemote := &Remote{
1055 Remote: &git.Remote{Name: "origin"},
1056 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
1059 originNetwork := gitlab.Project{
1060 ID: 2,
1061 PathWithNamespace: "maxice8/glab",
1062 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
1065 localRem.remotes = append(localRem.remotes, originRemote)
1066 localRem.network = append(localRem.network, originNetwork)
1068 // Mock the prompt
1069 c := ugh.New(t)
1070 c.Expect(ugh.SelectRegexp("Which should be the head repository")).
1071 Do(ugh.SelectIndex(0))
1072 ios, cleanup := testIOStreamsWithConsole(t, c)
1073 t.Cleanup(cleanup)
1074 got, err := localRem.HeadRepo(t.Context(), ios)
1075 require.NoError(t, err)
1077 assert.Equal(t, localRem.remotes[0].Repo.FullName(), got.FullName())
1078 assert.Equal(t, localRem.remotes[0].Repo.RepoHost(), got.RepoHost())
1079 })
1081 t.Run("Consult the network, one forked project, get fork", func(t *testing.T) {
1082 localRem := rem()
1084 originRemote := &Remote{
1085 Remote: &git.Remote{Name: "origin"},
1086 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
1089 originNetwork := gitlab.Project{
1090 ID: 2,
1091 PathWithNamespace: "maxice8/glab",
1092 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
1093 ForkedFromProject: &gitlab.ForkParent{
1094 ID: 1,
1095 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
1096 PathWithNamespace: "profclems/glab",
1097 },
1100 localRem.remotes = Remotes{originRemote}
1101 localRem.network = []gitlab.Project{originNetwork}
1103 // Mock the prompt
1104 c := ugh.New(t)
1105 c.Expect(ugh.SelectRegexp("Which should be the head repository")).
1106 Do(ugh.SelectIndex(1))
1107 ios, cleanup := testIOStreamsWithConsole(t, c)
1108 t.Cleanup(cleanup)
1109 got, err := localRem.HeadRepo(t.Context(), ios)
1110 require.NoError(t, err)
1112 assert.Equal(t, originRemote.Repo.FullName(), got.FullName())
1113 assert.Equal(t, originRemote.Repo.RepoHost(), got.RepoHost())
1114 })
1116 t.Run("Consult the network, one forked project, get upstream", func(t *testing.T) {
1117 localRem := rem()
1119 originRemote := &Remote{
1120 Remote: &git.Remote{Name: "origin"},
1121 Repo: NewWithHost("maxice8", "glab", "gitlab.com"),
1124 originNetwork := gitlab.Project{
1125 ID: 2,
1126 PathWithNamespace: "maxice8/glab",
1127 HTTPURLToRepo: "https://gitlab.com/maxice8/glab",
1128 ForkedFromProject: &gitlab.ForkParent{
1129 ID: 1,
1130 HTTPURLToRepo: "https://gitlab.com/profclems/glab",
1131 PathWithNamespace: "profclems/glab",
1132 },
1135 localRem.remotes = Remotes{originRemote}
1136 localRem.network = []gitlab.Project{originNetwork}
1138 // Mock the prompt
1139 c := ugh.New(t)
1140 c.Expect(ugh.SelectRegexp("Which should be the head repository")).
1141 Do(ugh.SelectIndex(0))
1142 ios, cleanup := testIOStreamsWithConsole(t, c)
1143 t.Cleanup(cleanup)
1144 got, err := localRem.HeadRepo(t.Context(), ios)
1145 require.NoError(t, err)
1147 assert.Equal(t, "profclems/glab", got.FullName())
1148 assert.Equal(t, "gitlab.com", got.RepoHost())
1149 })
1151 t.Run("Host mismatch: API host differs from git remote host", func(t *testing.T) {
1152 // This test verifies our fix for the host mismatch bug
1153 // where the API returns a different host than the git remote
1154 // Git remote uses git.example.com, but API returns api.example.com
1155 localRem := &ResolvedRemotes{
1156 remotes: Remotes{
1157 &Remote{
1158 Remote: &git.Remote{
1159 Name: "origin",
1160 },
1161 Repo: NewWithHost("owner", "repo", "git.example.com"), // Git remote uses git host
1162 },
1163 },
1164 apiClient: &gitlab.Client{},
1165 network: []gitlab.Project{
1167 ID: 1,
1168 PathWithNamespace: "owner/repo",
1169 HTTPURLToRepo: "https://api.example.com/owner/repo.git", // API returns api.example.com, different from git remote's git.example.com
1170 },
1171 },
1174 // Override git.SetRemoteResolution so it doesn't mess with the user configs
1175 originalSetRemoteResolution := git.SetRemoteResolution
1176 defer func() {
1177 git.SetRemoteResolution = originalSetRemoteResolution
1178 }()
1179 git.SetRemoteResolution = func(_, _ string) error {
1180 return nil
1183 // Override api.GetProject so it doesn't mess with other tests
1184 originalGetProject := api.GetProject
1185 defer func() {
1186 api.GetProject = originalGetProject
1187 }()
1188 api.GetProject = func(_ *gitlab.Client, projectID any) (*gitlab.Project, error) {
1189 p := &gitlab.Project{
1190 PathWithNamespace: fmt.Sprint(projectID),
1191 HTTPURLToRepo: "https://api.example.com/owner/repo.git", // API returns api.example.com, different from git remote's git.example.com
1193 return p, nil
1196 ios := iostreams.New(iostreams.WithStdout(io.Discard, true), iostreams.WithStderr(io.Discard, true))
1198 got, err := localRem.HeadRepo(t.Context(), ios)
1199 require.NoError(t, err)
1201 // The fix should ensure we use the git remote host, not the API host
1202 assert.Equal(t, "owner/repo", got.FullName())
1203 assert.Equal(t, "git.example.com", got.RepoHost()) // Should use git remote host, not API host
1204 })
Diagnostics6 git calls · 272 ms
CallStatusSizeTime0272 ms
discover200185 B2 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 KiB2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=59849
git.response.cache=UPDATING
git.response.duration_ms=2
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=3
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
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit3 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=3
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:0200314 B · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=265
git.response.bytes=314
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=93a3fb44940eceae81f0a58fd4df1d50fbd7ccb5
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=314
git.pkt.payload.max=287
git.sideband.band1.bytes=287
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=287
git.pack.trailer=0a0d545706824b859dbb83ba13169780ef407392
Open pack map
fetch2004.2 KiB265 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=4274
git.response.cache=MISS
git.response.duration_ms=265
git.fetch.wants=7c23ea9252526179298d88e74b7a68f3b76a13b3
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=4274
git.pkt.payload.max=4247
git.sideband.band1.bytes=4247
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
a5e2e21168cb4af4
Request
3e258a9e…
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