none
Automatically cloning Git repositories and adding them to Visual Studio registry

    Question

  • We have a PowerShell script that clones our repositories from Visual Studio Team Services when creating a new development machine. Whilst it works great, it's currently using a hard-coded lookup table to get a checksum to place in the registry so that Visual Studio understands the repository is cloned. (We're relatively fortunate that whatever this is calculated from doesn't change from user to user or machine to machine).

    In order to make the scripting process a little more robust, and able to handle new repositories without some manual effort first, does anyone know what values and algorithm VS uses to generate this checksum? Honestly, I was thinking about doing some trial and error, but I suspect in that path lies madness!

    We're using Windows 10 and Visual Studio Enterprise 2015 Update 3 if that helps/matters.

    Thanks

    George


    Tuesday, September 20, 2016 7:18 AM

All replies

  • Hi George,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thanks for your understanding!

    Sincerely,

    Oscar


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Wednesday, September 21, 2016 6:25 AM
    Moderator
  • Hi George Cover,

    Do you mean the string under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories?

    Wednesday, September 21, 2016 9:38 AM
  • Yep, that's the one. Fairly certain it's an MD5 checksum (40 character hex string)...and whilst I did devote a small amount of time trying to work out what data was being used to calculate the hash, that's a deep rabbit hole I didn't go too far down.
    Wednesday, September 21, 2016 11:14 AM
  • Hi George,

    Is the clone path always the same with different uses or machines? The value changes when the clone path is changed at my side.

    Thursday, September 22, 2016 2:23 AM
  • Hey Eddie - yep, the checksum changes when you change the path the repository is cloned to. We've (well I) have created a bunch of scripts to initialise a development machine with all the bits and pieces we need to consider ourselves "effective". This means that 98% of our machines all clone our repositories to the same (local) place (C:\src).

    Because the checksum changes with clone path, I can't really roll the script out to the wider group yet because it's oh so hard coded to that C:\src path. If I was able to calculate that checksum myself, I could script the cloning of the repositories and ensure VS knew about them, which would be a great thing with over 100 repositories (whether that's "too many" is a question for another day) ;-)

    Thursday, September 22, 2016 11:06 AM
  • Hi George Cover,

    I cannot find the calculate method of the checksum for now. However, if you create a registry key with a random checksum and the same "Path" configured manually for a cloned git repo under that path, Visual Studio is able to detect it as a cloned git repo and update the checksum automatically. Does this meet your requirement?

    Friday, September 23, 2016 2:46 AM
  • Thanks Eddie - I've scheduled some time on Monday to put that approach into practice. Will chime back in next week!
    Friday, September 23, 2016 10:32 AM
  • Testing that briefly it doesn't seem to work. I might need to be a bit more specific. Visual Studio definitely lists the repository in the "Local Git Repositories" but in the panel above (instance.visualstudio.com) the repository is still listed as uncloned. If I try to clone it, VS complains about there being a folder already present so will not continue the clone.

    It might not be an issues as most of the developers don't connect to the team project, most preferring to use the web interface to link everything together (or command line), but there are several key consumers of source code that would be confused by VS not thinking those repositories were cloned.

    Monday, September 26, 2016 12:32 PM
  • Hi George Cover,

    Can you share your detailed steps? It works correctly at my side.

    Following are my steps:

    1. Clone a VSTS repository to local machine.

    2. Create a registry key with the name and local path.

    3. Launch Visual Studio and open Team Explorer.

    The local repository is listed and the connected project is displayed as cloned.

    Friday, September 30, 2016 7:37 AM
  • Same steps. I'm using PowerShell to drive Git to clone the repo, after finding the remote URL via the VSTS Rest API. I'm going to have to do some more testing on the script I have, but it does look like VSTS is taking control of the registry entry as I noticed the Name of the subkey change today after opening up VS again.

    That said, whilst VS shows the local repository, it still shows the connected project as uncloned. I wonder if there's some other step I'm missing, or perhaps our repos/project are configured strangely.

    I have to switch priorities this week so I'm unlikely to get more time to focus on this. If I get a moment, I'll try and push the scripts up somewhere accessible to see if you get the same results running those. Perhaps something in the scripts isn't doing something in a manner expected by VS.

    Thanks


    Monday, October 03, 2016 8:32 AM