Skip to content
Published at March 24, 2017
Product Features

Migrating from TFS to Git: How to Run CodeScene on TFS Projects

What if your projects are under version control in Microsoft's Team Foundation Server.

The CodeScene analysis engine runs on git repositories. 

 

What if your projects are under version control in Microsoft’s Team Foundation Server (TFS), and you still want to use CodeScene? No problem, you can use git-tfs to convert your TFS projects to git repositories.

This guide assumes you are running Windows 10 (it might work with 7 and 8, as well).

 

Migrating from TFS to Git.

 

 

 

Install the Prerequisites

 

First, install Chocolatey on the computer you want to use for the conversion. Follow the instructions at chocolatey.org/install. Note that you need PowerShell 3, or higher, and that you need to run it as administrator.

After Chocolatey is installed, run the following command in PowerShell. You should be asked to confirm the installation scripts. Note that this command will also try to install git, if not previously installed. If already installed manually, it seems that it logs errors, but continues with gittfs nonetheless.


choco install gittfs

 

Next, make sure you now have git and git-tfs available on your PATH:


git tfs help
# prints available commands

 

If not available, you might have to set the PATH for the session, or restart PowerShell.

 

 

 

Converting TFS Projects for CodeScene Analysis

 

Let’s say that you want to clone the repository path called “Development”, where you integrate changes in your development workflow, in a project collection called “MyCollection”. The “Development” path is probably the one you want as a branch in Git to analyze in CodeScene.

Run git-tfs with the following command in PowerShell to convert and clone the TFS repository to a git repository in the directory MyProject.


git tfs clone --export http://tfs:8080/tfs/MyCollection $/MyProject/Development MyProject

 

Note the --export flag used in the cloning command. This tells git-tfs to include metadata, such as information about work items, in each commit message. This can be used in CodeScene to link commits by Ticket ID and to measure temporal coupling across commits, and across repositories.

 

 

 

Verifying the Git History

 

The clone operation explained above can take a lot of time, so it can be useful to try cloning a small repository first, and verify the resulting git history. You can also clone from a specific changeset, saving some time, and use that to verify the git history:

 

git tfs clone --export --changeset=1337 http://tfs:8080/tfs/MyCollection $/MyProject/Development MyProject
cd MyProject
git log
# should include work item IDs in commit messages, e.g. [1337] ...

 

Note that the --export flag does not seem to be supported by the
quick-clone command.

 

 

 

Work Item and Ticket ID Mapping

 

When using your converted git repositories in CodeScene, a Ticket ID pattern
like \[(\d+)\] should capture the exported work item metadata in your commit messages.

 

 

 

Need Help?

 

Leave a comment below, or drop us an email at support@codescene.com.

 

Adam Tornhil

Elements Image

Subscribe to our newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Semper neque enim rhoncus vestibulum at maecenas. Ut sociis dignissim.

Latest Articles

Sneak-Peek: IDE Integration for CodeScene!

Sneak-Peek: IDE Integration for CodeScene!

At CodeScene we are proud to announce that we're launching an IDE integration, offering Code Health feedback in real-time. You'll get recom...

Visualize team-code alignment: reverse engineer your organization from version-control

Visualize team-code alignment: reverse engineer your organization from...

Visualize team-code alignment: reverse engineer your organization from version-control

CodeScene On-Prem Release Announcement Dec 2021

CodeScene On-Prem Release Announcement Dec 2021

As 2021 draws to a close, we would like to share with you some of the latest features ready and waiting for you in CodeScene. Read more!