GitLabgitlab-org

cli

main
ply8 git calls202 ms99 KiB6 cachedprotocol v2
101 lines2.9 KiBRaw
1package create
3import (
4 "fmt"
5 "strings"
6 "time"
8 "github.com/MakeNowJust/heredoc/v2"
9 "github.com/briandowns/spinner"
10 "github.com/spf13/cobra"
12 "gitlab.com/gitlab-org/cli/internal/cmdutils"
13 "gitlab.com/gitlab-org/cli/internal/commands/stack/stackutils"
14 "gitlab.com/gitlab-org/cli/internal/git"
15 "gitlab.com/gitlab-org/cli/internal/mcpannotations"
16 "gitlab.com/gitlab-org/cli/internal/text"
17 "gitlab.com/gitlab-org/cli/internal/utils"
20func NewCmdCreateStack(f cmdutils.Factory, gr git.GitRunner) *cobra.Command {
21 stackCreateCmd := &cobra.Command{
22 Use: "create",
23 Short: "Create a new stack. (EXPERIMENTAL)",
24 Long: heredoc.Docf(`
25 The stack starts empty, and the other %[1]sglab stack%[1]s commands act on it until you switch. The branch you have checked out becomes its base branch, which the first merge request targets, so push it to the remote before you run %[1]sglab stack sync%[1]s. To add diffs, use %[1]sglab stack save%[1]s.
27 This command adds metadata to your %[1]s./.git/stacked%[1]s directory.
28 `, "`") + text.ExperimentalString,
29 Aliases: []string{"new"},
30 Example: heredoc.Doc(`
31 glab stack create cool-new-feature
32 glab stack new cool-new-feature`),
33 Args: cobra.MaximumNArgs(10),
34 Annotations: map[string]string{
35 mcpannotations.Destructive: "true",
36 },
37 RunE: func(cmd *cobra.Command, args []string) error {
38 if err := stackutils.CheckNoRebaseInProgress(); err != nil {
39 return err
40 }
42 var titleString string
44 switch len(args) {
45 case 1:
46 titleString = args[0]
47 case 0:
48 err := f.IO().Input(cmd.Context(), &titleString, "New stack title?", "", func(s string) error {
49 if s == "" {
50 return fmt.Errorf("title is required")
51 }
52 return nil
53 })
54 if err != nil {
55 return fmt.Errorf("error prompting for title: %w", err)
56 }
57 default:
58 titleString = strings.Join(args, "-")
59 }
61 s := spinner.New(spinner.CharSets[11], 100*time.Millisecond)
62 color := f.IO().Color()
64 title := utils.ReplaceNonAlphaNumericChars(titleString, "-")
65 if title != titleString {
66 f.IO().LogErrorf("%s warning: invalid characters have been replaced with dashes: %s\n",
67 color.WarnIcon(),
68 color.Blue(title))
69 }
71 err := git.SetCurrentStackTitle(title)
72 if err != nil {
73 return fmt.Errorf("error setting current stack: %w", err)
74 }
76 _, err = git.AddStackRefDir(title)
77 if err != nil {
78 return fmt.Errorf("error adding stack metadata directory: %w", err)
79 }
81 currentBranch, err := gr.Git("symbolic-ref", "--quiet", "--short", "HEAD")
82 if err != nil {
83 return fmt.Errorf("error getting current branch: %w", err)
84 }
86 err = git.AddStackBaseBranch(title, currentBranch)
87 if err != nil {
88 return fmt.Errorf("error adding current branch to metadata: %w", err)
89 }
91 if f.IO().IsOutputTTY() {
92 f.IO().LogInfof("New stack created with title \"%s\".\n", title)
93 }
95 s.Stop()
97 return nil
98 },
99 }
100 return stackCreateCmd
Diagnostics8 git calls · 202 ms
CallStatusSizeTime0202 ms
discover200185 B4 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 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 · hit5 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=5
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
fetchtree:02001.8 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=1857
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=dce174ff8c632a19d17eea99c8a9b7c37fb2b592
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1857
git.pkt.payload.max=1830
git.sideband.band1.bytes=1830
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=1830
git.pack.trailer=fb03183b7909876778f740d196d7516811003517
Open pack map
fetchtree:0200432 B · 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=432
git.response.cache=HIT
git.response.duration_ms=3
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=8f3029a269217d94d12d0671e0490fe3d5506303
Open pack map
fetchtree:0200145 B · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=189
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=bb53f04233a657802080a72acbea0331a76f5df4
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=145
git.pkt.payload.max=118
git.sideband.band1.bytes=118
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=118
git.pack.trailer=9aae38fdc630a3d715646e789f20b947a03e45ce
Open pack map
fetch2001.3 KiB189 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1312
git.response.cache=MISS
git.response.duration_ms=189
git.fetch.wants=397470618d658d9be6a59ea0e6a29afcb431cab0
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=1312
git.pkt.payload.max=1285
git.sideband.band1.bytes=1285
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
a5e159c7cdbccf6a
Request
aefa129e…
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