GitLabgitlab-org
cli
main
1package mrutils
3import (
4 "context"
5 "errors"
6 "fmt"
7 "regexp"
8 "slices"
9 "sort"
10 "strconv"
11 "strings"
12 "time"
14 "golang.org/x/sync/errgroup"
16 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
18 "gitlab.com/gitlab-org/cli/internal/api"
19 "gitlab.com/gitlab-org/cli/internal/cmdutils"
20 "gitlab.com/gitlab-org/cli/internal/dbg"
21 "gitlab.com/gitlab-org/cli/internal/git"
22 "gitlab.com/gitlab-org/cli/internal/glrepo"
23 "gitlab.com/gitlab-org/cli/internal/iostreams"
24 "gitlab.com/gitlab-org/cli/internal/tableprinter"
25 "gitlab.com/gitlab-org/cli/internal/utils"
26)
28type MRCheckErrOptions struct {
29 // Draft: check and return err if merge request is a DRAFT
30 Draft bool
31 // Closed: check and return err if merge request is closed
32 Closed bool
33 // Merged: check and return err if merge request is already merged
34 Merged bool
35 // Opened: check and return err if merge request is already opened
36 Opened bool
37 // Conflict: check and return err if there are merge conflicts
38 Conflict bool
39 // PipelineStatus: check and return err pipeline did not succeed and it is required before merging
40 PipelineStatus bool
41 // MergePermitted: check and return err if user is not authorized to merge
42 MergePermitted bool
43 // Subscribed: check and return err if user is already subscribed to MR
44 Subscribed bool
45 // Unsubscribed: check and return err if user is already unsubscribed to MR
46 Unsubscribed bool
47 // MergePrivilege: check and return err if user is not authorized to merge
48 MergePrivilege bool
49}
51type MrOptions struct {
52 BaseRepo glrepo.Interface
53 Branch string
54 State string
55 PromptEnabled bool
56}
58var multipleMRSelectQuestion = "Multiple merge requests exist for this branch. Select one:"
60// MRCheckErrors checks and return merge request errors specified in MRCheckErrOptions{}
61func MRCheckErrors(mr *gitlab.MergeRequest, err MRCheckErrOptions) error {
62 if mr.Draft && err.Draft {
63 return fmt.Errorf("this merge request is still a draft; run `glab mr update %d --ready` to mark it as ready for review", mr.IID)
64 }
66 dbg.Debug("MergeWhenPipelineSucceeds:", strconv.FormatBool(mr.MergeWhenPipelineSucceeds))
67 dbg.Debug("DetailedMergeStatus:", mr.DetailedMergeStatus)
69 if mr.DetailedMergeStatus == "ci_must_pass" && err.PipelineStatus {
70 return fmt.Errorf("this merge request requires a passing pipeline before merging")
71 }
73 if mr.MergeWhenPipelineSucceeds && err.PipelineStatus && mr.Pipeline != nil {
74 if mr.Pipeline.Status != "success" {
75 return fmt.Errorf("the pipeline for this merge request has failed; it must succeed before merging")
76 }
77 }
79 if mr.State == "merged" && err.Merged {
80 return fmt.Errorf("this merge request has already been merged")
81 }
83 if mr.State == "closed" && err.Closed {
84 return fmt.Errorf("this merge request has been closed")
85 }
87 if mr.State == "opened" && err.Opened {
88 return fmt.Errorf("this merge request is already open")
89 }
91 if mr.Subscribed && err.Subscribed {
92 return fmt.Errorf("you are already subscribed to this merge request")
93 }
95 if !mr.Subscribed && err.Unsubscribed {
96 return fmt.Errorf("you are not subscribed to this merge request")
97 }
99 if err.MergePrivilege && !mr.User.CanMerge {
100 return fmt.Errorf("you do not have permission to merge this merge request")
101 }
103 if err.Conflict && mr.HasConflicts {
104 return fmt.Errorf("merge conflicts exist; resolve the conflicts and try again, or merge locally")
105 }
107 return nil
108}
110func DisplayMR(c *iostreams.ColorPalette, mr *gitlab.BasicMergeRequest, isTTY bool) string {
111 mrID := MRState(c, mr)
112 if isTTY {
113 return fmt.Sprintf("%s %s (%s)\n %s\n", mrID, mr.Title, mr.SourceBranch, mr.WebURL)
114 } else {
115 return mr.WebURL
116 }
117}
119func MRState(c *iostreams.ColorPalette, m *gitlab.BasicMergeRequest) string {
120 switch m.State {
121 case "opened":
122 return c.Green(fmt.Sprintf("!%d", m.IID))
123 case "merged":
124 return c.Magenta(fmt.Sprintf("!%d", m.IID))
125 default:
126 return c.Red(fmt.Sprintf("!%d", m.IID))
127 }
128}
130func DisplayAllMRs(streams *iostreams.IOStreams, mrs []*gitlab.BasicMergeRequest) string {
131 c := streams.Color()
132 table := tableprinter.NewTablePrinter()
133 table.SetIsTTY(streams.IsOutputTTY())
134 for _, m := range mrs {
135 table.AddCell(streams.Hyperlink(MRState(c, m), m.WebURL))
136 var ref string
137 if m.References != nil {
138 ref = m.References.Full
139 }
140 table.AddCell(ref)
141 table.AddCell(m.Title)
142 table.AddCell(c.Cyan(fmt.Sprintf("(%s) ← (%s)", m.TargetBranch, m.SourceBranch)))
143 table.EndRow()
144 }
146 return table.Render()
147}
149// MRFromArgs is wrapper around MRFromArgsWithOpts without any custom options
150func MRFromArgs(ctx context.Context, f cmdutils.Factory, args []string, state string) (*gitlab.MergeRequest, glrepo.Interface, error) {
151 return MRFromArgsWithOpts(ctx, f, args, &gitlab.GetMergeRequestsOptions{}, state)
152}
154// mrTarget is a merge request identified from command-line arguments, before
155// the merge request itself has been fetched from the API. Exactly one of mrID
156// and branch is set: mrID when the argument was an ID or a merge request URL,
157// branch otherwise.
158type mrTarget struct {
159 client *gitlab.Client
160 baseRepo glrepo.Interface
161 mrID int
162 branch string
163}
165// resolveMRTarget interprets the command-line arguments without calling the API.
166// It falls back to the current branch when no argument is given.
167func resolveMRTarget(f cmdutils.Factory, args []string) (*mrTarget, error) {
168 var mrID int
170 client, err := f.GitLabClient()
171 if err != nil {
172 return nil, err
173 }
175 baseRepo, err := f.BaseRepo()
176 if err != nil {
177 return nil, err
178 }
180 var branch string
182 if len(args) > 0 {
183 // First, try to parse as a GitLab MR URL
184 if urlMRID, urlRepo := cmdutils.ParseMergeRequestFromURL(args[0], f.DefaultHostname(), f.Config()); urlMRID != 0 {
185 mrID = urlMRID
186 // Update client to use the hostname from the URL if it's different
187 if urlRepo.RepoHost() != baseRepo.RepoHost() {
188 apiClient, err := f.ApiClient(urlRepo.RepoHost())
189 if err != nil {
190 return nil, fmt.Errorf("failed to connect to GitLab instance %s from URL (%s): %w", urlRepo.RepoHost(), args[0], err)
191 }
192 client = apiClient.Lab()
193 }
194 baseRepo = urlRepo
195 } else {
196 // If not a URL, try to parse as an integer (with optional ! prefix)
197 mrID, err = strconv.Atoi(strings.TrimPrefix(args[0], "!"))
198 if err != nil {
199 branch = args[0]
200 } else if mrID == 0 { // to check for cases where the user explicitly specified mrID to be zero
201 return nil, fmt.Errorf("invalid merge request ID provided")
202 }
203 }
204 }
206 if branch == "" && mrID == 0 {
207 branch, err = f.Branch()
208 if err != nil {
209 return nil, err
210 }
211 }
213 return &mrTarget{client: client, baseRepo: baseRepo, mrID: mrID, branch: branch}, nil
214}
216// MRFromArgsWithOpts gets MR with custom request options passed down to it
217func MRFromArgsWithOpts(
218 ctx context.Context,
219 f cmdutils.Factory,
220 args []string,
221 opts *gitlab.GetMergeRequestsOptions,
222 state string,
223) (*gitlab.MergeRequest, glrepo.Interface, error) {
224 target, err := resolveMRTarget(f, args)
225 if err != nil {
226 return nil, nil, err
227 }
229 mrID := target.mrID
230 if mrID == 0 {
231 basicMR, err := target.mrForBranch(ctx, f.IO(), state)
232 if err != nil {
233 return nil, nil, err
234 }
235 mrID = int(basicMR.IID)
236 }
237 mr, err := api.GetMR(target.client, target.baseRepo.FullName(), int64(mrID), opts)
238 if err != nil {
239 return nil, nil, fmt.Errorf("failed to get merge request %d: %w", mrID, err)
240 }
242 return mr, target.baseRepo, nil
243}
245// MRWebURLFromArgs resolves the web URL of a merge request using as few API
246// calls as possible. When the merge request is identified by branch, the URL is
247// taken from the list response instead of fetching the merge request again.
248func MRWebURLFromArgs(ctx context.Context, f cmdutils.Factory, args []string, state string) (string, glrepo.Interface, error) {
249 target, err := resolveMRTarget(f, args)
250 if err != nil {
251 return "", nil, err
252 }
254 if target.mrID == 0 {
255 basicMR, err := target.mrForBranch(ctx, f.IO(), state)
256 if err != nil {
257 return "", nil, err
258 }
259 return basicMR.WebURL, target.baseRepo, nil
260 }
262 mr, err := api.GetMR(target.client, target.baseRepo.FullName(), int64(target.mrID), &gitlab.GetMergeRequestsOptions{})
263 if err != nil {
264 return "", nil, fmt.Errorf("failed to get merge request %d: %w", target.mrID, err)
265 }
266 return mr.WebURL, target.baseRepo, nil
267}
269func (t *mrTarget) mrForBranch(ctx context.Context, io *iostreams.IOStreams, state string) (*gitlab.BasicMergeRequest, error) {
270 return GetMRForBranch(ctx, io, t.client, MrOptions{t.baseRepo, t.branch, state, io.PromptEnabled()})
271}
273func MRsFromArgs(ctx context.Context, f cmdutils.Factory, args []string, state string) ([]*gitlab.MergeRequest, glrepo.Interface, error) {
274 if len(args) <= 1 {
275 var arrIDs []string
276 if len(args) == 1 {
277 arrIDs = strings.Split(args[0], ",")
278 }
279 if len(arrIDs) <= 1 {
280 // If there are no args then try to auto-detect from the branch name
281 mr, baseRepo, err := MRFromArgs(ctx, f, args, state)
282 if err != nil {
283 return nil, nil, err
284 }
285 return []*gitlab.MergeRequest{mr}, baseRepo, nil
286 }
287 args = arrIDs
288 }
290 baseRepo, err := f.BaseRepo()
291 if err != nil {
292 return nil, nil, err
293 }
295 errGroup, ctx := errgroup.WithContext(ctx)
296 errGroup.SetLimit(api.MaxConcurrentRequests)
297 mrs := make([]*gitlab.MergeRequest, len(args))
298 for i, arg := range args {
299 errGroup.Go(func() error {
300 // fetching multiple MRs does not return many major params in the payload
301 // so we fetch again using the single mr endpoint
302 mr, _, err := MRFromArgs(ctx, f, []string{arg}, state)
303 if err != nil {
304 return err
305 }
306 mrs[i] = mr
307 return nil
308 })
309 }
310 if err := errGroup.Wait(); err != nil {
311 return nil, nil, err
312 }
313 return mrs, baseRepo, nil
314}
316func resolveOwnerAndBranch(potentialBranch string) (string, string) {
317 split := strings.Split(potentialBranch, ":")
318 userUsedOwnerColonBranchFormat := len(split) != 1
319 if userUsedOwnerColonBranchFormat {
320 owner, branch := split[0], split[1]
321 return owner, branch
322 }
323 owner, branch := "", split[0]
324 return owner, branch
325}
327var GetMRForBranch = func(ctx context.Context, ios *iostreams.IOStreams, apiClient *gitlab.Client, mrOpts MrOptions) (*gitlab.BasicMergeRequest, error) {
328 owner, currentBranch := resolveOwnerAndBranch(mrOpts.Branch)
330 opts := gitlab.ListProjectMergeRequestsOptions{
331 SourceBranch: new(currentBranch),
332 }
334 userAskedForSpecificState := mrOpts.State != "" && mrOpts.State != "any"
335 if userAskedForSpecificState {
336 opts.State = new(mrOpts.State)
337 }
339 mrs, err := api.ListMRs(apiClient, mrOpts.BaseRepo.FullName(), &opts)
340 if err != nil {
341 return nil, fmt.Errorf("failed to get open merge request for %q: %w", currentBranch, err)
342 }
344 if len(mrs) == 0 {
345 return nil, fmt.Errorf("no open merge request available for %q", currentBranch)
346 }
348 userAskedForSpecificOwner := owner != ""
349 if userAskedForSpecificOwner {
350 for i := range mrs {
351 mr := mrs[i]
352 matchFound := mr.Author.Username == owner
353 if matchFound {
354 return mr, nil
355 }
356 }
357 return nil, fmt.Errorf("no open merge request available for %q owned by @%s", currentBranch, owner)
358 }
360 // This is done after the 'OWNER:' check because we don't want to give the wrong MR
361 // to someone that **explicitly** asked for a OWNER.
362 if len(mrs) == 1 {
363 return mrs[0], nil
364 }
366 // No 'OWNER:' prompt the user to pick a merge request
367 mrMap := map[string]*gitlab.BasicMergeRequest{}
368 var mrNames []string
369 for i := range mrs {
370 t := fmt.Sprintf("!%d (%s) by @%s", mrs[i].IID, currentBranch, mrs[i].Author.Username)
371 mrMap[t] = mrs[i]
372 mrNames = append(mrNames, t)
373 }
374 pickedMR := mrNames[0]
376 if !mrOpts.PromptEnabled {
377 // NO_PROMPT environment variable is set. Skip prompt and return error when multiple merge requests exist for branch.
378 err = fmt.Errorf("merge request ID number required. Possible matches:\n\n%s", strings.Join(mrNames, "\n"))
379 } else {
380 err = ios.Select(ctx, &pickedMR, multipleMRSelectQuestion, mrNames)
381 }
382 if err != nil {
383 return nil, fmt.Errorf("you must select a merge request: %w", err)
384 }
386 return mrMap[pickedMR], nil
387}
389type rebasePolling struct {
390 interval time.Duration
391 attempts int
392 // trustMergeErrorAfter is the poll after which a merge_error equal to the
393 // one from before the rebase is reported instead of treated as stale.
394 trustMergeErrorAfter int
395 wait func(context.Context, time.Duration) error
396}
398func RebaseMR(ctx context.Context, ios *iostreams.IOStreams, apiClient *gitlab.Client, repo glrepo.Interface, mr *gitlab.MergeRequest, rebaseOpts *gitlab.RebaseMergeRequestOptions) error {
399 return rebaseMR(ctx, ios, apiClient, repo, mr, rebaseOpts, rebasePolling{interval: time.Second, attempts: 300, trustMergeErrorAfter: 10, wait: waitOrDone})
400}
402// waitOrDone waits for d, or returns ctx.Err() as soon as ctx is done.
403func waitOrDone(ctx context.Context, d time.Duration) error {
404 timer := time.NewTimer(d)
405 defer timer.Stop()
406 select {
407 case <-ctx.Done():
408 return ctx.Err()
409 case <-timer.C:
410 return nil
411 }
412}
414func rebaseMR(ctx context.Context, ios *iostreams.IOStreams, apiClient *gitlab.Client, repo glrepo.Interface, mr *gitlab.MergeRequest, rebaseOpts *gitlab.RebaseMergeRequestOptions, poll rebasePolling) error {
415 ios.StartSpinner("Sending rebase request...")
416 _, err := apiClient.MergeRequests.RebaseMergeRequest(repo.FullName(), mr.IID, rebaseOpts, gitlab.WithContext(ctx))
417 if err != nil {
418 return err
419 }
420 ios.StopSpinner("")
422 opts := &gitlab.GetMergeRequestsOptions{
423 IncludeRebaseInProgress: new(true),
424 IncludeDivergedCommitsCount: new(true),
425 }
426 ios.StartSpinner("Rebase in progress...")
427 defer ios.StopSpinner("")
429 // The rebase API only queues a job, so rebase_in_progress can read false
430 // before the job starts. Only trust it once the rebase has visibly happened.
431 seenInProgress := false
432 for i := range poll.attempts {
433 if i > 0 {
434 if err := poll.wait(ctx, poll.interval); err != nil {
435 return err
436 }
437 }
438 cur, _, err := apiClient.MergeRequests.GetMergeRequest(repo.FullName(), mr.IID, opts, gitlab.WithContext(ctx))
439 if err != nil {
440 return err
441 }
442 if cur.RebaseInProgress {
443 seenInProgress = true
444 continue
445 }
446 shaChanged := mr.SHA != "" && cur.SHA != mr.SHA
447 hasMergeError := cur.MergeError != "" && cur.MergeError != "null"
448 // merge_error is not cleared when a rebase starts, so it may be stale.
449 // GitLab reports rebase_in_progress while the job is queued, so once a
450 // few polls have passed without it, a repeated error is this rebase's.
451 if !shaChanged && hasMergeError && (seenInProgress || cur.MergeError != mr.MergeError || i >= poll.trustMergeErrorAfter) {
452 return errors.New(cur.MergeError)
453 }
454 if seenInProgress || shaChanged || cur.DivergedCommitsCount == 0 {
455 ios.StopSpinner("")
456 ios.LogInfof("%s %s\n", ios.Color().GreenCheck(), "Rebase successful!")
457 return nil
458 }
459 }
460 return fmt.Errorf("timed out waiting for the rebase of merge request !%d to complete", mr.IID)
461}
463// PrintMRApprovalState renders an output to summarize the approval state of a merge request
464func PrintMRApprovalState(ios *iostreams.IOStreams, mrApprovals *gitlab.MergeRequestApprovalState) {
465 const approvedIcon = "👍"
467 c := ios.Color()
469 if mrApprovals.ApprovalRulesOverwritten {
470 ios.LogInfo(c.Yellow("Approval rules overwritten."))
471 }
472 for _, rule := range mrApprovals.Rules {
473 table := tableprinter.NewTablePrinter()
474 if rule.Approved {
475 ios.LogInfo(c.Green(fmt.Sprintf("Rule %q sufficient approvals (%d/%d required):", rule.Name, len(rule.ApprovedBy), rule.ApprovalsRequired)))
476 } else {
477 ios.LogInfo(c.Yellow(fmt.Sprintf("Rule %q insufficient approvals (%d/%d required):", rule.Name, len(rule.ApprovedBy), rule.ApprovalsRequired)))
478 }
480 eligibleApprovers := rule.EligibleApprovers
482 approvedBy := map[string]*gitlab.BasicUser{}
483 for _, by := range rule.ApprovedBy {
484 approvedBy[by.Username] = by
485 }
487 table.AddRow("Name", "Username", "Approved")
488 for _, eligibleApprover := range eligibleApprovers {
489 approved := "-"
490 source := ""
491 if _, exists := approvedBy[eligibleApprover.Username]; exists {
492 approved = approvedIcon
493 }
494 if rule.SourceRule != nil {
495 source = rule.SourceRule.RuleType
496 }
497 table.AddRow(eligibleApprover.Name, eligibleApprover.Username, approved, source)
498 delete(approvedBy, eligibleApprover.Username)
499 }
501 // sort all usernames to ensure consistent output
502 approverNames := make([]string, 0, len(approvedBy))
503 for name := range approvedBy {
504 approverNames = append(approverNames, name)
505 }
506 sort.Strings(approverNames)
508 for _, name := range approverNames {
509 approver := approvedBy[name]
510 table.AddRow(approver.Name, approver.Username, approvedIcon, "")
511 }
512 ios.LogInfo(table)
513 }
514}
516// AutofillMRFromCommits generates title and body from commit information between two branches
517func AutofillMRFromCommits(targetBranch, sourceBranch string, fillCommitBody bool) (string, string, error) {
518 commits, err := git.Commits(targetBranch, sourceBranch)
519 if err != nil {
520 // If git fails, create a simple title from branch name
521 return utils.Humanize(sourceBranch), "", nil //nolint:nilerr // intentional fallback: branch-name title when git history is unavailable
522 }
524 return GenerateMRTitleAndBody(commits, sourceBranch, fillCommitBody)
525}
527// GenerateMRTitleAndBody creates title and body from commits
528func GenerateMRTitleAndBody(commits []*git.Commit, sourceBranch string, fillCommitBody bool) (string /* title */, string /* body */, error) {
529 switch len(commits) {
530 case 0:
531 // No commits found, use branch name as fallback title
532 return utils.Humanize(sourceBranch), "", nil
533 case 1:
534 // Single commit: use commit title as MR title
535 title := commits[0].Title
537 // For single commit, always try to get the commit body (consistent with original behavior)
538 commitBody, err := git.CommitBody(commits[0].Sha)
539 if err != nil {
540 // If we can't get the commit body, fall back to the commit title
541 return title, commits[0].Title, nil //nolint:nilerr // intentional fallback: commit title as body when CommitBody fails
542 }
544 if strings.TrimSpace(commitBody) != "" {
545 return title, commitBody, nil
546 }
548 return title, commits[0].Title, nil
549 default:
550 // Multiple commits: use humanized branch name as fallback title
551 title := utils.Humanize(sourceBranch)
553 body, err := GenerateMRCommitListBody(commits, fillCommitBody)
554 if err != nil {
555 return "", "", err
556 }
558 return title, body, nil
559 }
560}
562// GenerateMRCommitListBody creates a markdown list of commits with optional commit bodies
563func GenerateMRCommitListBody(commits []*git.Commit, fillCommitBody bool) (string, error) {
564 var body strings.Builder
565 re := regexp.MustCompile(`\r?\n\n`)
567 for _, commit := range slices.Backward(commits) {
568 // adds 2 spaces for markdown line wrapping
569 fmt.Fprintf(&body, "- %s \n", commit.Title) //nolint:forbidigo // writing to a strings.Builder, not stdout/stderr
571 if fillCommitBody {
572 commitBody, err := git.CommitBody(commit.Sha)
573 if err != nil {
574 return "", fmt.Errorf("failed to get commit message for %s: %w", commit.Sha, err)
575 }
577 if strings.TrimSpace(commitBody) != "" {
578 commitBody = re.ReplaceAllString(commitBody, " \n")
579 fmt.Fprintf(&body, "%s\n", commitBody) //nolint:forbidigo // writing to a strings.Builder, not stdout/stderr
580 } else {
581 // Add extra newline when commit has no body to match original behavior
582 fmt.Fprintf(&body, "\n") //nolint:forbidigo // writing to a strings.Builder, not stdout/stderr
583 }
584 }
585 }
587 return body.String(), nil
588}
Diagnostics8 git calls · 193 ms
CallStatusSizeTime0193 ms
discover200185 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch 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
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=4273 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4273 git.pkt.payload.max=4173 git.sideband.band1.bytes=4173 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=11 git.pack.bytes=4173 git.fetch.wide.objects=11 git.fetch.wide.extra_bytes=3930 git.fetch.wide.blobs=0
fetchtree:0 · deepen 1020032 KiB · hit4 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=4 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:02001.8 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=1857 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=dce174ff8c632a19d17eea99c8a9b7c37fb2b592 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1857 git.pkt.payload.max=1830 git.sideband.band1.bytes=1830 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=1830 git.pack.trailer=fb03183b7909876778f740d196d7516811003517Open pack map
fetchtree:0200746 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=746 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=f3d413a22af5a9c2fe9aa49709b1cb36d1351a7f 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=746 git.pkt.payload.max=719 git.sideband.band1.bytes=719 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=719 git.pack.trailer=330baf80c59a4208b55120dff7dd824b7952b790Open pack map
fetchtree:0200469 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=179 git.response.bytes=469 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=6020159a68b7314d330ee4ac0f7529b651d7accc 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=469 git.pkt.payload.max=442 git.sideband.band1.bytes=442 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=442 git.pack.trailer=97b1fd715810f2e169ed93a75830c9ee2eff1fc0Open pack map
fetch2005.9 KiB179 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=6001 git.response.cache=MISS git.response.duration_ms=179 git.fetch.wants=2b63ee1ecdeab602deb5667c3bfb92e9cdce11a7 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=6001 git.pkt.payload.max=5974 git.sideband.band1.bytes=5974 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
- a5e2b6157eaecf33
- Request
- 62937ef7…
- 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