How to automatically request a code review after checking in code into TFS

4k Views Asked by At

I like to know if it is possible, and if so how, to automatically request a code review while code is being checked into TFS.

So, for instance, I would like to have the request code review gui inside the pending changes gui, so that I can enter the name of the reviewer. When the code gets checked in, I would like Visual Studio to automatically request the code review for that check in. Is this possible?

I see a lot of questions (and answers) about how to require a code review before checking in, but I like to be able to check the code in and have it reviewed afterwards.

2

There are 2 best solutions below

3
On BEST ANSWER

No, it's not the general workflow. You have already checked in, so what is the meaning of code review? That does't make sense.

Generally we need to create Code Review as much as possible to ensure that there are no obvious and potential problems before you check in your code. Because it may impact your build/release if you checked in the wrong code. You can use Visual Studio to ask someone else from your team to review it. Your request will show up in his team explorer, in the my work page.

Please see Get your code reviewed with Visual Studio for details.

Back to your question itself: It's not possible as no changes anymore, they have checked in and you can only compare the changesets to get the differences...

1
On

For planned releases out of the master branch, this perfectly makes sense. With TFS you can manually request a code review for one or more commits. The communication between the programmer and the reviewer is done through comments attached to commits. Here is how to proceed.

  1. In TFS, locate the branch that contains the code to review. Suppose it is the master branch of the project DevOps, as shown below. Select History, and click on the commit for which you want code review, say 12aa6235.

enter image description here

  1. This takes you to the detailed view of the commit, shown below. Click on the button on the right (highlighted in red) to add comments, and the comment edit window appears. You can request code review by typing the name of the reviewer prefixed with @. An email will be sent to that user with a link to the commit to be reviewed.

enter image description here

  1. When the reviewer clicks on the link in the email, he/she gets to the commit details page, where he/she can review. Communication may back and forth between the programmer and the reviewer, until code is accepted. The comments may be marked as being in the following different states.

enter image description here