Contribute comments or code changes to a code review

You can contribute to a code review in the following ways:

  • Comment on a review
  • Comment on a review description
  • Comment on a specific line in a file
  • Comment on a file in a review
  • Reply to a comment
  • Edit files in a review
  • Edit files in a review with Git Fusion

Comments

Comments are the primary feedback mechanism provided by Swarm. Review comments can be flagged as tasks for a lightweight workflow within a review that helps authors and reviewers prioritize review feedback. By default, comment notifications are delayed to allow you to add or edit comments as you progress through a review without sending a notification for each individual comment on the review. Comment notifications are rolled up into a single notification that you can either leave to be sent automatically, or you can send manually, see Comment notification delay.

Tip

For more information about comments and comment features, see Comments.

Comment on a review

  1. From the review page: click Comments to view the Comments tab.
  2. Add your comment in the text area.
  3. Optional: select the Flag as Task checkbox to mark the comment as a task that needs to be addressed.
  4. Click Post.

Comment on a review description

  1. From the review page description area: click Add a Comment or X Comments where X is the number of description comments that already exist.
  2. Add your comment in the text area.
  3. Optional: select the Flag as Task checkbox to mark the comment as a task that needs to be addressed.
  4. Click Post.
  5. Tip

    To hide the description comments, click X Comments (where X is the number of description comments that exist). To display the comments again, click X Comments.

Comment on a specific line in a file

  1. From the review page: click Files to view the Files tab.
  2. Click on the line you want to comment on.
  3. Add your comment in the text area.
  4. Optional: select the Flag as Task checkbox to mark the comment as a task that needs to be addressed.
  5. Click Post.

Comment on a file in a review

  1. From the review page: click Files to view the Files tab.
  2. If there are multiple files, click the file you want to comment on to expand its view.
  3. Click the Add a Comment link in the footer of the file display.
  4. Add your comment in the text area.
  5. Optional: select the Flag as Task checkbox to mark the comment as a task that needs to be addressed.
  6. Click Post.

Reply to a comment

  1. From the review page: click Comments to view the Comments tab.
  2. Navigate to the comment you are replying to.
  3. Click the Reply link below the comment you are replying to.
  4. Add your comment in the text area.
  5. Optional: select the Flag as Task checkbox to mark your reply as a task that needs to be addressed.
  6. Click Post.

Editing review files

Edit files in a review

  1. Get a local copy of the review's files.

  2. Edit the files as required.
  3. Prepare a changelist with the edited files and include #review-1234 within the changelist's description (separated from other text with whitespace, or on a separate line), where 1234 is the review's identifier.

    Warning

    If you use an invalid review identifier, it will appear that nothing happens. Swarm is currently unable to notify you of this situation. If the review has not been correctly updated, use the Add Change button in the Swarm review heading to add the changelist to the review, see Add a changelist to a review.

  4. Depending on the model of code review you are using, you would:

    • Shelve the files (for pre-commit).
    • Submit the files (for post-commit).

Edit files in a review with Git Fusion

Important

You can only update Git Fusion-initiated reviews using Git Fusion.

In the following example, the current local task branch is task1, the target branch is main, the review id is 1234, the Git Fusion hostname is gfserver, and the remote repo name is p4gf_repo.

  1. Fetch the review's head version:

    $ git fetch --prune origin
    From gfserver:p4gf_repo
    * [new_branch]      review/main/1234 -> origin/review/main/1234
    x [deleted]         (none)     -> origin/review/main/new

    The --prune option lets the local Git repo delete the unwanted review/main/new reference created by the initial git push origin task1:review/main/new command.

  2. Check out the review's head version:

    $ git checkout review/main/1234
  3. Edit the files as required.
  4. Add the edited files to the index of files, in preparation for the next commit.

    There are several ways to do this. For example, to add all modified files to the index, run:

    $ git add -A
  5. Commit the files in Git:

    $ git commit -m "made some changes"
  6. Push the Git changes to the review:

    $ git push origin review/main/1234
    Note

    If you get review feedback that is better expressed as a Git rebase and cleaned up history, you can make your changes and push them as a new review.

    You cannot clean up history and then push your changes to the same review.

For more information on Git Fusion, see the Git Fusion Guide.