Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Associate work item or code review to a changeset after check in

Tags:

tfs

Is it possible to update a changeset to include a reference to a work item after the check in has occurred? For instance you can right click on a changeset, and request a review (rather than requesting a review based on a shelveset before check in).

This may not be "best practices", but in that scenario is it possible to add a reference to that code review to the change set? The code review of course has a reference to the changeset, but it is not a two way association.

like image 544
Malaise Avatar asked Dec 11 '14 19:12

Malaise


4 Answers

Open the Work Item, select "All Links", select the "Link To" button, then "Changeset".

Link To Dialog

You can then either enter the changeset number, or use "..." to browse.

like image 91
Edward Thomson Avatar answered Oct 12 '22 11:10

Edward Thomson


To manually associate a changeset to a code review so that the code review shows up as a related work item in that changeset's details requires you to modify the work item form for the Code Review Request work item type. This requires the use of the TFS Process Template Editor.

TFS Versions supported

  • TFS 2015 | TFS 2013 | TFS 2012
    The steps below should be supported on these on premise deployments.
  • Azure DevOps Services (Hosted XML) | TFS 2018 | TFS 2017
    The work item form was redesigned in TFS 2017 and some of the XML used below was deprecated. If anyone can provide an equivalent definition for these newer versions I can update this answer.

Install Process Template Editor

Download and install the appropriate version of the Process Template Editor based on the version of Visual Studio that you have:

  • VS 2015: Microsoft Visual Studio Team Foundation Server 2015 Power Tools
  • VS 2017: TFS Process Template Editor
  • VS 2019: Process Template Editor

Modify the Code Review Request work item definition

Once the Process Template Editor is installed, follow these steps to update the Code Review Request work item form.

  1. Open the Code Review Request work item type definition from the server.
    1. Open Visual Studio and go to Tools > Process Editor > Work Items > Open WIT From Server.
    2. In the Connect to Team Project Collection dialog, select the appropriate collection and click Connect.
    3. Expand your team project, select Code Review Request and click OK.
  2. Add a new control for changeset links.
    1. In the Work Item Type window, click the Layout tab.
    2. Navigate to Layout > TabGroup > Tab Page - Links.
    3. Right-click Tab Page - Links and select New Control.
    4. Set the following properties:
      1. Type: LinksControl
      2. Label: Changeset
      3. Label Position: Top
      4. Name: ChangesetLink
    5. In the properties panel, find the Control Settings property and click the ... button to the right of "LinksControlOptionsType".
    6. If you see an error that says "Failed to load Control Settings" you should be able to safely dismiss it.
    7. On the XML tab, enter the following code and click OK:
      <LinksControlOptionsType>
      <LinkColumns>
          <LinkColumn RefName="System.Title" />
          <LinkColumn LinkAttribute="System.Links.Comment" />
      </LinkColumns>
      <WorkItemLinkFilters FilterType="excludeAll" />
      <ExternalLinkFilters FilterType="include">
          <Filter LinkType="Fixed in Changeset" />
      </ExternalLinkFilters>
      </LinksControlOptionsType>
      
  3. Update the server with your changes.
    1. Save the file. This will create one file with a .wit extension and one with a .xml extension.
    2. Go to Tools > Process Editor > Work Items > Import WIT.
    3. In the Connect to Team Project Collection dialog, select the appropriate collection and click Connect.
    4. In the Import Work Item Type Definition dialog, select the team project from the list.
    5. Click Browse..., select the .XML file, and click Open. Then click OK.

Adding the link

After updating the work item type definition, users may first need to click the refresh button in Team Explorer or in the browser the changes will be recognized.

Using Visual Studio

  1. Open the Code Review Request
    • Use Team > Go to Work Item..., OR
    • Enter the code review id in Team Explorer's Search Work Items field.
  2. Open the work item form by clicking Actions in the Team Explorer pane, and then click Open Work Item #
  3. Navigate to the Links tab, scroll down to the Changeset control, and click Link to.
  4. Enter the changeset id and click OK.

Using the TFS Web Interface

  1. Open the TFS web interface.
  2. Enter the code review id in the Search work items field.
  3. Navigate to the Links tab, scroll down to the Changeset control, and click Link to.
  4. Enter the changeset id and click OK.
like image 20
Holistic Developer Avatar answered Oct 12 '22 12:10

Holistic Developer


Note that you can also conduct a code review on a checked-in changeset by going to the history right-clicking on the changeset and selecting

enter image description here

like image 26
Etienne Avatar answered Oct 12 '22 12:10

Etienne


Here is a screenshot of a shared query my team uses to find a code review:

TFS code review query

I can find a code review work item for a specific work item by entering that work Item number in the filter field on the results tab for the query in the screenshot I attached.

This way, I can find the code review work item for any changeset, as long as that changeset was associated with a TFS work item.

like image 41
Danwize Avatar answered Oct 12 '22 11:10

Danwize