CODEREVIEW
Manage code reviews with the Unity Version Control CLI.
阅读时间12 分钟最后更新于 3 天前
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>] [--description=<text> | --descriptionfile=<file>] [--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>] [--description=<text> | --descriptionfile=<file>] [--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, or to mark a change request as applied or not applied:
cm codereview comment add <review_id> | reply <guid> | edit <guid> | delete <guid> ...cm codereview comment apply <guid> --changeset=<csetspec>cm codereview comment unapply <guid>
Use the following syntax to add, remove, or list the reviewers of a code review:
cm codereview reviewer add | remove <review_id>cm codereview reviewer list <review_id> [--format=<str_format> | --xml[=<output_file>]] [--encoding=<name>]
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>])
Use the following syntax to subscribe to or unsubscribe from the emails of a code review, or to check your subscription:
cm codereview subscribe | unsubscribe <review_id>cm codereview subscription <review_id> [--format=<str_format>]
Options
Option / Argument | Description |
|---|---|
| -e | Edits the parameters of an existing code review. |
| -d | Deletes one or more existing code reviews. Use a whitespace to separate the code reviews IDs. |
| --status | Sets the new status of a code review. See Remarks for additional information. |
| A comma-separated list of users. When you create a code review, sets its reviewers. With |
| A comma-separated list of groups. Works the same way as |
| Used with |
| --assignee | Sets the new assignee of a code review. Can't be combined with |
| Used when you create a code review, or when you edit one with |
| Used when you create a code review, or when you edit one with |
| --format | Retrieves the output message in a specific format. See Remarks for additional information. |
| --repository | Sets the repository to be used as default. (Use 'cm help objectspec' to learn more about repository specs.) |
| Used with |
| Used with |
| Used with |
| Used with |
| Used with |
| Used with |
| Used with |
| The text of a comment. |
| Reads the text of a comment from the specified file. Use |
| Used with |
| Used with |
| Used with |
| Used with |
| Used with |
| spec | It 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.) |
| title | A text string to be used as title of the new code review. |
| id | The code review identification number. A GUID can be used as well. |
| review_id | The code review identification number. A GUID can be used as well. |
| guid | The GUID of a review comment. |
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.
When you edit a code review, fails if the code review has no reviewers. Add them with , and each reviewer sets their own status with .
--statuscm codereview reviewer addcm codereview reviewThe description is the text that the Desktop GUI shows at the top of the code review.
When you edit a code review with , works as follows:
-e--description- If the code review has a description, replaces it.
--description - If the code review has no description, adds one.
--description - An empty value, , clears the description.
--description=
If you set both and , takes precedence.
--description--descriptionfile--descriptionfileIf the command creates the code review but can't add its description, it does the following:
- Shows the error with the code review ID.
- Prints the ID, or the output.
--format - Exits with an error code.
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 , , and subcommands work on branch, changeset, and shelve reviews.
commentreviewerreviewcm mergerequestcommentreviewerreviewsubscribeunsubscribesubscriptioncm crcm codereviewcomment addmkcomment deletermreviewer listlscomment add--path--revision- To comment on a line or a range of lines, add .
--line - To comment on any other location, such as a point of an image, add .
--location - To comment on the whole file, don't add or
--line.--location
The command prints the GUID of the new comment, which , , , , and take.
replyeditdeleteapplyunapply--locationcm<kind>:<text>cm find changereviewcomment--format={location}comment editcomment applycomment unapply- You can mark only comments of type .
Change - The changeset can be any changeset in the repository, not only one under review.
- To apply a change request in a different changeset, run first.
comment unapply
A check-in or whose comment contains also marks the change request as applied in that changeset.
cm changeset editcomment[apply-change:<guid>]reviewer list--xmlReviewersReviewerReviewerUserStatusTypeTo set your own review status with , you must be a reviewer of the code review, a member of a reviewer group, or a server administrator.
reviewEmail subscriptions
subscribeunsubscribeUnity Version Control automatically subscribes the following users to a code review:
- The owner
- The reviewers
- Users who comment on the code review
- Users that someone mentions in a comment
After you unsubscribe, Unity Version Control subscribes you again if any of the following happens:
- You comment on the code review.
- Someone mentions you in a comment.
- Someone adds you, or a group you belong to, as a reviewer again.
Unity Version Control sends review emails only while they're enabled for the repository and your notification settings include reviews. If either is off, your subscription doesn't change.
subscription--formatname: valuesubscribed: yesreason: owneremails: enabled
subscription--formatFormat field | Description |
|---|---|
| Whether you're subscribed: |
| Why you're subscribed or not. For the values, refer to the following table. |
| Whether review emails are enabled for the repository: |
| Inserts a tab. |
| Inserts a new line. |
{reason}Value | Meaning |
|---|---|
| You own the code review. |
| You're a reviewer of the code review. |
| You commented on the code review. |
| Someone mentioned you in a comment. |
| You subscribed yourself. |
| You unsubscribed yourself. |
| You have no subscription of your own. You can still get the emails as a member of a reviewer group. |
| A reason that this version of the client doesn't recognize. |
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 , and sets its reviewers:
/main/task001cm 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 in code review 1367:
/src/foo.cscm 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
The following example creates a code review with a description:
cm cr br:/main/task001 "Fix the login crash" --description="Retries the token refresh once."
The following example replaces the description of code review 1367 with the content of a file:
cm cr -e 1367 --descriptionfile=description.md
The following example comments on line 12 of a revision that code review 1367 deletes:
cm cr comment add 1367 -c="Why remove it?" --revision=revid:5821 --line=12
The following example marks a change request as applied in changeset 1520, and then as not applied:
cm cr comment apply 27658884-5dcc-49b7-b0ef-a5760ae740a3 --changeset=cs:1520cm cr comment unapply 27658884-5dcc-49b7-b0ef-a5760ae740a3
The following example writes the reviewers of code review 1367 to an XML file:
cm cr reviewer list 1367 --xml=reviewers.xml --encoding=utf-8
The following example shows your subscription to code review 1367, and then unsubscribes you from its emails:
cm cr subscription 1367cm cr unsubscribe 1367