Documentation

Unity Version Control

CODEREVIEW

Manage code reviews with the Unity Version Control CLI.
Read time 6 minutesLast updated 6 days ago

Description

Creates, edits, or deletes code reviews, and manages their comments, reviewers, and review status.

Usage

Use the following syntax to create a code review:
cm codereview <spec> <title> [--status=<status_name>] [--assignee=<user_name>] [--users=<user_list>] [--groups=<group_list>] [--format=<str_format>] [--repository=<rep_spec>]
Use the following syntax to edit a code review:
cm codereview -e <id> [--status=<status_name>] [--assignee=<user_name>] [--title=<title>] [--repository=<rep_spec>]
Use the following syntax to delete one or more code reviews:
cm codereview -d <id> [ ...] [--repository=<rep_spec>]
Use the following syntax to add, reply to, edit, or delete review comments:
cm codereview comment add <review_id> | reply <guid> | edit <guid> | delete <guid> ...
Use the following syntax to add, remove, or list the reviewers of a code review:
cm codereview reviewer add | remove | list <review_id>
Use the following syntax to set your own review status, or ask reviewers to review again:
cm codereview review <review_id> --reviewed | --rework-required | --under-reviewcm codereview review <review_id> --re-request (--all | [--users=<list>] [--groups=<list>])

Options

Option / Argument

Description

-eEdits the parameters of an existing code review.
-dDeletes one or more existing code reviews. Use a whitespace to separate the code reviews IDs.
--statusSets the new status of a code review. See Remarks for additional information.
--users
A comma-separated list of users. When you create a code review, sets its reviewers. With
reviewer add
,
reviewer remove
, and
review --re-request
, sets the users to act on. Accepts the special user
me
.
--groups
A comma-separated list of groups. Works the same way as
--users
.
--title
Used with
-e
, sets the new title of a code review.
--assigneeSets the new assignee of a code review. Can't be combined with
--users
or
--groups
.
--formatRetrieves the output message in a specific format. See Remarks for additional information.
--repositorySets the repository to be used as default. (Use 'cm help objectspec' to learn more about repository specs.)
--path
Used with
comment add
, posts the comment on a line of the specified file, given as a server path such as
/src/foo.cs
. Use it with
--line
.
--line
Used with
--path
, the line of the file to comment on. Lines count from 1.
--type
Used with
comment add
and
--path
, sets the type of a comment on a file:
Change
(a change request, the default),
Question
, or
Comment
.
--changeset
Used with
comment add
and
--path
, shows the comment in the diff of the specified changeset instead of the diff of the whole branch.
--discard
Used with
comment reply
, discards a change request.
-c
The text of a comment.
-commentsfile
Reads the text of a comment from the specified file. Use
-commentsfile=-
to read it from the standard input.
--reviewed
|
--rework-required
|
--under-review
Used with
review
, sets your own review status. You can add a comment with
-c
.
--re-request
Used with
review
, sets reviewers back to "Under review". Requires
--all
, or
--users
,
--groups
, or both. Doesn't accept a comment.
--all
Used with
--re-request
, asks every reviewer to review again.
specIt can be either a changeset spec, a shelve spec or a branch spec. It will be the target of the new code review. (Use 'cm help objectspec' to learn more about changeset or branch specs.)
titleA text string to be used as title of the new code review.
idThe code review identification number. A GUID can be used as well.
review_idThe code review identification number. A GUID can be used as well.
guidThe GUID of a review comment.
comment add
prints it, and
cm find changereviewcomment --format={guid}
lists them.

Help

Remarks

This command allows users to manage code reviews: create, edit, and delete code reviews for changesets or branches.
To create a new code review, a changeset/branch spec and a title are required. The initial status and assignee can be set, too. An ID (or GUID if requested) will be returned as a result.
To edit or delete an existing code review, the target code review ID (or GUID) is required. No messages are displayed if there are no errors.
The 'status parameter' must only be one of the following: "Under review" (default), "Reviewed", or "Rework required".
The 'repository' parameter is available to set the default working repository. This is useful when the user wants to manage reviews on a server different than the one associated to the current workspace, or when there is no current workspace at all.

Comments, reviewers, and review status

The
comment
,
reviewer
, and
review
subcommands work on branch, changeset, and shelve reviews.
cm cr
is an alias of
cm codereview
.
comment add
also accepts
mk
,
comment delete
accepts
rm
, and
reviewer list
accepts
ls
.
comment add
posts a comment on the whole review, or on a line of a file with
--path
and
--line
. The command prints the GUID of the new comment.
reply
,
edit
, and
delete
take that GUID.
To set your own review status with
review
, you must be a reviewer of the code review, a member of a reviewer group, or a server administrator.

Output format parameters (--format option)

This command accepts a format string to show the output.

The output parameters of this command are the following

Option / Argument

Description

{0}id
{1}guid
Please note that the '--format' parameter only takes effect when creating a new code review.

Examples

cm codereview cs:1856@myrepo@myserver:8084 "My code review" --assignee=dummy
cm codereview br:/main/task001@myrepo@myserver:8084 "My code review" --status="Rework required" --assignee=newbie --format="{id} -> {guid}"
cm codereview 1367 -e --assignee=new_assignee
cm codereview -e 27658884-5dcc-49b7-b0ef-a5760ae740a3 --status=Reviewed
cm codereview -d 1367 --repository=myremoterepo@myremoteserver:18084
cm codereview 27658884-5dcc-49b7-b0ef-a5760ae740a3 -d
The following example creates a code review of branch
/main/task001
, and sets its reviewers:
cm cr br:/main/task001 "Login fixes" --users=maria --groups=leads
The following example changes the title of code review 1367:
cm cr -e 1367 --title="Fix the login crash"
The following example posts a change request on line 42 of
/src/foo.cs
in code review 1367:
cm cr comment add 1367 -c="Rename this" --path=/src/foo.cs --line=42
The following example adds reviewers to code review 1367:
cm cr reviewer add 1367 --users=maria,me --groups=leads
The following example sets your review status to "Reviewed", with a comment:
cm cr review 1367 --reviewed -c="Looks good"
The following example asks every reviewer of code review 1367 to review again:
cm cr review 1367 --re-request --all