GitLabgitlab-org

cli

main
ply9 git calls270 ms100 KiB6 cachedprotocol v2
86 lines4.1 KiBRaw

Add a pending review comment to a merge request. (EXPERIMENTAL)

Synopsis

Add a comment to your pending review. The comment stays visible only to you until you publish the review with glab mr note draft publish or submit it from the merge request page.

On success, the command prints the ID of the pending comment. Pass that ID to glab mr note draft update or glab mr note draft delete.

Use --file to place the comment on a specific file in the latest merge request diff version. Combine with --line (new side) or --old-line (old/removed side) to target a specific line. Omit both flags for a file-level comment.

Use --reply to reply to an existing discussion thread. The value can be a full discussion ID or a unique prefix of at least 8 characters. Find discussion IDs with glab mr note list.

The flag rules are:

  • --line and --old-line require --file, and cannot be used together.
  • --file and --reply are mutually exclusive.

--attach uploads a file and references it at the end of the comment. Repeat the flag for more than one file, or pass - to read the file from standard input. The upload happens immediately, even though the comment stays pending. An attachment is content on its own, so a comment with only --attach does not prompt for a body. When standard input is not a terminal, it is read as the comment body, unless --attach - reads the file from standard input. The command waits until standard input closes, so to post only the attachment from a script, redirect standard input from /dev/null.

This feature is an experiment and is not ready for production use. It might be unstable or removed at any time. For more information, see https://docs.gitlab.com/policy/development_stages_support/.

plaintext
glab mr note draft create [<id> | <branch>] [flags]

Examples

console
# Add a pending comment to merge request 123
glab mr note draft create 123 -m "Consider renaming this."

# Add a pending comment to the current branch's merge request
glab mr note draft create -m "Looks good overall."

# Pipe the body from stdin
echo "Needs a test." | glab mr note draft create 123

# Add a pending diff comment on line 42 of main.go
glab mr note draft create 123 --file main.go --line 42 -m "Off-by-one?"

# Add a pending diff comment on lines 10-15
glab mr note draft create 123 --file main.go --line 10:15 -m "Extract this block."

# Add a pending diff comment on a removed line
glab mr note draft create 123 --file main.go --old-line 7 -m "Why was this removed?"

# Add a pending reply to an existing discussion thread
glab mr note draft create 123 --reply abc12345 -m "Agreed."

# Keep the ID of the pending comment for a later update
id=$(glab mr note draft create 123 -m "First pass")

Options

plaintext
      --attach stringArray   (EXPERIMENTAL) Upload a file and reference it at the end of the comment. Use "-" to read the file from standard input. Repeat the flag to attach multiple files.
      --file string          File path for a diff comment, like <path/to/file>. Targets the latest merge request diff version.
      --line string          Line in the new version. A single line number, like 42, or a range, like 10:15.
  -m, --message string       Comment message. If omitted, opens an editor or reads from stdin.
      --old-line int         Line in the old version, for commenting on a removed line.
      --reply string         Reply to an existing discussion. Accepts a full discussion ID or a unique prefix of at least 8 characters.

Options inherited from parent commands

plaintext
  -h, --help          Show help for this command.
  -R, --repo string   Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted.
1---
2title: '`glab mr note draft create`'
3stage: AI Clients
4group: Developer Clients
5info: To determine the technical writer assigned to the Stage/Group associated with this page, see <https://handbook.gitlab.com/handbook/marketing/product-and-technical-marketing/technical-writing/#assignments>
6---
8<!--
9This documentation is auto generated by a script.
10Please do not edit this file directly. Run `make gen-docs` instead.
11-->
13Add a pending review comment to a merge request. (EXPERIMENTAL)
15## Synopsis
17Add a comment to your pending review. The comment stays visible only to you until you publish the review with `glab mr note draft publish` or submit it from the merge request page.
19On success, the command prints the ID of the pending comment. Pass that ID to `glab mr note draft update` or `glab mr note draft delete`.
21Use `--file` to place the comment on a specific file in the latest merge request diff version. Combine with `--line` (new side) or `--old-line` (old/removed side) to target a specific line. Omit both flags for a file-level comment.
23Use `--reply` to reply to an existing discussion thread. The value can be a full discussion ID or a unique prefix of at least 8 characters. Find discussion IDs with `glab mr note list`.
25The flag rules are:
27- `--line` and `--old-line` require `--file`, and cannot be used together.
28- `--file` and `--reply` are mutually exclusive.
30`--attach` uploads a file and references it at the end of the comment. Repeat the flag for more than one file, or pass `-` to read the file from standard input. The upload happens immediately, even though the comment stays pending. An attachment is content on its own, so a comment with only `--attach` does not prompt for a body. When standard input is not a terminal, it is read as the comment body, unless `--attach -` reads the file from standard input. The command waits until standard input closes, so to post only the attachment from a script, redirect standard input from `/dev/null`.
32This feature is an experiment and is not ready for production use.
33It might be unstable or removed at any time.
34For more information, see
35<https://docs.gitlab.com/policy/development_stages_support/>.
37```plaintext
38glab mr note draft create [<id> | <branch>] [flags]
39```
41## Examples
43```console
44# Add a pending comment to merge request 123
45glab mr note draft create 123 -m "Consider renaming this."
47# Add a pending comment to the current branch's merge request
48glab mr note draft create -m "Looks good overall."
50# Pipe the body from stdin
51echo "Needs a test." | glab mr note draft create 123
53# Add a pending diff comment on line 42 of main.go
54glab mr note draft create 123 --file main.go --line 42 -m "Off-by-one?"
56# Add a pending diff comment on lines 10-15
57glab mr note draft create 123 --file main.go --line 10:15 -m "Extract this block."
59# Add a pending diff comment on a removed line
60glab mr note draft create 123 --file main.go --old-line 7 -m "Why was this removed?"
62# Add a pending reply to an existing discussion thread
63glab mr note draft create 123 --reply abc12345 -m "Agreed."
65# Keep the ID of the pending comment for a later update
66id=$(glab mr note draft create 123 -m "First pass")
68```
70## Options
72```plaintext
73 --attach stringArray (EXPERIMENTAL) Upload a file and reference it at the end of the comment. Use "-" to read the file from standard input. Repeat the flag to attach multiple files.
74 --file string File path for a diff comment, like <path/to/file>. Targets the latest merge request diff version.
75 --line string Line in the new version. A single line number, like 42, or a range, like 10:15.
76 -m, --message string Comment message. If omitted, opens an editor or reads from stdin.
77 --old-line int Line in the old version, for commenting on a removed line.
78 --reply string Reply to an existing discussion. Accepts a full discussion ID or a unique prefix of at least 8 characters.
79```
81## Options inherited from parent commands
83```plaintext
84 -h, --help Show help for this command.
85 -R, --repo string Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted.
86```
Diagnostics9 git calls · 270 ms
CallStatusSizeTime0270 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 KiB3 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=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 · 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
fetchtree:02001.7 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=1744
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=5e4007a5673eb3bf5d0d7f1a1463c3b2ca3fb3bd
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=1744
git.pkt.payload.max=1717
git.sideband.band1.bytes=1717
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=1717
git.pack.trailer=3f1b9ccc7756e8941d6705e8187c87fd922113e6
Open pack map
fetchtree:0200669 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=669
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=e7f366ff56d25d838386e3ceead4278af75f7180
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=669
git.pkt.payload.max=642
git.sideband.band1.bytes=642
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=642
git.pack.trailer=8973f4a733afcd554e109d2cd1877fb7b7210224
Open pack map
fetchtree:0200320 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=320
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=26e1df371683d775a58e6541e378e4f0c2f3d7d0
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=320
git.pkt.payload.max=293
git.sideband.band1.bytes=293
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=293
git.pack.trailer=835632d6a936ff937caaf1aeb117c22834ab3425
Open pack map
fetchtree:0200257 B · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=254
git.response.bytes=257
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=bef67ccb863cb4a50e5725b5e1f792d657dd6eda
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=257
git.pkt.payload.max=230
git.sideband.band1.bytes=230
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=230
git.pack.trailer=2f5c0d7ca265a659f49b95fed4fc61fe27e560de
Open pack map
fetch2001.7 KiB254 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1791
git.response.cache=MISS
git.response.duration_ms=254
git.fetch.wants=73b71dbc7228c89757785cf1c99219d76d3062ef
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=1791
git.pkt.payload.max=1764
git.sideband.band1.bytes=1764
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
a5e15e2d2b3ecf6a
Request
3942da72…
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