GitLabgitlab-org
cli
main
1package sync
3import (
4 "context"
5 "errors"
6 "fmt"
7 "strings"
9 "github.com/MakeNowJust/heredoc/v2"
10 "github.com/spf13/cobra"
12 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
14 "gitlab.com/gitlab-org/cli/internal/api"
15 "gitlab.com/gitlab-org/cli/internal/auth"
16 "gitlab.com/gitlab-org/cli/internal/cmdutils"
17 "gitlab.com/gitlab-org/cli/internal/commands/mr/create"
18 "gitlab.com/gitlab-org/cli/internal/commands/mr/mrutils"
19 "gitlab.com/gitlab-org/cli/internal/commands/stack/stackutils"
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/mcpannotations"
25 "gitlab.com/gitlab-org/cli/internal/text"
26)
28type options struct {
29 io *iostreams.IOStreams
30 stack git.Stack
31 target glrepo.Interface
32 source glrepo.Interface
33 labClient *gitlab.Client
34 baseRepo func() (glrepo.Interface, error)
35 remotes func() (glrepo.Remotes, error)
36 user gitlab.User
37 noVerify bool
38 skipPush bool
39 updateBase bool
40 skipMRCreation bool
41 assignees []string
42 assigneeIDs *[]int64
43 labels []string
44 reviewers []string
45 reviewerIDs *[]int64
46 template string
47 templateBody string
48}
50// max string size for MR title is ~255, but we'll add a "..."
51const maxMRTitleSize = 252
53const (
54 BranchIsBehind = "Your branch is behind"
55 BranchHasDiverged = "have diverged"
56 NothingToCommit = "nothing to commit"
57 mergedStatus = "merged"
58 closedStatus = "closed"
59)
61func NewCmdSyncStack(f cmdutils.Factory, gr git.GitRunner) *cobra.Command {
62 opts := &options{
63 io: f.IO(),
64 remotes: f.Remotes,
65 baseRepo: f.BaseRepo,
66 }
68 stackSaveCmd := &cobra.Command{
69 Use: "sync",
70 Short: `Push the stack to GitLab, and create or update its merge requests. (EXPERIMENTAL)`,
71 Long: heredoc.Docf(`
72 Updates GitLab to match your local stack:
74 - Creates a merge request for each diff without one, unless %[1]s--skip-mr-creation%[1]s or %[1]s--skip-push%[1]s is set. Each merge request targets the branch of the previous diff, or the base branch for the first diff.
75 - With %[1]s--template%[1]s, uses the template for each new merge request and appends that diff's commit message body. Ignores the template when %[1]s--skip-push%[1]s or %[1]s--skip-mr-creation%[1]s is set.
76 - Pulls changes made on GitLab, such as applied suggestions, into any diff whose branch is behind its remote.
77 - If you amended a diff since the last sync, rebases the diffs after it. Then, unless %[1]s--skip-push%[1]s is set, force-pushes the stack's branches.
78 - Removes diffs with merged merge requests and deletes their local branches. Keeps diffs with closed merge requests.
79 - If you're working in a fork, asks whether to push to the fork or the upstream repository.
80 - With %[1]s--update-base%[1]s, rebases the stack onto the latest version of the base branch. Then, unless %[1]s--skip-push%[1]s is set, force-pushes the stack's branches.
81 `, "`") + text.ExperimentalString,
82 Example: heredoc.Doc(`
83 glab stack sync
84 glab stack sync --no-verify
85 glab stack sync --update-base
86 glab stack sync --skip-push
87 glab stack sync --skip-mr-creation
88 glab stack sync --assignee user1,user2
89 glab stack sync --label bug,priority::high
90 glab stack sync --template Review
91 glab stack sync --reviewer user1 --reviewer user2`),
92 Args: cobra.NoArgs,
93 ValidArgsFunction: cobra.NoFileCompletions,
94 Annotations: map[string]string{
95 mcpannotations.Destructive: "true",
96 },
97 RunE: func(cmd *cobra.Command, args []string) error {
98 opts.io.StartSpinner("Syncing")
99 defer opts.io.StopSpinner("")
101 var gr git.StandardGitCommand
103 return opts.run(cmd.Context(), f, gr)
104 },
105 }
107 fl := stackSaveCmd.Flags()
108 fl.BoolVar(&opts.noVerify, "no-verify", false, "Bypass the pre-push hook. (See githooks(5) for more information.)")
109 fl.BoolVar(&opts.updateBase, "update-base", false, "Rebase the stack onto the latest version of the base branch.")
110 fl.BoolVar(&opts.skipPush, "skip-push", false, "Rebase the stack locally without pushing branches or creating merge requests. Still fetches from the remote and calls the GitLab API.")
111 fl.BoolVar(&opts.skipMRCreation, "skip-mr-creation", false, "Skip creating merge requests for branches that don't have one yet.")
112 fl.StringSliceVarP(&opts.assignees, "assignee", "a", []string{}, "Assign merge request to people by their `usernames`. Multiple usernames can be comma-separated or specified by repeating the flag.")
113 fl.StringSliceVarP(&opts.labels, "label", "l", []string{}, "Add label by `name`. Multiple labels can be comma-separated or specified by repeating the flag.")
114 fl.StringSliceVar(&opts.reviewers, "reviewer", []string{}, "Request review from users by their `usernames`. Multiple usernames can be comma-separated or specified by repeating the flag.")
115 fl.StringVar(&opts.template, "template", "", "Template for new merge requests. A `name` is looked up in '.gitlab/merge_request_templates/' of the local repository, and the '.md' extension is optional. A value that is absolute or contains a path separator is read as a file path.")
117 return stackSaveCmd
118}
120func (o *options) run(ctx context.Context, f cmdutils.Factory, gr git.GitRunner) error {
121 if err := stackutils.CheckNoRebaseInProgress(); err != nil {
122 return err
123 }
125 switch {
126 case o.template != "" && (o.skipPush || o.skipMRCreation):
127 o.io.LogError("[Warning] --template is ignored with --skip-push or --skip-mr-creation.")
128 case o.template != "":
129 templateBody, err := cmdutils.LoadGitLabTemplate(cmdutils.MergeRequestTemplate, o.template)
130 if err != nil {
131 return err
132 }
133 if templateBody == "" {
134 return fmt.Errorf("template %q not found in .gitlab/merge_request_templates/", o.template)
135 }
136 o.templateBody = templateBody
137 }
139 client, err := auth.GetAuthenticatedClient(f.Config(), f.GitLabClient, f.IO())
140 if err != nil {
141 return fmt.Errorf("error authorizing with GitLab: %w", err)
142 }
143 o.labClient = client
145 o.io.StopSpinner("")
147 repo, err := f.BaseRepo()
148 if err != nil {
149 return fmt.Errorf("error determining base repo: %w", err)
150 }
152 // This prompts the user for the head repo if they're in a fork,
153 // allowing them to choose between their fork and the original repository
154 source, err := create.ResolvedHeadRepo(ctx, f)()
155 if err != nil {
156 return fmt.Errorf("error determining head repo: %w", err)
157 }
159 o.io.StartSpinner("Syncing")
161 stack, err := getStack()
162 if err != nil {
163 return fmt.Errorf("error getting current stack: %w", err)
164 }
166 user, _, err := client.Users.CurrentUser()
167 if err != nil {
168 return fmt.Errorf("error getting current user: %w", err)
169 }
171 o.stack = stack
172 o.target = repo
173 o.source = source
174 o.user = *user
176 if err := o.validate(); err != nil {
177 return err
178 }
180 if err := o.complete(client); err != nil {
181 return err
182 }
184 err = fetchOrigin(gr)
185 if err != nil {
186 return err
187 }
189 pushAfterSync := false
190 var branchesToPush []string
192 if o.updateBase {
193 baseBranch, err := stack.BaseBranch(gr)
194 if err != nil {
195 return fmt.Errorf("error getting base branch: %w", err)
196 }
198 remoteBase := git.DefaultRemote + "/" + baseBranch
199 fmt.Print(progressString(o.io, "Rebasing stack onto "+remoteBase+"..."))
201 err = rebaseWithUpdateRefs(o.io, remoteBase, &stack, gr)
202 if err != nil {
203 return err
204 }
205 pushAfterSync = true
206 branchesToPush = append(branchesToPush, stack.Branches()...)
207 }
209 for ref := range stack.Iter() {
210 status, err := branchStatus(&ref, gr)
211 if err != nil {
212 return fmt.Errorf("error getting branch status: %w", err)
213 }
215 switch {
216 case strings.Contains(status, BranchIsBehind):
217 err = branchBehind(o.io, &ref, gr)
218 if err != nil {
219 return err
220 }
221 case strings.Contains(status, BranchHasDiverged):
222 needsPush, err := branchDiverged(o.io, &ref, &stack, gr)
223 if err != nil {
224 return err
225 }
227 if needsPush {
228 pushAfterSync = true
229 branchesToPush = append(branchesToPush, ref.Branch)
230 }
231 case strings.Contains(status, NothingToCommit):
232 // this is fine. we can just move on.
233 default:
234 return fmt.Errorf("your Git branch is ahead, but it shouldn't be; you might need to squash your commits")
235 }
237 if ref.MR == "" {
238 switch {
239 case o.skipPush:
240 o.io.LogInfo(progressString(
241 o.io,
242 ref.Branch+" has no merge request. Skipping MR creation because --skip-push was specified.",
243 ))
244 case o.skipMRCreation:
245 fmt.Println(progressString(
246 o.io,
247 ref.Branch+" has no merge request. Skipping MR creation.",
248 ))
249 default:
250 err := populateMR(o.io, &ref, o, client, gr)
251 if err != nil {
252 return err
253 }
254 }
255 } else {
256 // we found an MR. let's get the status:
257 mr, _, err := mrutils.MRFromArgsWithOpts(ctx, f, []string{ref.Branch}, nil, "any")
258 if err != nil {
259 return fmt.Errorf("error getting merge request from branch: %w. Does it still exist?", err)
260 }
262 // remove the MR from the stack if it's merged
263 // do not remove the MR from the stack if it is closed,
264 // but alert the user
265 err = removeOldMrs(o.io, &ref, mr, &stack, gr)
266 if err != nil {
267 return fmt.Errorf("error removing merged merge request: %w", err)
268 }
269 }
270 }
272 if pushAfterSync {
273 if o.skipPush {
274 branchesToPush = dedupe(filterEmpty(branchesToPush))
275 o.io.LogInfo(progressString(
276 o.io,
277 "Skipped pushing branches:",
278 strings.Join(branchesToPush, ", "),
279 ))
280 o.io.LogInfo("Run `glab stack sync` without `--skip-push` to push these branches to the remote.")
281 } else {
282 err := forcePushAllWithLease(o, &stack, gr)
283 if err != nil {
284 return fmt.Errorf("error pushing branches to remote: %w", err)
285 }
286 }
287 }
289 fmt.Print(progressString(o.io, "Sync finished!"))
290 return nil
291}
293func filterEmpty(s []string) []string {
294 result := make([]string, 0, len(s))
295 for _, v := range s {
296 if trimmed := strings.TrimSpace(v); trimmed != "" {
297 result = append(result, trimmed)
298 }
299 }
300 return result
301}
303func dedupe(s []string) []string {
304 seen := make(map[string]struct{}, len(s))
305 result := make([]string, 0, len(s))
306 for _, v := range s {
307 if _, ok := seen[v]; !ok {
308 seen[v] = struct{}{}
309 result = append(result, v)
310 }
311 }
312 return result
313}
315func (o *options) validate() error {
316 raw := o.assignees
317 o.assignees = dedupe(filterEmpty(o.assignees))
319 if len(raw) > 0 && len(o.assignees) == 0 {
320 return fmt.Errorf("--assignee (-a) flag requires at least one valid username")
321 }
323 rawLabels := o.labels
324 o.labels = dedupe(filterEmpty(o.labels))
326 if len(rawLabels) > 0 && len(o.labels) == 0 {
327 return fmt.Errorf("--label (-l) flag requires at least one valid label name")
328 }
330 rawReviewers := o.reviewers
331 o.reviewers = dedupe(filterEmpty(o.reviewers))
333 if len(rawReviewers) > 0 && len(o.reviewers) == 0 {
334 return fmt.Errorf("--reviewer flag requires at least one valid username")
335 }
337 return nil
338}
340func (o *options) complete(client *gitlab.Client) error {
341 if len(o.assignees) > 0 {
342 users, err := api.UsersByNames(client, o.assignees)
343 if err != nil {
344 return fmt.Errorf("error resolving assignee usernames: %w", err)
345 }
346 o.assigneeIDs = cmdutils.IDsFromUsers(users)
347 }
349 if len(o.reviewers) > 0 {
350 users, err := api.UsersByNames(client, o.reviewers)
351 if err != nil {
352 return fmt.Errorf("error resolving reviewer usernames: %w", err)
353 }
354 o.reviewerIDs = cmdutils.IDsFromUsers(users)
355 }
357 return nil
358}
360func getStack() (git.Stack, error) {
361 title, err := git.GetCurrentStackTitle()
362 if err != nil {
363 return git.Stack{}, fmt.Errorf("error getting current stack: %w", err)
364 }
366 stack, err := git.GatherStackRefs(title)
367 if err != nil {
368 return git.Stack{}, fmt.Errorf("error getting current stack references: %w", err)
369 }
370 return stack, nil
371}
373func gitPull(gr git.GitRunner) (string, error) {
374 pull, err := gr.Git("pull")
375 if err != nil {
376 return "", err
377 }
378 dbg.Debug("Pulled:", pull)
380 return pull, nil
381}
383func fetchOrigin(gr git.GitRunner) error {
384 output, err := gr.Git("fetch", git.DefaultRemote)
385 dbg.Debug("Fetching from remote:", output)
387 if err != nil {
388 return err
389 }
391 return nil
392}
394func branchStatus(ref *git.StackRef, gr git.GitRunner) (string, error) {
395 checkout, err := gr.Git("checkout", ref.Branch)
396 if err != nil {
397 return "", err
398 }
399 dbg.Debug("Checked out:", checkout)
401 output, err := gr.Git("status", "-uno")
402 if err != nil {
403 return "", err
404 }
405 dbg.Debug("Git status:", output)
407 return output, nil
408}
410func rebaseWithUpdateRefs(io *iostreams.IOStreams, target string, stack *git.Stack, gr git.GitRunner) error {
411 lastRef := stack.Last()
413 checkout, err := gr.Git("checkout", lastRef.Branch)
414 if err != nil {
415 return err
416 }
417 dbg.Debug("Checked out:", checkout)
419 rebase, err := gr.Git("rebase", "--fork-point", "--update-refs", target)
420 if err != nil {
421 return errors.New(errorString(
422 io,
423 "could not rebase onto "+target+", likely due to a merge conflict.",
424 "Fix the issues with Git and run `glab stack sync` again.",
425 ))
426 }
427 dbg.Debug("Rebased:", rebase)
429 return nil
430}
432func forcePushAllWithLease(opts *options, stack *git.Stack, gr git.GitRunner) error {
433 opts.io.LogInfo(progressString(
434 opts.io,
435 "Updating branches:",
436 strings.Join(stack.Branches(), ", "),
437 ))
439 pushArgs := []string{"push", git.DefaultRemote, "--force-with-lease"}
440 if opts.noVerify {
441 pushArgs = append(pushArgs, "--no-verify")
442 }
443 pushArgs = append(pushArgs, stack.Branches()...)
445 if err := gr.GitWithIO(opts.io.StdOut, opts.io.StdErr, pushArgs...); err != nil {
446 return err
447 }
449 opts.io.LogInfo(strings.TrimSuffix(progressString(opts.io, "Push succeeded"), "\n"))
450 return nil
451}
453func createMR(client *gitlab.Client, opts *options, ref *git.StackRef, gr git.GitRunner) (*gitlab.MergeRequest, error) {
454 targetProject, err := opts.target.Project(client)
455 if err != nil {
456 return &gitlab.MergeRequest{}, fmt.Errorf("error getting target project: %w", err)
457 }
459 pushArgs := []string{"push", "--set-upstream", git.DefaultRemote}
460 if opts.noVerify {
461 pushArgs = append(pushArgs, "--no-verify")
462 }
463 pushArgs = append(pushArgs, ref.Branch)
465 if err = gr.GitWithIO(opts.io.StdOut, opts.io.StdErr, pushArgs...); err != nil {
466 return &gitlab.MergeRequest{}, fmt.Errorf("error pushing branch: %w", err)
467 }
469 var previousBranch string
470 if ref.IsFirst() {
471 // Point to the base branch
472 previousBranch, err = opts.stack.BaseBranch(gr)
473 if err != nil {
474 return &gitlab.MergeRequest{}, fmt.Errorf("error getting base branch: %w", err)
475 }
477 if !git.RemoteBranchExists(previousBranch, gr) {
478 return &gitlab.MergeRequest{}, fmt.Errorf("branch %q does not exist on remote %q. Please push the branch to the remote before syncing",
479 previousBranch,
480 git.DefaultRemote)
481 }
483 } else {
484 // if we have a previous branch, let's point to that
485 previousBranch = opts.stack.Refs[ref.Prev].Branch
486 }
488 title, _, _ := strings.Cut(ref.Description, "\n")
489 title = strings.TrimSpace(title)
490 if len(title) > maxMRTitleSize {
491 title = title[:maxMRTitleSize-3] + "..."
492 }
493 description := ref.Body()
494 if opts.templateBody != "" {
495 description = strings.TrimSpace(opts.templateBody + "\n\n" + description)
496 }
498 l := &gitlab.CreateMergeRequestOptions{
499 Title: new(title),
500 Description: new(description),
501 SourceBranch: new(ref.Branch),
502 TargetBranch: new(previousBranch),
503 RemoveSourceBranch: new(true),
504 TargetProjectID: new(targetProject.ID),
505 }
507 if opts.assigneeIDs != nil {
508 l.AssigneeIDs = opts.assigneeIDs
509 } else {
510 l.AssigneeID = new(opts.user.ID)
511 }
513 if len(opts.labels) > 0 {
514 l.Labels = (*gitlab.LabelOptions)(&opts.labels)
515 }
517 if opts.reviewerIDs != nil {
518 l.ReviewerIDs = opts.reviewerIDs
519 }
521 mr, _, err := client.MergeRequests.CreateMergeRequest(opts.source.FullName(), l)
522 if err != nil {
523 return &gitlab.MergeRequest{}, fmt.Errorf("error creating merge request with the API: %w", err)
524 }
526 return mr, nil
527}
529func removeOldMrs(io *iostreams.IOStreams, ref *git.StackRef, mr *gitlab.MergeRequest, stack *git.Stack, gr git.GitRunner) error {
530 switch mr.State {
531 case mergedStatus:
532 progress := fmt.Sprintf("Merge request !%v has merged. Removing reference...", mr.IID)
533 fmt.Println(progressString(io, progress))
535 err := stack.RemoveRef(*ref, gr)
536 if err != nil {
537 return err
538 }
539 case closedStatus:
540 progress := fmt.Sprintf("MR !%v has closed", mr.IID)
541 fmt.Println(progressString(io, progress))
542 }
543 return nil
544}
546func errorString(io *iostreams.IOStreams, lines ...string) string {
547 redCheck := io.Color().Red("✘")
549 title := lines[0]
550 body := strings.Join(lines[1:], "\n ")
552 return fmt.Sprintf("\n%s %s \n %s", redCheck, title, body)
553}
555func progressString(io *iostreams.IOStreams, lines ...string) string {
556 blueDot := io.Color().ProgressIcon()
557 title := lines[0]
559 var body string
561 if len(lines) > 1 {
562 body = strings.Join(lines[1:], "\n ")
563 return fmt.Sprintf("\n%s %s \n %s", blueDot, title, body)
564 }
565 return fmt.Sprintf("\n%s %s\n", blueDot, title)
566}
568func branchDiverged(io *iostreams.IOStreams, ref *git.StackRef, stack *git.Stack, gr git.GitRunner) (bool, error) {
569 fmt.Println(progressString(io, ref.Branch+" has diverged. Rebasing..."))
571 err := rebaseWithUpdateRefs(io, ref.Branch, stack, gr)
572 if err != nil {
573 return false, err
574 }
576 return true, nil
577}
579func branchBehind(io *iostreams.IOStreams, ref *git.StackRef, gr git.GitRunner) error {
580 // possibly someone applied suggestions or someone else added a
581 // different commit
582 fmt.Println(progressString(io, ref.Branch+" is behind - pulling updates."))
584 _, err := gitPull(gr)
585 if err != nil {
586 return fmt.Errorf("error checking for a running Git pull: %w", err)
587 }
589 return nil
590}
592func populateMR(io *iostreams.IOStreams, ref *git.StackRef, opts *options, client *gitlab.Client, gr git.GitRunner) error {
593 // no MR - lets create one!
594 fmt.Println(progressString(io, ref.Branch+" needs a merge request. Creating it now."))
596 mr, err := createMR(client, opts, ref, gr)
597 if err != nil {
598 return fmt.Errorf("error updating stack ref files: %w", err)
599 }
601 fmt.Println(progressString(io, "Merge request created!"))
602 fmt.Println(mrutils.DisplayMR(io.Color(), &mr.BasicMergeRequest, true))
604 // update the ref
605 ref.MR = mr.WebURL
606 err = git.UpdateStackRefFile(opts.stack.Title, *ref)
607 if err != nil {
608 return fmt.Errorf("error updating stack ref files: %w", err)
609 }
611 return nil
612}
Diagnostics8 git calls · 226 ms
CallStatusSizeTime0226 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 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
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 · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=32926 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=22 git.pkt.data=20 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=32926 git.pkt.payload.max=32046 git.sideband.band1.bytes=32046 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=80 git.pack.bytes=32046 git.pack.ofs_delta=36 git.pack.ref_delta=0 git.pack.chain.max=2 git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91 git.pack.full=44Open pack map
fetchtree: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=2 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:0200432 B · 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=432 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=ff2d1e7abc74964e5679ebdb51f1ac0d0dc3aff0 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=432 git.pkt.payload.max=405 git.sideband.band1.bytes=405 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=405 git.pack.trailer=8f3029a269217d94d12d0671e0490fe3d5506303Open pack map
fetchtree:0200142 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=213 git.response.bytes=142 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=2b98e3432ee122253c3de860618f418835d8ee7b 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=142 git.pkt.payload.max=115 git.sideband.band1.bytes=115 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=115 git.pack.trailer=8526d31131397a024a329f09ee9b0c209c0458d2Open pack map
fetch2005.4 KiB213 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=5517 git.response.cache=MISS git.response.duration_ms=213 git.fetch.wants=f407e87306b0ace45def49e32957c693df02329f 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=5517 git.pkt.payload.max=5490 git.sideband.band1.bytes=5490 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
- a5e159a88ab0cf6a
- Request
- 1956ef75…
- 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