Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Associating git commits with Team Foundation work items

Tags:

Context

A GitHub Enterprise installation used for development. Every developer has his own public repo, and the organization has the authorative repo. Pull requests are used for code reviews, and we loosely follow nvie's git flow branching model.

A TFS installation used for issue tracking and deployment (the release branch). We mirror the release branch into a TFS repo.

Work Items

Now the hard part is: How do we associate git commits (that may originally be done on the public branches of the developers) with TF work items?

What I did

I've looked at the following projects for help:

  • Git-TFS
  • Git-TF (nodirt)
  • Git-TF (microsoft)

I've read references to associating commits with work item in both Git-TF projects, but I am unsure what tool to use, and how to go about it exactly.

I would be fine if I had to run a script on the release branch commits to extract work item references from the commit message and associate them with changesets sent to TFS. However, a solution that allows the association in metadata (instead of commit messages) would be preferred.

What are my options to associate work items in TFS with git commits?

like image 396
Wilbert Avatar asked Feb 18 '13 09:02

Wilbert


People also ask

How do you link work items?

Open a work item and choose the Links tab. From the links control tab you can link to new or existing work items, delete a link, or open the linked object. From the Query Results view, you can link a work item to a new or existing work item.

How do you link work items in Azure DevOps pull request?

You can link work items to existing builds from the Add link dialog. From the Links tab of a work item, choose Add link>Existing item. From the Add link dialog, choose one of the build link types—Build, Found in build, Integrated in build— and specify the build number.

What is complete associated work items after merging?

The root cause of this issue is Complete associated work items after merging option. When you complete the Pull Request and this option is enabled, the related work items will close. To solve this issue, you could disable this option. You can also set it to be disabled by default.

How do pull requests work?

A pull request works by allowing developers to create new features or squash bugs without affecting the main project code or what the users are seeing. This way, they are able to write and test code changes locally without having to worry about breaking the overall product.


2 Answers

If you use # in your git commit message as in git commit -m'fixes #123' TFS will automatically add the commit as a linked item in workitem specified.

like image 68
mcstar Avatar answered Oct 15 '22 12:10

mcstar


With git-tfs, you can associate workitems in a commit message using metadatas (and even force commit policy!).

They are automaticaly associated when the commit are done in the TFS server ( if you use the rcheckin command )

And there is even a git-note created on the git commit to have the title of the workitem and a link toward the workitem!

But to use rcheckin in a synchronisation process between git and TFS, you should before (abolutely) understand how it works!

When you rcheckin git commits in TFS, git-tfs, for each commit create the corresponding changeset in tfs and fetch the content of this changeset to recreate a git commit. So, even if it's (nearly) invisible for you in a normal worklow, you have the git commits after the rcheckin that are not the same than the original ones (there is a modification of the history!).

That could be a big problem if this git reporitory is supposted to be the central repository because every commiters will have to do a rebase. Otherwise, it shouldn't be a problem because it's completly transparent, except in special cases but easily solvable.

Not a perfect solution...

like image 37
Philippe Avatar answered Oct 15 '22 13:10

Philippe