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).
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 contact us.