Skip to content

Instantly share code, notes, and snippets.

@kzu
Created May 8, 2014 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzu/6be398a134d6ecda35b7 to your computer and use it in GitHub Desktop.
Save kzu/6be398a134d6ecda35b7 to your computer and use it in GitHub Desktop.
VsHelper.Checkout
/// <summary>
/// Checks-out the file from source control.
/// </summary>
public static void CheckOut(string fileName)
{
Guard.NotNullOrEmpty(() => fileName, fileName);
if (File.Exists(fileName))
{
var vs = ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
if (vs != null && vs.SourceControl != null &&
vs.SourceControl.IsItemUnderSCC(fileName) && !vs.SourceControl.IsItemCheckedOut(fileName))
{
vs.SourceControl.CheckOutItem(fileName);
}
else
{
File.SetAttributes(fileName, FileAttributes.Normal);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment