GitLabgitlab-org

cli

main
ply6 git calls242 ms102 KiB3 cachedprotocol v2
630 lines18 KiBRaw
1package cmdutils
3import (
4 "context"
5 "errors"
6 "fmt"
7 "io"
8 "os"
9 "path/filepath"
10 "slices"
11 "strconv"
12 "strings"
13 "time"
15 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
17 "gitlab.com/gitlab-org/cli/internal/api"
18 "gitlab.com/gitlab-org/cli/internal/config"
19 "gitlab.com/gitlab-org/cli/internal/git"
20 "gitlab.com/gitlab-org/cli/internal/glrepo"
21 "gitlab.com/gitlab-org/cli/internal/iostreams"
22 "gitlab.com/gitlab-org/cli/internal/utils"
25const (
26 IssueTemplate = "issue_templates"
27 MergeRequestTemplate = "merge_request_templates"
30// TemplateSelectionFunc is a callback function that returns template contents.
31// It allows each command to customize its template selection logic.
32type TemplateSelectionFunc func(ctx context.Context) (string, error)
34// HandleDescriptionEditor handles the -d- flag by optionally showing template selection
35// and then opening an external editor with the template contents.
36// If templateSelector is nil, no template selection is shown (empty editor).
37func HandleDescriptionEditor(ctx context.Context, description *string, io *iostreams.IOStreams, cfg func() config.Config, templateSelector TemplateSelectionFunc) error {
38 if *description != "-" {
39 return nil // Not using -d- flag, nothing to do
40 }
42 var templateContents string
43 var err error
45 // If a template selector is provided, use it to get template contents
46 if templateSelector != nil {
47 templateContents, err = templateSelector(ctx)
48 if err != nil {
49 return err
50 }
51 }
53 // Get the configured editor
54 editor, err := GetEditor(cfg)
55 if err != nil {
56 return err
57 }
59 // Open the editor with template contents
60 return io.DirectEditor(ctx, description, templateContents, editor)
63var listLabels = func(client *gitlab.Client, projectID any, opts *gitlab.ListLabelsOptions) ([]*gitlab.Label, error) {
64 labels, _, err := client.Labels.ListLabels(projectID, opts)
65 return labels, err
68var projectMilestoneByTitle = func(client *gitlab.Client, projectID any, name string) (*gitlab.Milestone, error) {
69 opts := &gitlab.ListMilestonesOptions{Title: new(name), IncludeParentMilestones: new(true)}
71 if opts.PerPage == 0 {
72 opts.PerPage = api.DefaultListLimit
73 }
75 milestones, _, err := client.Milestones.ListMilestones(projectID, opts)
76 if err != nil {
77 return nil, err
78 }
80 if len(milestones) != 1 {
81 return nil, fmt.Errorf("failed to find milestone by title: %s", name)
82 }
84 return milestones[0], nil
87var listProjectMembers = func(ctx context.Context, client *gitlab.Client, projectID any, opts *gitlab.ListProjectMembersOptions) ([]*gitlab.ProjectMember, error) {
88 // Set a timeout to prevent hanging on very large projects
89 ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
90 defer cancel()
92 return gitlab.ScanAndCollect(func(p gitlab.PaginationOptionFunc) ([]*gitlab.ProjectMember, *gitlab.Response, error) {
93 return client.ProjectMembers.ListAllProjectMembers(projectID, opts, p, gitlab.WithContext(ctx))
94 })
97// LoadGitLabTemplate loads a description template. A bare name is looked up
98// in `.gitlab/<tmplType>/` of the working git directory, following
99// https://docs.gitlab.com/user/project/description_templates/#set-a-default-template-for-merge-requests-and-issues,
100// and returns an empty string when missing.
101//
102// GitLab only reads templates directly under `.gitlab/<tmplType>/`, so a name
103// that is absolute or contains a path separator is read as a file path
104// instead, and a missing file is an error.
105//
106// TODO: load from remote repository if repo is overridden by -R flag
107func LoadGitLabTemplate(tmplType, tmplName string) (string, error) {
108 if filepath.IsAbs(tmplName) || strings.ContainsAny(tmplName, "/"+string(filepath.Separator)) {
109 return loadTemplateFile(tmplName)
110 }
112 wdir, err := git.ToplevelDir()
113 if err != nil {
114 return "", err
115 }
117 if !strings.HasSuffix(tmplName, ".md") {
118 tmplName += ".md"
119 }
121 tmplFile := filepath.Join(wdir, ".gitlab", tmplType, tmplName)
122 f, err := os.Open(tmplFile)
123 if os.IsNotExist(err) {
124 return "", nil
125 } else if err != nil {
126 return "", err
127 }
128 defer f.Close()
130 tmpl, err := io.ReadAll(f)
131 if err != nil {
132 return "", err
133 }
135 return strings.TrimSpace(string(tmpl)), nil
138func loadTemplateFile(path string) (string, error) {
139 if rest, ok := strings.CutPrefix(path, "~/"); ok {
140 home, err := os.UserHomeDir()
141 if err != nil {
142 return "", err
143 }
144 path = filepath.Join(home, rest)
145 }
147 tmpl, err := os.ReadFile(path)
148 if err != nil {
149 return "", fmt.Errorf("failed to read template file: %w", err)
150 }
152 content := strings.TrimSpace(string(tmpl))
153 if content == "" {
154 return "", fmt.Errorf("template file %q is empty", path)
155 }
157 return content, nil
160func ListGitLabTemplates(tmplType string) ([]string, error) {
161 wdir, err := git.ToplevelDir()
162 if err != nil {
163 return []string{}, nil //nolint:nilerr // Local templates remain optional outside a Git repository.
164 }
165 tmplFolder := filepath.Join(wdir, ".gitlab", tmplType)
166 var files []string
167 f, err := os.Open(tmplFolder)
168 if os.IsNotExist(err) {
169 return files, nil
170 }
171 if err != nil {
172 return nil, err
173 }
174 fileNames, err := f.Readdirnames(-1)
175 err = errors.Join(err, f.Close())
176 if err != nil {
177 return nil, err
178 }
180 for _, file := range fileNames {
181 if strings.HasPrefix(file, ".") || !strings.HasSuffix(file, ".md") {
182 continue
183 }
184 files = append(files, strings.TrimSuffix(file, ".md"))
185 }
186 slices.Sort(files)
187 return files, nil
190func GetEditor(cf func() config.Config) (string, error) {
191 cfg := cf()
192 // will search in the order glab_editor, visual, editor first from the env before the config file
193 editorCommand, _ := cfg.Get("", "editor")
195 return editorCommand, nil
198func EditorPrompt(ctx context.Context, io *iostreams.IOStreams, response *string, question, templateContent, editorCommand string) error {
199 defaultBody := *response
200 if templateContent != "" {
201 if defaultBody != "" {
202 // prevent excessive newlines between default body and template
203 defaultBody = strings.TrimRight(defaultBody, "\n")
204 defaultBody += "\n\n"
205 }
206 defaultBody += templateContent
207 }
209 // Use DirectEditor to directly open the external editor with the content
210 err := io.DirectEditor(ctx, response, defaultBody, editorCommand)
211 if err != nil {
212 return err
213 }
214 if *response == "" {
215 *response = defaultBody
216 }
217 return nil
220type GetTextUsingEditor func(ctx context.Context, editor, tmpFileName, content string) (string, error)
222func LabelsPrompt(ctx context.Context, ios *iostreams.IOStreams, response *[]string, apiClient *gitlab.Client, repoRemote *glrepo.Remote) error {
223 labelOpts := &gitlab.ListLabelsOptions{}
224 labelOpts.PerPage = 100
225 labels, err := listLabels(apiClient, repoRemote.FullName(), labelOpts)
226 if err != nil {
227 return err
228 }
230 if len(labels) != 0 {
231 var labelOptions []string
233 for i := range labels {
234 labelOptions = append(labelOptions, labels[i].Name)
235 }
237 var selectedLabels []string
238 err = ios.MultiSelect(ctx, &selectedLabels, "Select labels", labelOptions)
239 if err != nil {
240 return err
241 }
242 *response = append(*response, selectedLabels...)
243 return nil
244 }
246 var responseString string
247 err = ios.Input(ctx, &responseString, "Label(s) (comma-separated)", "", nil)
248 if err != nil {
249 return err
250 }
251 if responseString != "" {
252 *response = append(*response, strings.Split(responseString, ",")...)
253 }
254 return nil
257func MilestonesPrompt(ctx context.Context, response *int64, apiClient *gitlab.Client, repoRemote *glrepo.Remote, ios *iostreams.IOStreams) error {
258 var milestoneOptions []string
259 milestoneMap := map[string]int64{}
261 lOpts := &api.ListMilestonesOptions{
262 IncludeParentMilestones: new(true),
263 State: new("active"),
264 PerPage: 100,
265 }
266 milestones, err := api.ListAllMilestones(apiClient, repoRemote.FullName(), lOpts)
267 if err != nil {
268 return err
269 }
270 if len(milestones) == 0 {
271 fmt.Fprintln(ios.StdErr, "No active milestones exist for this project.")
272 return nil
273 }
275 for i := range milestones {
276 milestoneOptions = append(milestoneOptions, milestones[i].Title)
277 milestoneMap[milestones[i].Title] = milestones[i].ID
278 }
280 var selectedMilestone string
281 err = ios.Select(ctx, &selectedMilestone, "Select milestone", milestoneOptions)
282 if err != nil {
283 return err
284 }
285 *response = milestoneMap[selectedMilestone]
287 return nil
290// GroupMemberLevel maps a number representing the access level to a string shown to the
291// user.
292// API docs:
293// https://docs.gitlab.com/api/group_members/
294var GroupMemberLevel = map[int]string{
295 0: "no access",
296 5: "minimal access",
297 10: "guest",
298 20: "reporter",
299 30: "developer",
300 40: "maintainer",
301 50: "owner",
304// UsersPrompt creates a multi-selection prompt of all the users above the given access level
305// for the remote referenced by the `*glrepo.Remote`.
306//
307// `role` will appear on the prompt to keep the user informed of the reason of the selection.
308func UsersPrompt(ctx context.Context, response *[]string, apiClient *gitlab.Client, repoRemote *glrepo.Remote, io *iostreams.IOStreams, minimumAccessLevel int, role string) error {
309 var userOptions []string
310 userMap := map[string]string{}
312 lOpts := &gitlab.ListProjectMembersOptions{
313 ListOptions: gitlab.ListOptions{
314 PerPage: 100,
315 },
316 }
318 if io != nil {
319 io.StartSpinner("Loading project members...")
320 }
322 members, err := listProjectMembers(ctx, apiClient, repoRemote.FullName(), lOpts)
323 if err != nil {
324 if io != nil {
325 io.StopSpinner("")
326 }
327 return err
328 }
330 for i := range members {
331 if members[i].AccessLevel >= gitlab.AccessLevelValue(minimumAccessLevel) {
332 userOptions = append(userOptions, fmt.Sprintf("%s (%s)",
333 members[i].Username,
334 GroupMemberLevel[int(members[i].AccessLevel)],
335 ))
336 userMap[fmt.Sprintf("%s (%s)", members[i].Username, GroupMemberLevel[int(members[i].AccessLevel)])] = members[i].Username
337 }
338 }
340 // Stop spinner before showing the prompt
341 if io != nil {
342 io.StopSpinner("")
343 }
345 if len(userOptions) == 0 {
346 fmt.Fprintf(io.StdErr, "Couldn't fetch any members with minimum permission level %d.\n", minimumAccessLevel)
347 return nil
348 }
350 var selectedUsers []string
351 err = io.MultiSelect(ctx, &selectedUsers, fmt.Sprintf("Select %s", role), userOptions)
352 if err != nil {
353 return err
354 }
355 for _, x := range selectedUsers {
356 *response = append(*response, userMap[x])
357 }
359 return nil
362type Action int
364const (
365 NoAction Action = iota
366 SubmitAction
367 PreviewAction
368 AddMetadataAction
369 CancelAction
370 EditCommitMessageAction
373func ConfirmSubmission(ctx context.Context, ios *iostreams.IOStreams, allowAddMetadata bool) (Action, error) {
374 const (
375 submitLabel = "Submit"
376 previewLabel = "Continue in browser"
377 addMetadataLabel = "Add metadata"
378 cancelLabel = "Cancel"
379 )
381 options := []string{submitLabel, previewLabel}
382 if allowAddMetadata {
383 options = append(options, addMetadataLabel)
384 }
385 options = append(options, cancelLabel)
387 var confirmAnswer string
388 err := ios.Select(ctx, &confirmAnswer, "What's next?", options)
389 if err != nil {
390 return -1, fmt.Errorf("could not prompt: %w", err)
391 }
393 switch confirmAnswer {
394 case submitLabel:
395 return SubmitAction, nil
396 case previewLabel:
397 return PreviewAction, nil
398 case addMetadataLabel:
399 return AddMetadataAction, nil
400 case cancelLabel:
401 return CancelAction, nil
402 default:
403 return -1, fmt.Errorf("invalid value: %s", confirmAnswer)
404 }
407const (
408 AddLabelAction Action = iota
409 AddAssigneeAction
410 AddMilestoneAction
413func PickMetadata(ctx context.Context, io *iostreams.IOStreams) ([]Action, error) {
414 const (
415 labelsLabel = "labels"
416 assigneeLabel = "assignees"
417 milestoneLabel = "milestones"
418 )
420 options := []string{
421 labelsLabel,
422 assigneeLabel,
423 milestoneLabel,
424 }
426 var confirmAnswers []string
427 err := io.MultiSelect(ctx, &confirmAnswers, "Which metadata types to add?", options)
428 if err != nil {
429 return nil, fmt.Errorf("could not prompt: %w", err)
430 }
432 var pickedActions []Action
434 for _, x := range confirmAnswers {
435 switch x {
436 case labelsLabel:
437 pickedActions = append(pickedActions, AddLabelAction)
438 case assigneeLabel:
439 pickedActions = append(pickedActions, AddAssigneeAction)
440 case milestoneLabel:
441 pickedActions = append(pickedActions, AddMilestoneAction)
442 }
443 }
445 return pickedActions, nil
448// IDsFromUsers collects all user IDs from a slice of users
449func IDsFromUsers(users []*gitlab.User) *[]int64 {
450 ids := make([]int64, len(users))
451 for i, user := range users {
452 ids[i] = user.ID
453 }
454 return &ids
457func ParseMilestone(apiClient *gitlab.Client, repo glrepo.Interface, milestoneTitle string) (int64, error) {
458 if milestoneID, err := strconv.Atoi(milestoneTitle); err == nil {
459 return int64(milestoneID), nil
460 }
462 milestone, err := projectMilestoneByTitle(apiClient, repo.FullName(), milestoneTitle)
463 if err != nil {
464 return 0, err
465 }
467 return milestone.ID, nil
470// UserAssignments holds 3 slice strings that represent which assignees should be added, removed, and replaced
471// helper functions are also provided
472type UserAssignments struct {
473 ToAdd []string
474 ToRemove []string
475 ToReplace []string
476 AssignmentType UserAssignmentType
479type UserAssignmentType int
481const (
482 AssigneeAssignment UserAssignmentType = iota
483 ReviewerAssignment
486// ParseAssignees takes a String Slice and splits them into 3 Slice Strings based on
487// the first character of a string.
488//
489// '+' is put in the first slice, '!' and '-' in the second slice and all other cases
490// in the third slice.
491//
492// The 3 String slices are returned regardless if anything was put it in or not the user
493// is responsible for checking the length to see if anything is in it
494func ParseAssignees(assignees []string) *UserAssignments {
495 ua := UserAssignments{
496 AssignmentType: AssigneeAssignment,
497 }
499 for _, assignee := range assignees {
500 runes := []rune(assignee)
501 if len(runes) == 0 {
502 continue
503 }
504 switch string(runes[0]) {
505 case "+":
506 ua.ToAdd = append(ua.ToAdd, string(runes[1:]))
507 case "!", "-":
508 ua.ToRemove = append(ua.ToRemove, string(runes[1:]))
509 default:
510 ua.ToReplace = append(ua.ToReplace, assignee)
511 }
512 }
513 return &ua
516// VerifyAssignees is a method for UserAssignments that checks them for validity
517func (ua *UserAssignments) VerifyAssignees() error {
518 // Fail if relative and absolute assignees were given, there is no reason to mix them.
519 if len(ua.ToReplace) != 0 && (len(ua.ToAdd) != 0 || len(ua.ToRemove) != 0) {
520 return errors.New("mixing relative (+,!,-) and absolute assignments is forbidden")
521 }
523 if m := utils.CommonElementsInStringSlice(ua.ToAdd, ua.ToRemove); len(m) != 0 {
524 return fmt.Errorf("%s %q present in both add and remove, which is forbidden",
525 utils.Pluralize(len(m), "element"),
526 strings.Join(m, " "))
527 }
528 return nil
531// UsersFromReplaces converts all users from the `ToReplace` member of the struct into
532// an Slice of String representing the Users' IDs, it also takes a Slice of Strings and
533// writes a proper action message to it
534func (ua *UserAssignments) UsersFromReplaces(apiClient *gitlab.Client, actions []string) (*[]int64, []string, error) {
535 users, err := api.UsersByNames(apiClient, ua.ToReplace)
536 if err != nil {
537 return &[]int64{}, actions, err
538 }
539 var usernames []string
540 for i := range users {
541 usernames = append(usernames, fmt.Sprintf("@%s", users[i].Username))
542 }
543 if len(usernames) != 0 {
544 if ua.AssignmentType == ReviewerAssignment {
545 actions = append(actions, fmt.Sprintf("requested review from %q", strings.Join(usernames, " ")))
546 } else {
547 actions = append(actions, fmt.Sprintf("assigned to %q", strings.Join(usernames, " ")))
548 }
549 }
550 return IDsFromUsers(users), actions, nil
553// UsersFromAddRemove works with both `ToAdd` and `ToRemove` members to produce a Slice of Ints that
554// represents the final collection of IDs to assigned.
555//
556// It starts by getting all IDs already assigned, but ignoring ones present in `ToRemove`, it then
557// converts all `usernames` in `ToAdd` into IDs by using the `api` package and adds them to the
558// IDs to be assigned
559func (ua *UserAssignments) UsersFromAddRemove(
560 issueAssignees []*gitlab.IssueAssignee,
561 mergeRequestAssignees []*gitlab.BasicUser,
562 apiClient *gitlab.Client,
563 actions []string,
564) (*[]int64, []string, error) {
565 var assignedIDs []int64
566 var usernames []string
568 // Only one of those is required
569 if mergeRequestAssignees != nil && issueAssignees != nil {
570 return &[]int64{}, actions, errors.New("issueAssignees and mergeRequestAssignees can't both be set")
571 }
573 // Path for Issues
574 for i := range issueAssignees {
575 // Only store them in assigneedIDs if they are not marked for removal
576 if !utils.PresentInStringSlice(ua.ToRemove, issueAssignees[i].Username) {
577 assignedIDs = append(assignedIDs, issueAssignees[i].ID)
578 }
579 }
581 // Path for Merge Requests
582 for i := range mergeRequestAssignees {
583 // Only store them in assigneedIDs if they are not marked for removal
584 if !utils.PresentInStringSlice(ua.ToRemove, mergeRequestAssignees[i].Username) {
585 assignedIDs = append(assignedIDs, mergeRequestAssignees[i].ID)
586 }
587 }
589 // Add action string
590 if len(ua.ToRemove) != 0 {
591 for _, x := range ua.ToRemove {
592 usernames = append(usernames, fmt.Sprintf("@%s", x))
593 }
594 if ua.AssignmentType == ReviewerAssignment {
595 actions = append(actions, fmt.Sprintf("removed review request for %q.", strings.Join(usernames, " ")))
596 } else {
597 actions = append(actions, fmt.Sprintf("unassigned %q", strings.Join(usernames, " ")))
598 }
599 }
601 if len(ua.ToAdd) != 0 {
602 users, err := api.UsersByNames(apiClient, ua.ToAdd)
603 if err != nil {
604 return nil, nil, err
605 }
607 for i := range users {
608 assignedIDs = append(assignedIDs, users[i].ID)
609 }
611 // Reset the usernames array because it might have been used by `unassignedUsers`
612 usernames = []string{}
614 for _, x := range ua.ToAdd {
615 usernames = append(usernames, fmt.Sprintf("@%s", x))
616 }
617 if ua.AssignmentType == ReviewerAssignment {
618 actions = append(actions, fmt.Sprintf("requested review from %q.", strings.Join(usernames, " ")))
619 } else {
620 actions = append(actions, fmt.Sprintf("assigned %q", strings.Join(usernames, " ")))
621 }
622 }
624 // That means that all assignees were removed but we can't pass an empty Slice of Ints so
625 // pass the documented value of 0
626 if len(assignedIDs) == 0 {
627 assignedIDs = []int64{0}
628 }
629 return &assignedIDs, actions, nil
Diagnostics6 git calls · 242 ms
CallStatusSizeTime0242 ms
discover200185 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=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 KiB4 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=4
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1020032 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:02001.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=3
git.response.bytes=1238
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=c10f4b8b760c3fec7ed8ca85e428d5bc523f8e17
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=1238
git.pkt.payload.max=1211
git.sideband.band1.bytes=1211
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=1211
git.pack.trailer=7373aa350f2a611db7d4116eb1450c92f18a27ca
Open pack map
fetch2005.5 KiB231 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=231
git.response.bytes=5622
git.response.cache=MISS
git.response.duration_ms=231
git.fetch.wants=03437b15268f3536d531ef4cc4817fac5ddfb688
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=5622
git.pkt.payload.max=5595
git.sideband.band1.bytes=5595
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
a5e1228def9f7fd8
Request
943e2045…
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