Clone Windows Button - How Does It Work?

I am curious how the button works. Can you explain how, when you click the "Clone to Windows" button, it’s known to open a local application (GitHub) on my machine.

+6
source share
2 answers

Check out this GitExtension patch : it logs this action in HKCR

<Component Id="Protocol.github_windows" Guid="*"> <RegistryKey Key="github-windows" Root="HKCR"> <RegistryValue Value="URL: Github for Windows Protocol" Type="string" /> <RegistryValue Name="URL Protocol" Value="" Type="string" /> </RegistryKey> <RegistryKey Key="github-windows\DefaultIcon" Root="HKCR"> <RegistryValue Value="[INSTALLDIR]GitExtensions.exe" Type="string" /> </RegistryKey> <RegistryKey Root="HKCR" Key="github-windows\shell"/> <RegistryKey Root="HKCR" Key="github-windows\shell\open"/> <RegistryKey Root="HKCR" Key="github-windows\shell\open\command"> <RegistryValue Value="&quot;[INSTALLDIR]GitExtensions.exe&quot; %1" Type="string" /> </RegistryKey> </Component> 

And adds:

 if (args[1].StartsWith("git://")) { args = new string[]{args[0], "clone", args[1]}; } if (args[1].StartsWith("github-windows://openRepo/")) { args = new string[]{args[0], "clone", args[1].Replace("github-windows://openRepo/", "")}; } 

GitHub for Windows is suitable for a similar approach.

+4
source

It is very similar to the TortoiseGit app.

This is the github-windows protocol handler from TortoiseGit

 newCmd.Format(_T("/command:clone /url:\"%s\" /hasurlhandler"), (LPCTSTR)url); 

Adds registry keys to register the handler.

 <RegistryValue Root="HKLM" Key="Software\Classes\github-windows\shell\open\command" Value="&quot;[INSTALLDIR]bin\TortoiseGitProc.exe&quot; /urlhandler:&quot;%1&quot;" Type="string" /> 
0
source

All Articles