Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first commit V 0.1

  • Loading branch information...
commit 6d80ea7f9f05d6f472b1d0f2babb07987f3a283b 0 parents
yysun authored
29 .gitignore
@@ -0,0 +1,29 @@
+
+#ignore thumbnails created by windows
+Thumbs.db
+#Ignore files build by Visual Studio
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
217 BasicSccProvider.cs
@@ -0,0 +1,217 @@
+using System;
+using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel.Design;
+using Microsoft.Win32;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio;
+
+using MsVsShell = Microsoft.VisualStudio.Shell;
+using ErrorHandler = Microsoft.VisualStudio.ErrorHandler;
+
+namespace GitScc
+{
+ /////////////////////////////////////////////////////////////////////////////
+ // BasicSccProvider
+ [MsVsShell.ProvideLoadKey("Standard", "0.1", "Git Source Control Provider", "Yiyisun@hotmail.com", 15261)]
+ [MsVsShell.DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\9.0Exp")]
+ // Register the package to have information displayed in Help/About dialog box
+ [MsVsShell.InstalledProductRegistration(false, "#100", "#101", "1.0.0.0", IconResourceID = CommandId.iiconProductIcon)]
+ // Declare that resources for the package are to be found in the managed assembly resources, and not in a satellite dll
+ [MsVsShell.PackageRegistration(UseManagedResourcesOnly = true)]
+ // Register the resource ID of the CTMENU section (generated from compiling the VSCT file), so the IDE will know how to merge this package's menus with the rest of the IDE when "devenv /setup" is run
+ // The menu resource ID needs to match the ResourceName number defined in the csproj project file in the VSCTCompile section
+ // Everytime the version number changes VS will automatically update the menus on startup; if the version doesn't change, you will need to run manually "devenv /setup /rootsuffix:Exp" to see VSCT changes reflected in IDE
+ [MsVsShell.ProvideMenuResource(1000, 1)]
+ // Register a sample options page visible as Tools/Options/SourceControl/SampleOptionsPage when the provider is active
+ //[MsVsShell.ProvideOptionPageAttribute(typeof(SccProviderOptions), "Source Control", "Sample Options Page Basic Provider", 106, 107, false)]
+ //[ProvideToolsOptionsPageVisibility("Source Control", "Sample Options Page Basic Provider", "ADC98052-0000-41D1-A6C3-704E6C1A3DE2")]
+ // Register a sample tool window visible only when the provider is active
+ //[MsVsShell.ProvideToolWindow(typeof(SccProviderToolWindow))]
+ //[MsVsShell.ProvideToolWindowVisibility(typeof(SccProviderToolWindow), "ADC98052-0000-41D1-A6C3-704E6C1A3DE2")]
+ // Register the source control provider's service (implementing IVsScciProvider interface)
+ [MsVsShell.ProvideService(typeof(SccProviderService), ServiceName = "Git Source Control Service")]
+ // Register the source control provider to be visible in Tools/Options/SourceControl/Plugin dropdown selector
+ [ProvideSourceControlProvider("Git Source Control Provider", "#100")]
+ // Pre-load the package when the command UI context is asserted (the provider will be automatically loaded after restarting the shell if it was active last time the shell was shutdown)
+ [MsVsShell.ProvideAutoLoad("C4128D99-0000-41D1-A6C3-704E6C1A3DE2")]
+ // Declare the package guid
+ [Guid("C4128D99-2000-41D1-A6C3-704E6C1A3DE2")]
+ public class BasicSccProvider : MsVsShell.Package
+ {
+ private SccProviderService sccService = null;
+
+ public BasicSccProvider()
+ {
+ Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering constructor for: {0}", this.ToString()));
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+ // BasicSccProvider Package Implementation
+ #region Package Members
+
+ protected override void Initialize()
+ {
+ Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering Initialize() of: {0}", this.ToString()));
+ base.Initialize();
+
+ // Proffer the source control service implemented by the provider
+ sccService = new SccProviderService(this);
+ ((IServiceContainer)this).AddService(typeof(SccProviderService), sccService, true);
+
+ // Add our command handlers for menu (commands must exist in the .vsct file)
+ MsVsShell.OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService;
+ if (mcs != null)
+ {
+ CommandID cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommand);
+ MenuCommand menuCmd = new MenuCommand(new EventHandler(OnSccCommand), cmd);
+ mcs.AddCommand(menuCmd);
+
+ cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandCommit);
+ menuCmd = new MenuCommand(new EventHandler(OnSccCommand), cmd);
+ mcs.AddCommand(menuCmd);
+
+ cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandHistory);
+ menuCmd = new MenuCommand(new EventHandler(OnSccCommand), cmd);
+ mcs.AddCommand(menuCmd);
+
+ cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandCompare);
+ menuCmd = new MenuCommand(new EventHandler(OnSccCommand), cmd);
+ mcs.AddCommand(menuCmd);
+
+ //// ToolWindow Command
+ //cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdViewToolWindow);
+ //menuCmd = new MenuCommand(new EventHandler(ViewToolWindow), cmd);
+ //mcs.AddCommand(menuCmd);
+
+ // // ToolWindow's ToolBar Command
+ // cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdToolWindowToolbarCommand);
+ // menuCmd = new MenuCommand(new EventHandler(ToolWindowToolbarCommand), cmd);
+ // mcs.AddCommand(menuCmd);
+ }
+
+ // Register the provider with the source control manager
+ // If the package is to become active, this will also callback on OnActiveStateChange and the menu commands will be enabled
+ IVsRegisterScciProvider rscp = (IVsRegisterScciProvider)GetService(typeof(IVsRegisterScciProvider));
+ rscp.RegisterSourceControlProvider(GuidList.guidSccProvider);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering Dispose() of: {0}", this.ToString()));
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ private void OnSccCommand(object sender, EventArgs e)
+ {
+ // Toggle the checked state of this command
+ MenuCommand thisCommand = sender as MenuCommand;
+ if (thisCommand != null)
+ {
+ //thisCommand.Checked = !thisCommand.Checked;
+
+ sccService.Refresh();
+ }
+ }
+
+ /// <summary>
+ /// The function can be used to bring back the provider's toolwindow if it was previously closed
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ //private void ViewToolWindow(object sender, EventArgs e)
+ //{
+ // this.ShowSccProviderToolWindow();
+ //}
+
+ //private void ToolWindowToolbarCommand(object sender, EventArgs e)
+ //{
+ // SccProviderToolWindow window = (SccProviderToolWindow)this.FindToolWindow(typeof(SccProviderToolWindow), 0, true);
+
+ // if (window != null)
+ // {
+ // window.ToolWindowToolbarCommand();
+ // }
+ //}
+
+ // This function is called by the IVsSccProvider service implementation when the active state of the provider changes
+ // The package needs to show or hide the scc-specific commands
+ public virtual void OnActiveStateChange()
+ {
+ MsVsShell.OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService;
+ if (mcs != null)
+ {
+ CommandID cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommand);
+ MenuCommand menuCmd = mcs.FindCommand(cmd);
+ menuCmd.Supported = true;
+ menuCmd.Enabled = sccService.Active;
+ menuCmd.Visible = sccService.Active;
+
+ cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandCommit);
+ menuCmd = mcs.FindCommand(cmd);
+ menuCmd.Supported = true;
+ menuCmd.Enabled = sccService.Active;
+ menuCmd.Visible = sccService.Active;
+
+ cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandHistory);
+ menuCmd = mcs.FindCommand(cmd);
+ menuCmd.Supported = true;
+ menuCmd.Enabled = sccService.Active;
+ menuCmd.Visible = sccService.Active;
+
+ cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandCompare);
+ menuCmd = mcs.FindCommand(cmd);
+ menuCmd.Supported = true;
+ menuCmd.Enabled = sccService.Active;
+ menuCmd.Visible = sccService.Active;
+
+ // cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdViewToolWindow);
+ // menuCmd = mcs.FindCommand(cmd);
+ // menuCmd.Supported = true;
+ // menuCmd.Enabled = sccService.Active;
+ // menuCmd.Visible = sccService.Active;
+
+ // cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdToolWindowToolbarCommand);
+ // menuCmd = mcs.FindCommand(cmd);
+ // menuCmd.Supported = true;
+ // menuCmd.Enabled = sccService.Active;
+ // menuCmd.Visible = sccService.Active;
+ }
+
+ //ShowSccProviderToolWindow();
+ }
+
+ private void ShowSccProviderToolWindow()
+ {
+ //MsVsShell.ToolWindowPane window = this.FindToolWindow(typeof(SccProviderToolWindow), 0, true);
+ //IVsWindowFrame windowFrame = null;
+ //if (window != null && window.Frame != null)
+ //{
+ // windowFrame = (IVsWindowFrame)window.Frame;
+ //}
+ //if (windowFrame == null)
+ //{
+ // throw new InvalidOperationException("No valid window frame object was returned from Toolwindow pane");
+ //}
+ //if (sccService.Active)
+ //{
+ // ErrorHandler.ThrowOnFailure(windowFrame.Show());
+ //}
+ //else
+ //{
+ // ErrorHandler.ThrowOnFailure(windowFrame.Hide());
+ //}
+ }
+
+ public new Object GetService(Type serviceType)
+ {
+ return base.GetService(serviceType);
+ }
+
+ }
+}
108 BasicSccProvider.csproj
@@ -0,0 +1,108 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{ADECE07A-5D80-4950-9DA5-A681CE2F5106}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>GitScc</RootNamespace>
+ <AssemblyName>GitSccProvider</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="GitSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\GitSharp.dll</HintPath>
+ </Reference>
+ <Reference Include="GitSharp.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\GitSharp.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Shell.9.0" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Design" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Drawing" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="GitFileStatusTracker.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="BasicSccProvider.cs" />
+ <Compile Include="CommandId.cs" />
+ <Compile Include="Guids.cs" />
+ <Compile Include="ProvideSourceControlProvider.cs" />
+ <Compile Include="Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="SccProviderService.cs" />
+ <Compile Include="GitFileStatus.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Resources.resx">
+ <SubType>Designer</SubType>
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <MergeWithCTO>true</MergeWithCTO>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Resources\Images_24bit.bmp" />
+ <Content Include="Resources\Images_32bit.bmp" />
+ <Content Include="Resources\SccGlyphs.bmp" />
+ <None Include="Resources\Product.ico" />
+ </ItemGroup>
+ <ItemGroup>
+ <VSCTCompile Include="PkgCmd.vsct">
+ <ResourceName>1000</ResourceName>
+ </VSCTCompile>
+ <None Include="ClassDiagram.cd" />
+ </ItemGroup>
+ <PropertyGroup>
+ <!--
+ To specify a different registry root to register your package, uncomment the TargetRegistryRoot
+ tag and specify a registry root in it.
+ <TargetRegistryRoot></TargetRegistryRoot>
+ -->
+ <RegisterOutputPackage>true</RegisterOutputPackage>
+ <RegisterWithCodebase>true</RegisterWithCodebase>
+ </PropertyGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\VSSDK\Microsoft.VsSDK.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
34 BasicSccProvider.sln
@@ -0,0 +1,34 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicSccProvider", "BasicSccProvider.csproj", "{ADECE07A-5D80-4950-9DA5-A681CE2F5106}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{A0417584-B3B4-4991-8435-4B86D643322B}"
+ ProjectSection(SolutionItems) = preProject
+ lib\DiffieHellman.dll = lib\DiffieHellman.dll
+ lib\GitSharp.Core.dll = lib\GitSharp.Core.dll
+ lib\GitSharp.dll = lib\GitSharp.dll
+ lib\ICSharpCode.SharpZipLib.dll = lib\ICSharpCode.SharpZipLib.dll
+ lib\Org.Mentalis.Security.dll = lib\Org.Mentalis.Security.dll
+ lib\Tamir.SharpSSH.dll = lib\Tamir.SharpSSH.dll
+ lib\Winterdom.IO.FileMap.dll = lib\Winterdom.IO.FileMap.dll
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {ADECE07A-5D80-4950-9DA5-A681CE2F5106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ADECE07A-5D80-4950-9DA5-A681CE2F5106}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ADECE07A-5D80-4950-9DA5-A681CE2F5106}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ADECE07A-5D80-4950-9DA5-A681CE2F5106}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ DebugSamples90.Connect = 1;Configure Project for VSIP Experimental Environment;ConfigVSIPDebug
+ EndGlobalSection
+EndGlobal
19 ClassDiagram.cd
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram MajorVersion="1" MinorVersion="1">
+ <Class Name="GitScc.SccProviderService" Collapsed="true">
+ <Position X="1.25" Y="1.25" Width="1.75" />
+ <TypeIdentifier>
+ <HashCode>EAAAC4AYgCBAGAAAEAIABCEAYgQAAIAqAAAQuIASAAA=</HashCode>
+ <FileName>SccProviderService.cs</FileName>
+ </TypeIdentifier>
+ <Lollipop Position="0.2" />
+ </Class>
+ <Class Name="GitScc.BasicSccProvider" Collapsed="true">
+ <Position X="3.5" Y="1.25" Width="1.75" />
+ <TypeIdentifier>
+ <HashCode>AAEAAAAACCAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAEA=</HashCode>
+ <FileName>BasicSccProvider.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Font Name="Tahoma" Size="8.25" />
+</ClassDiagram>
45 CommandId.cs
@@ -0,0 +1,45 @@
+/***************************************************************************
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+This code is licensed under the Visual Studio SDK license terms.
+THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+
+***************************************************************************/
+
+using System;
+
+namespace GitScc
+{
+ /// <summary>
+ /// This class is used to expose the list of the IDs of the commands implemented
+ /// by the client package. This list of IDs must match the set of IDs defined inside the
+ /// VSCT file.
+ /// </summary>
+ static class CommandId
+ {
+ // Define the list a set of public static members.
+ public const int icmdSccCommand = 0x101;
+ public const int icmdSccCommandCommit = 0x102;
+ public const int icmdSccCommandHistory = 0x103;
+ public const int icmdSccCommandCompare = 0x104;
+
+ //public const int icmdViewToolWindow = 0x102;
+ //public const int icmdToolWindowToolbarCommand = 0x103;
+
+ // Define the list of menus (these include toolbars)
+ //public const int imnuToolWindowToolbarMenu = 0x200;
+
+ // Define the list of icons (use decimal numbers here, to match the resource IDs)
+ public const int iiconProductIcon = 400;
+
+ // Define the list of bitmaps (use decimal numbers here, to match the resource IDs)
+ //public const int ibmpToolbarMenusImages = 500;
+ //public const int ibmpToolWindowsImages = 501;
+
+ // Glyph indexes in the bitmap used for toolwindows (ibmpToolWindowsImages)
+ //public const int iconSccProviderToolWindow = 0;
+ }
+}
16 GitFileStatus.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace GitScc
+{
+ public enum GitFileStatus
+ {
+ NotControlled,
+ UnTrackered,
+ Trackered,
+ Modified,
+ Staged,
+ //Deleted,
+ }
+}
118 GitFileStatusTracker.cs
@@ -0,0 +1,118 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using GitSharp;
+
+namespace GitScc
+{
+ public class GitFileStatusTracker
+ {
+ private RepositoryStatus repositoryStatus;
+ private Uri workingFolderUri;
+ FileSystemWatcher watcher;
+
+ public GitFileStatusTracker()
+ {
+
+ }
+
+ public void Open(string workingFolder)
+ {
+ Close();
+
+ if (!string.IsNullOrEmpty(workingFolder))
+ {
+ var repo = new Repository(workingFolder);
+ if (Repository.IsValid(repo.WorkingDirectory))
+ {
+ this.repositoryStatus = repo.Status;
+ this.workingFolderUri = new Uri(repo.WorkingDirectory+"\\");
+
+ this.watcher = new FileSystemWatcher(repo.WorkingDirectory + "\\.git"); //?
+ this.watcher.NotifyFilter = NotifyFilters.LastWrite;
+ this.watcher.EnableRaisingEvents = true;
+ this.watcher.Changed += new FileSystemEventHandler(watcher_Changed);
+ }
+ }
+ else
+ {
+ this.repositoryStatus = null;
+ this.workingFolderUri = null;
+ this.watcher.Changed -= new FileSystemEventHandler(watcher_Changed);
+ this.watcher = null;
+ }
+ }
+
+ private DateTime TimeFired;
+ public event EventHandler OnGitRepoChanged;
+ private object locker = new object();
+
+ void watcher_Changed(object sender, FileSystemEventArgs e)
+ {
+ lock (locker)
+ {
+ double delta = DateTime.Now.Subtract(TimeFired).TotalMilliseconds;
+ if (OnGitRepoChanged == null || delta < 500) return;
+
+ this.repositoryStatus.Update();
+ OnGitRepoChanged(this, EventArgs.Empty);
+
+ TimeFired = DateTime.Now;
+ }
+ }
+
+ public bool HasGitRepository
+ {
+ get { return this.repositoryStatus != null; }
+ }
+
+ public void Close()
+ {
+ if (this.repositoryStatus != null) this.repositoryStatus.Repository.Close();
+
+ if (this.watcher != null)
+ {
+ this.watcher.Changed -= new FileSystemEventHandler(watcher_Changed);
+ this.watcher.Dispose();
+ }
+ }
+
+ public GitFileStatus GetFileStatus(string fileName)
+ {
+ if (!HasGitRepository || !File.Exists(fileName)) return GitFileStatus.NotControlled;
+
+ fileName = workingFolderUri.MakeRelativeUri(new Uri(fileName)).ToString();
+
+ if (this.repositoryStatus.Untracked.Has(fileName))
+ {
+ return GitFileStatus.UnTrackered;
+ }
+ else if (this.repositoryStatus.Modified.Has(fileName))
+ {
+ return GitFileStatus.Modified;
+ }
+ else if (this.repositoryStatus.Added.Has(fileName))
+ {
+ return GitFileStatus.Staged;
+ }
+ else if (this.repositoryStatus.Staged.Has(fileName))
+ {
+ return GitFileStatus.Staged;
+ }
+ else
+ {
+ return GitFileStatus.Trackered;
+ }
+ }
+ }
+
+ public static class HashSetExt
+ {
+ public static bool Has(this HashSet<string> hashSet, string value)
+ {
+ return hashSet.Any(s => string.Compare(s, value, true) == 0);
+ }
+ }
+}
35 Guids.cs
@@ -0,0 +1,35 @@
+/***************************************************************************
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+This code is licensed under the Visual Studio SDK license terms.
+THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+
+***************************************************************************/
+
+using System;
+
+namespace GitScc
+{
+ /// <summary>
+ /// This class is used only to expose the list of Guids used by this package.
+ /// This list of guids must match the set of Guids used inside the VSCT file.
+ /// </summary>
+ static class GuidList
+ {
+ // Now define the list of guids as public static members.
+
+ // Unique ID of the source control provider; this is also used as the command UI context to show/hide the pacakge UI
+ public static readonly Guid guidSccProvider = new Guid("{C4128D99-0000-41D1-A6C3-704E6C1A3DE2}");
+ // The guid of the source control provider service (implementing IVsSccProvider interface)
+ public static readonly Guid guidSccProviderService = new Guid("{C4128D99-1000-41D1-A6C3-704E6C1A3DE2}");
+ // The guid of the source control provider package (implementing IVsPackage interface)
+ public static readonly Guid guidSccProviderPkg = new Guid("{C4128D99-2000-41D1-A6C3-704E6C1A3DE2}");
+
+ //Other guids for menus and commands
+ public static readonly Guid guidSccProviderCmdSet = new Guid("{C4A089DA-E640-438d-A977-815C267CA76D}");
+
+ };
+}
221 Overview.xml
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="../../../../Common/Overview.xsl" type="text/xsl"?>
+<VSSDKSample>
+ <ImagePath>../../../../Common</ImagePath>
+ <Status>
+ <Accessibility>true</Accessibility>
+ <ArchitectureDiagram>true</ArchitectureDiagram>
+ <Comments>true</Comments>
+ <Documentation>true</Documentation>
+ <ErrorHandling>true</ErrorHandling>
+ <FollowSDKCodingStandards>false</FollowSDKCodingStandards>
+ <Localizable>true</Localizable>
+ <Overview>true</Overview>
+ <ScenarioTests>false</ScenarioTests>
+ <Supported>true</Supported>
+ <UnitTests>true</UnitTests>
+ <Style>Example</Style>
+ </Status>
+ <Overview>
+ <ShortName>C# Example.BasicSccProvider</ShortName>
+ <LongName>C# Basic Source Code Control Provider Sample</LongName>
+ <Phrase>Implementing a source code control provider in Visual Studio using C#.</Phrase>
+ </Overview>
+ <Introduction>
+ <Summary>
+ This sample demonstrates how to create a source code control provider that registers
+ with Visual Studio and can be selected as active source control provider.
+ </Summary>
+ <Goal>Implement a source control provider package.</Goal>
+ <Goal>Expose an Options page visible only when the provider is active.</Goal>
+ <Goal>Expose a tool window visible only when the provider is active.</Goal>
+ <Goal>Display menu items only when the provider is active.</Goal>
+ <Image width="400" height="400">Example.BasicSccProvider.jpg</Image>
+ </Introduction>
+ <SampleInfo>
+ <State>
+ </State>
+ <Type>Example</Type>
+ <Complexity>2</Complexity>
+ <Screenshot>Example.BasicSccProvider.jpg</Screenshot>
+ <Area>Source Code Control</Area>
+ <Language>C#</Language>
+ <Folder>VisualStudioIntegration\Samples\SourceControl\CSharp\Example.BasicSccProvider\</Folder>
+ <SampleSolution>BasicSccProvider.sln</SampleSolution>
+ <FolderUnitTest>VisualStudioIntegration\Samples\SourceControl\CSharp\Example.BasicSccProvider\TDD\</FolderUnitTest>
+ <UnitTestStartup>UnitTests.sln</UnitTestStartup>
+ <Doc>ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.VSSDK.v90/dv_vsintegration/html/23a07da8-41b2-4d18-834b-60a71e7a5c54.htm</Doc>
+ <Keywords>
+ <Keyword>SCC</Keyword>
+ <Keyword>Source</Keyword>
+ <Keyword>Code</Keyword>
+ <Keyword>Control</Keyword>
+ <Keyword>Tool window</Keyword>
+ <Keyword>provider</Keyword>
+ <Keyword>active</Keyword>
+ <Keyword>menu</Keyword>
+ <Keyword>items</Keyword>
+ <Keyword>Source Code Control</Keyword>
+ <Keyword>Source Code Control Provider</Keyword>
+ </Keywords>
+ </SampleInfo>
+ <GettingStarted>
+ <Paragraph>
+ This sample has a package (BasicSccProvider) and the source control service (SccProviderService).
+ The sample exposes one tool window (SccProviderToolWindow) and one Options page (SccProviderOptions).
+ </Paragraph>
+ <Paragraph>
+ The source control provider can be selected on the Tools, Options, Source Control, Plug-In Selection page as "Managed Source Control Sample Basic Provider". Selecting it will make it the active source control provider.
+ </Paragraph>
+ <Paragraph>
+ When the provider is selected as the active source control provider,
+ the command "Scc Command" will be added to the Tools menu and the command "Source control provider toolwindow" will be added to the View menu, and the Tools, Options, Source Control, Sample Options Page will become visible.
+ When "View/Source control provider toolwindow" is clicked, the tool window will be created.
+ The visibility of menu commands, Options page, and tool window is controlled by the active state of the provider.
+ All of the UI elements will be hidden automatically when the provider is deactivated.
+ </Paragraph>
+ </GettingStarted>
+ <AdditionalResources>
+ <Resource>
+ <Title>Visual Studio SDK Website</Title>
+ <URL>http://msdn.microsoft.com/vstudio/extend</URL>
+ </Resource>
+ </AdditionalResources>
+ <UnitTests>
+ <Test>
+ Verify that the package can be created and sited and that it implements IVsPackage.
+ </Test>
+ <Test>
+ Verify that the source control provider service can be created, activated, and deactivated.
+ </Test>
+ <Test>
+ Test the "Scc Command" command on the Tools menu by toggling it twice.
+ </Test>
+ <Test>
+ Test the Options-page Activate, Deactivate, Apply, and Close events.
+ </Test>
+ <Test>
+ Test that the tool window can be displayed and that the toolbar command can be executed.
+ </Test>
+ </UnitTests>
+ <FunctionalTests>
+ <Test>Verify sample builds in all configurations.</Test>
+ <Test>Verify that the sample was registered. The About box should list the product as installed.</Test>
+ <Test>Verify that the provider is accessible in Tools, Options, SourceControl.</Test>
+ <Test>Verify that menu commands are visible when the provider is active.</Test>
+ <Test>Verify that the tool window is visible only when the provider is active, after it was displayed once.</Test>
+ <Test>Verify that the Options page is visible only when the provider is active.</Test>
+ </FunctionalTests>
+ <ProjectFiles>
+ <File>
+ <Name>BasicSccProvider.cs</Name>
+ <Description>
+ This file contains the Package implementation. It also is responsible for
+ handling the enabling and execution of source control commands.
+ </Description>
+ </File>
+ <File>
+ <Name>SccProviderService.cs</Name>
+ <Description>
+ This file contains the source control service implementation.
+ The class implements the IVsSccProvider interface that enables source control
+ provider activation and switching.
+ </Description>
+ </File>
+ <File>
+ <Name>SccProviderOptions.cs</Name>
+ <Description>
+ This class derives from MsVsShell.DialogPage and provides the Options page.
+ It is responsible for handing the Option page events, such as activation, apply, and close.
+ It hosts the SccProviderOptionsControl.
+ </Description>
+ </File>
+ <File>
+ <Name>SccProviderOptionsControl.cs</Name>
+ <Description>
+ This class is a UserControl that will be hosted on the Options page.
+ It has a label to demonstrate display of controls in the page.
+ </Description>
+ </File>
+ <File>
+ <Name>SccProviderToolWindow.cs</Name>
+ <Description>
+ This class derives from ToolWindowPane, which provides the IVsWindowPane
+ implementation. It is responsible for defining the window frame properties
+ such as caption and bitmap. It hosts the SccProviderToolWindowControl.
+ </Description>
+ </File>
+ <File>
+ <Name>SccProviderToolWindowControl.cs</Name>
+ <Description>
+ This class is a UserControl that will be hosted in the tool window. It has
+ a label to demonstrate display of controls in the window.
+ </Description>
+ </File>
+ <File>
+ <Name>CommandId.cs</Name>
+ <Description>
+ This is a list of GUIDs specific to this sample, especially the package GUID
+ and the commands group GUID. It also includes GUIDs of other elements used by
+ the sample.
+ </Description>
+ </File>
+ <File>
+ <Name>Guids.cs</Name>
+ <Description>
+ This is the list of command IDs that the sample defines.
+ </Description>
+ </File>
+ <File>
+ <Name>PkgCmd.vsct</Name>
+ <Description>
+ This file describes the menu structure and commands for this sample.
+ </Description>
+ </File>
+ <File>
+ <Name>Resources (.cs/.resx/.Designer.cs)</Name>
+ <Description>These files are used to support localized strings.</Description>
+ </File>
+ <File>
+ <Name>Resources\Images_24bit.bmp</Name>
+ <Description>
+ This bitmap defines the icons that are used for tool windows.
+ </Description>
+ </File>
+ <File>
+ <Name>Resources\Images_32bit.bmp</Name>
+ <Description>
+ This bitmap defines the icons that are used for toolbars and menu commands.
+ </Description>
+ </File>
+ <File>
+ <Name>Resources\Product.ico</Name>
+ <Description>
+ This file defines the icon to be used for the product.
+ </Description>
+ </File>
+ <File>
+ <Name>ProvideSourceControlProvider.cs</Name>
+ <Description>
+ This file contains the implementation of a custom registration attribute
+ that registers a source control provider. It is used to make the source control
+ provider visible on the Tools, Options, SourceControl, Plugins page.
+ </Description>
+ </File>
+ <File>
+ <Name>ProvideToolsOptionsPageVisibility.cs</Name>
+ <Description>
+ This file contains the implementation of a custom registration attribute
+ that defines the visibility of a tool window. It is used to make the tool
+ window implemented by the provider visible only when the provider is active
+ (that is, when the provider context UI has been asserted).
+ </Description>
+ </File>
+ </ProjectFiles>
+ <History>
+ <Change>
+ <Date>2005-10-01</Date>
+ <Description>Created this sample for the Visual Studio 2005 SDK.</Description>
+ </Change>
+ </History>
+</VSSDKSample>
172 PkgCmd.vsct
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!--
+ ***************************************************************************
+ Copyright (c) Microsoft Corporation. All rights reserved.
+ This code is licensed under the Visual Studio SDK license terms.
+ THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+ ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+ IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+ PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+ ***************************************************************************
+ -->
+ <!-- Definition of the command and menus used by this sample -->
+ <Extern href="stdidcmd.h"/>
+ <Extern href="vsshlids.h"/>
+ <Extern href="msobtnid.h"/>
+ <Commands package="guidSccProviderPkg">
+ <Menus>
+ <!--<Menu guid="guidSccProviderCmdSet" id="imnuToolWindowToolbarMenu" priority="0x0000" type="ToolWindowToolbar">
+ <Parent guid="guidSccProviderCmdSet" id="imnuToolWindowToolbarMenu"/>
+ <Strings>
+ <ButtonText>WindowBar</ButtonText>
+ <CommandName>Window Bar</CommandName>
+ </Strings>
+ </Menu>-->
+
+ <Menu guid="guidSccProviderCmdSet" id="imnuFileSourceControlMenu" priority="0x0000" type="Menu">
+ <!--<Parent guid="guidSccProviderCmdSet" id="igrpFileSourceControl"/>-->
+ <Strings>
+ <ButtonText>GitSccMenu</ButtonText>
+ <CommandName>Git</CommandName>
+ </Strings>
+ </Menu>
+
+ </Menus>
+ <Groups>
+
+ <!-- Group for scci commands in the File main menu -->
+ <Group guid="guidSccProviderCmdSet" id="igrpFileSourceControl" priority="0x0800">
+ <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_FILE"/>
+ </Group>
+
+ <!-- Group for scci buttons in the File/SourceControl menu -->
+ <Group guid="guidSccProviderCmdSet" id="igrpSourceControlCommands" priority="0x0000">
+ <Parent guid="guidSccProviderCmdSet" id="imnuFileSourceControlMenu"/>
+ </Group>
+
+
+ <!--<Group guid="guidSccProviderCmdSet" id="igrpSccMenuGroup" priority="0x0600">
+ <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
+ </Group>-->
+ <!--<Group guid="guidSccProviderCmdSet" id="igrpViewToolWindowGroup" priority="0x0100">
+ <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_VIEW"/>
+ </Group>
+ <Group guid="guidSccProviderCmdSet" id="igrpToolWindowToolbarGroup" priority="0x0100">
+ <Parent guid="guidSccProviderCmdSet" id="imnuToolWindowToolbarMenu"/>
+ </Group>-->
+ </Groups>
+ <Buttons>
+ <Button guid="guidSccProviderCmdSet" id="icmdSccCommandCommit" priority="0x0100" type="Button">
+ <Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>Commit ...</ButtonText>
+ </Strings>
+ </Button>
+
+ <Button guid="guidSccProviderCmdSet" id="icmdSccCommandHistory" priority="0x0102" type="Button">
+ <!--<Parent guid="guidSccProviderCmdSet" id="igrpSccMenuGroup"/>-->
+ <Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>View History</ButtonText>
+ </Strings>
+ </Button>
+
+ <Button guid="guidSccProviderCmdSet" id="icmdSccCommandCompare" priority="0x0101" type="Button">
+ <!--<Parent guid="guidSccProviderCmdSet" id="igrpSccMenuGroup"/>-->
+ <Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>Compare ...</ButtonText>
+ </Strings>
+ </Button>
+
+ <Button guid="guidSccProviderCmdSet" id="icmdSccCommand" priority="0x0109" type="Button">
+ <!--<Parent guid="guidSccProviderCmdSet" id="igrpSccMenuGroup"/>-->
+ <Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>Refresh Git File Status</ButtonText>
+ </Strings>
+ </Button>
+
+ <!--<Button guid="guidSccProviderCmdSet" id="icmdViewToolWindow" priority="0x0100" type="Button">
+ <Parent guid="guidSccProviderCmdSet" id="igrpViewToolWindowGroup"/>
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>&amp;Source control provider toolwindow</ButtonText>
+ </Strings>
+ </Button>
+ <Button guid="guidSccProviderCmdSet" id="icmdToolWindowToolbarCommand" priority="0x0100" type="Button">
+ <Parent guid="guidSccProviderCmdSet" id="igrpToolWindowToolbarGroup"/>
+ <Icon guid="guidSccProviderImages" id="iconCheckout"/>
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <Strings>
+ <ButtonText>ToolButton</ButtonText>
+ </Strings>
+ </Button>-->
+ </Buttons>
+ <Bitmaps>
+ <Bitmap guid="guidSccProviderImages" href="Resources\Images_32bit.bmp" usedList="iconCheckout, iconCheckin, iconUncheckout, iconAdd"/>
+ </Bitmaps>
+ </Commands>
+ <CommandPlacements>
+ <!--<CommandPlacement guid="guidSccProviderCmdSet" id="imnuFileSourceControlMenu" priority="0x0000">
+ <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_ITEM_SCC"/>
+ </CommandPlacement>
+ <CommandPlacement guid="guidSccProviderCmdSet" id="imnuFileSourceControlMenu" priority="0x0000">
+ <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_SCC"/>
+ </CommandPlacement>
+ <CommandPlacement guid="guidSccProviderCmdSet" id="imnuFileSourceControlMenu" priority="0x0000">
+ <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_SOLUTION_SCC"/>
+ </CommandPlacement>-->
+
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommand" priority="0x0001">
+ <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_ITEM_SCC"/>
+ </CommandPlacement>
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommand" priority="0x0001">
+ <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_SCC"/>
+ </CommandPlacement>
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommand" priority="0x0001">
+ <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_SOLUTION_SCC"/>
+ </CommandPlacement>
+
+ </CommandPlacements>
+ <Symbols>
+ <GuidSymbol name="guidSccProviderPkg" value="{C4128D99-2000-41D1-A6C3-704E6C1A3DE2}" />
+ <GuidSymbol name="guidSccProviderCmdSet" value="{C4A089DA-E640-438d-A977-815C267CA76D}" >
+ <IDSymbol name="icmdSccCommand" value="0x101"/>
+ <IDSymbol name="icmdSccCommandCommit" value="0x102"/>
+ <IDSymbol name="icmdSccCommandHistory" value="0x103"/>
+ <IDSymbol name="icmdSccCommandCompare" value="0x104"/>
+
+ <!--<IDSymbol name="icmdViewToolWindow" value="0x102"/>
+ <IDSymbol name="icmdToolWindowToolbarCommand" value="0x103"/>-->
+
+ <!--<IDSymbol name="igrpSccMenuGroup" value="0x300"/>-->
+ <!--<IDSymbol name="igrpViewToolWindowGroup" value="0x301"/>
+ <IDSymbol name="igrpToolWindowToolbarGroup" value="0x302"/>
+ <IDSymbol name="imnuToolWindowToolbarMenu" value="0x200"/>-->
+
+ <IDSymbol name="imnuFileSourceControlMenu" value="0x200"/>
+ <IDSymbol name="igrpFileSourceControl" value="0x300"/>
+ <IDSymbol name="igrpSourceControlCommands" value="0x301"/>
+
+ </GuidSymbol>
+
+ <GuidSymbol name="guidSccProviderImages" value="{495089FD-A8CA-4260-8EB1-794E2956B625}" >
+ <IDSymbol name="iconCheckout" value="1"/>
+ <IDSymbol name="iconCheckin" value="2"/>
+ <IDSymbol name="iconUncheckout" value="3"/>
+ <IDSymbol name="iconAdd" value="4"/>
+ </GuidSymbol>
+ </Symbols>
+</CommandTable>
78 Properties/AssemblyInfo.cs
@@ -0,0 +1,78 @@
+
+/***************************************************************************
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+This code is licensed under the Visual Studio SDK license terms.
+THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+
+***************************************************************************/
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("Git Source Control Provider")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Git Source Control Provider")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("28B54E0C-7BC4-4319-9B36-97E11DB22784")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
110 ProvideSourceControlProvider.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Globalization;
+using MsVsShell = Microsoft.VisualStudio.Shell;
+
+namespace GitScc
+{
+ /// <summary>
+ /// This attribute registers the source control provider.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
+ public sealed class ProvideSourceControlProvider : MsVsShell.RegistrationAttribute
+ {
+ private string _regName = null;
+ private string _uiName = null;
+
+ /// <summary>
+ /// </summary>
+ public ProvideSourceControlProvider(string regName, string uiName)
+ {
+ _regName = regName;
+ _uiName = uiName;
+ }
+
+ /// <summary>
+ /// Get the friendly name of the provider (written in registry)
+ /// </summary>
+ public string RegName
+ {
+ get { return _regName; }
+ }
+
+ /// <summary>
+ /// Get the unique guid identifying the provider
+ /// </summary>
+ public Guid RegGuid
+ {
+ get { return GuidList.guidSccProvider; }
+ }
+
+ /// <summary>
+ /// Get the UI name of the provider (string resource ID)
+ /// </summary>
+ public string UIName
+ {
+ get { return _uiName; }
+ }
+
+ /// <summary>
+ /// Get the package containing the UI name of the provider
+ /// </summary>
+ public Guid UINamePkg
+ {
+ get { return GuidList.guidSccProviderPkg; }
+ }
+
+ /// <summary>
+ /// Get the guid of the provider's service
+ /// </summary>
+ public Guid SccProviderService
+ {
+ get { return GuidList.guidSccProviderService; }
+ }
+
+ /// <summary>
+ /// Called to register this attribute with the given context. The context
+ /// contains the location where the registration inforomation should be placed.
+ /// It also contains other information such as the type being registered and path information.
+ /// </summary>
+ public override void Register(RegistrationContext context)
+ {
+ // Write to the context's log what we are about to do
+ context.Log.WriteLine(String.Format(CultureInfo.CurrentCulture, "BasicSccProvider:\t\t{0}\n", RegName));
+
+ // Declare the source control provider, its name, the provider's service
+ // and aditionally the packages implementing this provider
+ using (Key sccProviders = context.CreateKey("SourceControlProviders"))
+ {
+ using (Key sccProviderKey = sccProviders.CreateSubkey(RegGuid.ToString("B")))
+ {
+ sccProviderKey.SetValue("", RegName);
+ sccProviderKey.SetValue("Service", SccProviderService.ToString("B"));
+
+ using (Key sccProviderNameKey = sccProviderKey.CreateSubkey("Name"))
+ {
+ sccProviderNameKey.SetValue("", UIName);
+ sccProviderNameKey.SetValue("Package", UINamePkg.ToString("B"));
+
+ sccProviderNameKey.Close();
+ }
+
+ // Additionally, you can create a "Packages" subkey where you can enumerate the dll
+ // that are used by the source control provider, something like "Package1"="BasicSccProvider.dll"
+ // but this is not a requirement.
+ sccProviderKey.Close();
+ }
+
+ sccProviders.Close();
+ }
+ }
+
+ /// <summary>
+ /// Unregister the source control provider
+ /// </summary>
+ /// <param name="context"></param>
+ public override void Unregister(RegistrationContext context)
+ {
+ context.RemoveKey("SourceControlProviders\\" + GuidList.guidSccProviderPkg.ToString("B"));
+ }
+ }
+}
21 README.html
@@ -0,0 +1,21 @@
+<head>
+<title>Git Source Control Provider</title>
+</head>
+<body>
+<h2>Introduction</h2>
+Visual Studio users are used to see file status in source code control system right inside the solution explorer, whether it is SourceSafe, Team Foundation Server, Subversionor or even Mercurial. This plug-in integrates Git with visual studio solution explorer.<br /><br /><img src="http://gitscc.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=123874" alt="solution&#32;explorer.png" title="solution&#32;explorer.png" />
+<h2>Features</h2>
+<ul><li>Displays file status in solution explorer</li>
+<li>Enable/disable plug-in through visual studio&#39;s source control plug-in selection</li>
+<li>No source code control information stored in solution or project file.</li></ul>
+<h2>How to use</h2>
+<ul><li>Download and install <a href="http://gitscc.codeplex.com/wikipage?title=Git&referringTitle=Home">Git</a> and Git Source Control Provider. </li>
+<li>Open Visual Studio and go to Tools -&gt; Options. </li>
+<li>Select Source Control in the tree view</li>
+<li>Select Git Source Control Provider from the drop down list, and click OK. </li>
+<li>Open your solution controlled by Git to see the files&#39; status.</li>
+<li>If the file status is out of sync, right click solution explorer items and select &#39;&#39;Refresh Git File Status&quot;</li></ul>
+<img src="http://gitscc.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=123883" alt="solution&#32;explorer&#32;-&#32;context&#32;menu.png" title="solution&#32;explorer&#32;-&#32;context&#32;menu.png" />
+<h2>What&#39;s coming</h2>
+<ul><li><a href="http://gitscc.codeplex.com/wikipage?title=Project%20Roadmap&referringTitle=Home">Project Roadmap</a></li></ul></div><div class="ClearBoth"></div>
+</body>
127 Resources.Designer.cs
@@ -0,0 +1,127 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.4200
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace GitScc {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GitScc.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Git Source Control Provider.
+ /// </summary>
+ internal static string _100 {
+ get {
+ return ResourceManager.GetString("100", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to .
+ /// </summary>
+ internal static string _101 {
+ get {
+ return ResourceManager.GetString("101", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to CIP0H8JCC9JAJMRZE8H3J2IPADZQI9QIRHMKQPH2E8EDPDPEHCJQPDZEZRI1J8D3D8KHZPRQCEEDIPK3MKDDA9IEAACCMIPAQ0JCEQPHD0RPHDZRZKC2RDHERTDCKDPM.
+ /// </summary>
+ internal static string _15261 {
+ get {
+ return ResourceManager.GetString("15261", resourceCulture);
+ }
+ }
+
+ internal static System.Drawing.Icon _400 {
+ get {
+ object obj = ResourceManager.GetObject("400", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
+
+ internal static System.Drawing.Bitmap _500 {
+ get {
+ object obj = ResourceManager.GetObject("500", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ internal static System.Drawing.Bitmap _501 {
+ get {
+ object obj = ResourceManager.GetObject("501", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Git Source Control Provider.
+ /// </summary>
+ internal static string ProviderName {
+ get {
+ return ResourceManager.GetString("ProviderName", resourceCulture);
+ }
+ }
+
+ internal static System.Drawing.Bitmap SccGlyphs {
+ get {
+ object obj = ResourceManager.GetObject("SccGlyphs", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
145 Resources.resx
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="100" xml:space="preserve">
+ <value>Git Source Control Provider</value>
+ </data>
+ <data name="101" xml:space="preserve">
+ <value />
+ </data>
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="400" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\Product.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+ <data name="500" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\Images_32bit.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+ <data name="501" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\Images_24bit.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+ <data name="ProviderName" xml:space="preserve">
+ <value>Git Source Control Provider</value>
+ </data>
+ <data name="SccGlyphs" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\SccGlyphs.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+ <data name="15261" xml:space="preserve">
+ <value>CIP0H8JCC9JAJMRZE8H3J2IPADZQI9QIRHMKQPH2E8EDPDPEHCJQPDZEZRI1J8D3D8KHZPRQCEEDIPK3MKDDA9IEAACCMIPAQ0JCEQPHD0RPHDZRZKC2RDHERTDCKDPM</value>
+ </data>
+</root>
BIN  Resources/Images_24bit.bmp
Binary file not shown
BIN  Resources/Images_32bit.bmp
Binary file not shown
BIN  Resources/Product.ico
Binary file not shown
BIN  Resources/SccGlyphs.bmp
Binary file not shown
483 SccProviderService.cs
@@ -0,0 +1,483 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Globalization;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Shell.Interop;
+
+namespace GitScc
+{
+ [Guid("C4128D99-1000-41D1-A6C3-704E6C1A3DE2")]
+ public class SccProviderService : IVsSccProvider,
+ IVsSccManager2,
+ IVsSccManagerTooltip,
+ IVsSolutionEvents,
+ IVsSolutionEvents2,
+ IVsSccGlyphs,
+ IDisposable
+ {
+ private bool _active = false;
+ private BasicSccProvider _sccProvider = null;
+ private uint _vsSolutionEventsCookie;
+
+ private GitFileStatusTracker _statusTracker = null;
+
+ #region SccProvider Service initialization/unitialization
+ public SccProviderService(BasicSccProvider sccProvider)
+ {
+ _sccProvider = sccProvider;
+ _statusTracker = new GitFileStatusTracker();
+ //_statusTracker.OnGitRepoChanged += new EventHandler(_statusTracker_OnGitRepoChanged);
+
+ // Subscribe to solution events
+ IVsSolution sol = (IVsSolution)_sccProvider.GetService(typeof(SVsSolution));
+ sol.AdviseSolutionEvents(this, out _vsSolutionEventsCookie);
+ Debug.Assert(VSConstants.VSCOOKIE_NIL != _vsSolutionEventsCookie);
+
+ }
+
+ public void Dispose()
+ {
+ //_statusTracker.OnGitRepoChanged -= new EventHandler(_statusTracker_OnGitRepoChanged);
+
+ // Unregister from receiving solution events
+ if (VSConstants.VSCOOKIE_NIL != _vsSolutionEventsCookie)
+ {
+ IVsSolution sol = (IVsSolution)_sccProvider.GetService(typeof(SVsSolution));
+ sol.UnadviseSolutionEvents(_vsSolutionEventsCookie);
+ _vsSolutionEventsCookie = VSConstants.VSCOOKIE_NIL;
+ }
+ }
+ #endregion
+
+ #region IVsSccProvider interface functions
+ /// <summary>
+ /// Returns whether this source control provider is the active scc provider.
+ /// </summary>
+ public bool Active
+ {
+ get { return _active; }
+ }
+
+ // Called by the scc manager when the provider is activated.
+ // Make visible and enable if necessary scc related menu commands
+ public int SetActive()
+ {
+ Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Provider set active"));
+ _active = true;
+ _sccProvider.OnActiveStateChange();
+
+ OpenTracker();
+ return VSConstants.S_OK;
+ }
+
+ // Called by the scc manager when the provider is deactivated.
+ // Hides and disable scc related menu commands
+ public int SetInactive()
+ {
+ Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Provider set inactive"));
+
+ _active = false;
+ _sccProvider.OnActiveStateChange();
+
+ return VSConstants.S_OK;
+ }
+
+ public int AnyItemsUnderSourceControl(out int pfResult)
+ {
+ pfResult = 0;
+ return VSConstants.S_OK;
+ }
+ #endregion
+
+ #region IVsSccManager2 interface functions
+
+ public int BrowseForProject(out string pbstrDirectory, out int pfOK)
+ {
+ // Obsolete method
+ pbstrDirectory = null;
+ pfOK = 0;
+ return VSConstants.E_NOTIMPL;
+ }
+
+ public int CancelAfterBrowseForProject()
+ {
+ // Obsolete method
+ return VSConstants.E_NOTIMPL;
+ }
+
+ /// <summary>
+ /// Returns whether the source control provider is fully installed
+ /// </summary>
+ public int IsInstalled(out int pbInstalled)
+ {
+ // All source control packages should always return S_OK and set pbInstalled to nonzero
+ pbInstalled = 1;
+ return VSConstants.S_OK;
+ }
+
+ /// <summary>
+ /// Provide source control icons for the specified files and returns scc status of files
+ /// </summary>
+ /// <returns>The method returns S_OK if at least one of the files is controlled, S_FALSE if none of them are</returns>
+ public int GetSccGlyph([InAttribute] int cFiles, [InAttribute] string[] rgpszFullPaths, [OutAttribute] VsStateIcon[] rgsiGlyphs, [OutAttribute] uint[] rgdwSccStatus)
+ {
+ Debug.Assert(cFiles == 1, "Only getting one file icon at a time is supported");
+ // Return the icons and the status. While the status is a combination a flags, we'll return just values
+ // with one bit set, to make life easier for GetSccGlyphsFromStatus
+ GitFileStatus status = _statusTracker.GetFileStatus(rgpszFullPaths[0]);
+
+ switch (status)
+ {
+ case GitFileStatus.Trackered:
+ rgsiGlyphs[0] = VsStateIcon.STATEICON_CHECKEDIN;
+ if (rgdwSccStatus != null)
+ {
+ rgdwSccStatus[0] = (uint)__SccStatus.SCC_STATUS_CONTROLLED;
+ }
+ break;
+
+ case GitFileStatus.Modified:
+ rgsiGlyphs[0] = VsStateIcon.STATEICON_CHECKEDOUT;
+ if (rgdwSccStatus != null)
+ {
+ rgdwSccStatus[0] = (uint)__SccStatus.SCC_STATUS_CHECKEDOUT;
+ }
+ break;
+
+ case GitFileStatus.UnTrackered:
+ //rgsiGlyphs[0] = VsStateIcon.STATEICON_CHECKEDOUT;
+ rgsiGlyphs[0] = (VsStateIcon)(this._customSccGlyphBaseIndex + (uint)CustomSccGlyphs.PendingAdd);
+ if (rgdwSccStatus != null)
+ {
+ rgdwSccStatus[0] = (uint)__SccStatus.SCC_STATUS_CHECKEDOUT;
+ }
+ break;
+
+ case GitFileStatus.Staged:
+ //rgsiGlyphs[0] = VsStateIcon.STATEICON_CHECKEDOUT;
+ rgsiGlyphs[0] = (VsStateIcon)(this._customSccGlyphBaseIndex + (uint)CustomSccGlyphs.Staged);
+ if (rgdwSccStatus != null)
+ {
+ rgdwSccStatus[0] = (uint)__SccStatus.SCC_STATUS_CHECKEDOUT;
+ }
+ break;
+
+ case GitFileStatus.NotControlled:
+ rgsiGlyphs[0] = VsStateIcon.STATEICON_BLANK;
+ if (rgdwSccStatus != null)
+ {
+ rgdwSccStatus[0] = (uint)__SccStatus.SCC_STATUS_NOTCONTROLLED;
+ }
+ break;
+
+ }
+
+ return VSConstants.S_OK;
+ }
+
+ /// <summary>
+ /// Determines the corresponding scc status glyph to display, given a combination of scc status flags
+ /// </summary>
+ public int GetSccGlyphFromStatus([InAttribute] uint dwSccStatus, [OutAttribute] VsStateIcon[] psiGlyph)
+ {
+ switch (dwSccStatus)
+ {
+ case (uint)__SccStatus.SCC_STATUS_CHECKEDOUT:
+ psiGlyph[0] = VsStateIcon.STATEICON_CHECKEDOUT;
+ break;
+ case (uint)__SccStatus.SCC_STATUS_CONTROLLED:
+ psiGlyph[0] = VsStateIcon.STATEICON_CHECKEDIN;
+ break;
+ default:
+ psiGlyph[0] = VsStateIcon.STATEICON_BLANK;
+ break;
+ }
+ return VSConstants.S_OK;
+ }
+
+ /// <summary>
+ /// One of the most important methods in a source control provider, is called by projects that are under source control when they are first opened to register project settings
+ /// </summary>
+ public int RegisterSccProject([InAttribute] IVsSccProject2 pscp2Project, [InAttribute] string pszSccProjectName, [InAttribute] string pszSccAuxPath, [InAttribute] string pszSccLocalPath, [InAttribute] string pszProvider)
+ {
+ return VSConstants.S_OK;
+ }
+
+ /// <summary>
+ /// Called by projects registered with the source control portion of the environment before they are closed.
+ /// </summary>
+ public int UnregisterSccProject([InAttribute] IVsSccProject2 pscp2Project)
+ {
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ #region IVsSccManagerTooltip interface functions
+
+ /// <summary>
+ /// Called by solution explorer to provide tooltips for items. Returns a text describing the source control status of the item.
+ /// </summary>
+ public int GetGlyphTipText([InAttribute] IVsHierarchy phierHierarchy, [InAttribute] uint itemidNode, out string pbstrTooltipText)
+ {
+ string fileName = GetFileName(phierHierarchy, itemidNode);
+ GitFileStatus status = _statusTracker.GetFileStatus(fileName);
+ pbstrTooltipText = status.ToString();
+
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ #region IVsSolutionEvents interface functions
+
+ public int OnAfterOpenSolution([InAttribute] Object pUnkReserved, [InAttribute] int fNewSolution)
+ {
+ OpenTracker();
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterCloseSolution([InAttribute] Object pUnkReserved)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterLoadProject([InAttribute] IVsHierarchy pStubHierarchy, [InAttribute] IVsHierarchy pRealHierarchy)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterOpenProject([InAttribute] IVsHierarchy pHierarchy, [InAttribute] int fAdded)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnBeforeCloseProject([InAttribute] IVsHierarchy pHierarchy, [InAttribute] int fRemoved)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnBeforeCloseSolution([InAttribute] Object pUnkReserved)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnBeforeUnloadProject([InAttribute] IVsHierarchy pRealHierarchy, [InAttribute] IVsHierarchy pStubHierarchy)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnQueryCloseProject([InAttribute] IVsHierarchy pHierarchy, [InAttribute] int fRemoving, [InAttribute] ref int pfCancel)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnQueryCloseSolution([InAttribute] Object pUnkReserved, [InAttribute] ref int pfCancel)
+ {
+ CloseTracker();
+ return VSConstants.S_OK;
+ }
+
+ public int OnQueryUnloadProject([InAttribute] IVsHierarchy pRealHierarchy, [InAttribute] ref int pfCancel)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterMergeSolution([InAttribute] Object pUnkReserved)
+ {
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ #region IVsSccGlyphs Members
+
+ // Remember the base index where our custom scc glyph start
+ private uint _customSccGlyphBaseIndex = 0;
+ // Our custom image list
+ ImageList _customSccGlyphsImageList;
+ // Indexes of icons in our custom image list
+ enum CustomSccGlyphs
+ {
+ PendingAdd = 0,
+ Staged = 1,
+ };
+
+ public int GetCustomGlyphList(uint BaseIndex, out uint pdwImageListHandle)
+ {
+ // If this is the first time we got called, construct the image list, remember the index, etc
+ if (this._customSccGlyphsImageList == null)
+ {
+ // The shell calls this function when the provider becomes active to get our custom glyphs
+ // and to tell us what's the first index we can use for our glyphs
+ // Remember the index in the scc glyphs (VsStateIcon) where our custom glyphs will start
+ this._customSccGlyphBaseIndex = BaseIndex;
+
+ // Create a new imagelist
+ this._customSccGlyphsImageList = new ImageList();
+
+ // Set the transparent color for the imagelist (the SccGlyphs.bmp uses magenta for background)
+ this._customSccGlyphsImageList.TransparentColor = Color.FromArgb(255, 0, 255);
+
+ // Set the corret imagelist size (7x16 pixels, otherwise the system will either stretch the image or fill in with black blocks)
+ this._customSccGlyphsImageList.ImageSize = new Size(7, 16);
+
+ // Add the custom scc glyphs we support to the list
+ // NOTE: VS2005 and VS2008 are limited to 4 custom scc glyphs (let's hope this will change in future versions)
+ Image sccGlyphs = (Image)Resources.SccGlyphs;
+ this._customSccGlyphsImageList.Images.AddStrip(sccGlyphs);
+ }
+
+ // Return a Win32 HIMAGELIST handle to our imagelist to the shell (by keeping the ImageList a member of the class we guarantee the Win32 object is still valid when the shell needs it)
+ pdwImageListHandle = (uint)this._customSccGlyphsImageList.Handle;
+
+ // Return success (If you don't want to have custom glyphs return VSConstants.E_NOTIMPL)
+ return VSConstants.S_OK;
+
+ }
+
+ #endregion
+
+ private string solutionDirectoryName;
+
+ private string GetFileName(IVsHierarchy hierHierarchy, uint itemidNode)
+ {
+ string pvalue;
+ return hierHierarchy.GetCanonicalName(itemidNode, out pvalue) == VSConstants.S_OK ? //pvalue : null;
+ Path.Combine(solutionDirectoryName, pvalue) : null;
+ }
+
+ private void OpenTracker()
+ {
+ solutionDirectoryName = null;
+
+ IVsSolution sol = (IVsSolution)_sccProvider.GetService(typeof(SVsSolution));
+
+ if (sol != null)
+ {
+ string solutionDirectory, solutionFile, solutionUserOptions;
+ solutionDirectoryName = (sol.GetSolutionInfo(out solutionDirectory, out solutionFile, out solutionUserOptions) == VSConstants.S_OK) ?
+ solutionDirectory : null;
+
+ _statusTracker.Open(solutionDirectoryName);
+ }
+
+ Refresh();
+ }
+
+
+ private void CloseTracker()
+ {
+ _statusTracker.Close();
+ }
+
+ void _statusTracker_OnGitRepoChanged(object sender, EventArgs e)
+ {
+ Refresh();
+ }
+
+ internal void Refresh()
+ {
+ if (solutionDirectoryName != null)
+ {
+ IVsSolution sol = (IVsSolution)_sccProvider.GetService(typeof(SVsSolution));
+ EnumHierarchyItems(sol as IVsHierarchy, VSConstants.VSITEMID_ROOT);
+ }
+ }
+
+ private void EnumHierarchyItems(IVsHierarchy hierarchy, uint itemid)
+ {
+ int hr;
+ IntPtr nestedHierarchyObj;
+ uint nestedItemId;
+ Guid hierGuid = typeof(IVsHierarchy).GUID;
+
+ hr = hierarchy.GetNestedHierarchy(itemid, ref hierGuid, out nestedHierarchyObj, out nestedItemId);
+ if (VSConstants.S_OK == hr && IntPtr.Zero != nestedHierarchyObj)
+ {
+ IVsHierarchy nestedHierarchy = Marshal.GetObjectForIUnknown(nestedHierarchyObj) as IVsHierarchy;
+ Marshal.Release(nestedHierarchyObj);
+ if (nestedHierarchy != null)
+ {
+ EnumHierarchyItems(nestedHierarchy, nestedItemId);
+ }
+ }
+ else
+ {
+ object pVar;
+
+ processNodeFunc(hierarchy, itemid);
+
+ hr = hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_FirstVisibleChild, out pVar);
+ if (VSConstants.S_OK == hr)
+ {
+ uint childId = GetItemId(pVar);
+ while (childId != VSConstants.VSITEMID_NIL)
+ {
+ EnumHierarchyItems(hierarchy, childId);
+ hr = hierarchy.GetProperty(childId, (int)__VSHPROPID.VSHPROPID_NextVisibleSibling, out pVar);
+ if (VSConstants.S_OK == hr)
+ {
+ childId = GetItemId(pVar);
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the item id.
+ /// </summary>
+ /// <param name="pvar">VARIANT holding an itemid.</param>
+ /// <returns>Item Id of the concerned node</returns>
+ private uint GetItemId(object pvar)
+ {
+ if (pvar == null) return VSConstants.VSITEMID_NIL;
+ if (pvar is int) return (uint)(int)pvar;
+ if (pvar is uint) return (uint)pvar;
+ if (pvar is short) return (uint)(short)pvar;
+ if (pvar is ushort) return (uint)(ushort)pvar;
+ if (pvar is long) return (uint)(long)pvar;
+ return VSConstants.VSITEMID_NIL;
+ }
+
+ private void processNodeFunc(IVsHierarchy hierarchy, uint itemid)
+ {
+ object pVal, p2, p3;
+ int hr = hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_ParentHierarchy, out pVal);
+ hr = hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_Parent, out p2);
+ hr = hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_Name, out p3);
+
+ ////if (pVal == null || (int)p2 == -1)
+ if (pVal == null)
+ {
+ //string fileName = GetFileName(hierarchy, itemid);
+ //if (string.IsNullOrEmpty(fileName)) return;
+ //VsStateIcon[] rgsiGlyphs = new VsStateIcon[1];
+ //uint[] rgdwSccStatus = new uint[1];
+ //GetSccGlyph(1, new string[] { fileName }, rgsiGlyphs, rgdwSccStatus);
+
+ var sccProject2 = hierarchy as IVsSccProject2;
+ if (sccProject2 != null)
+ {
+ //hr = sccProject2.SccGlyphChanged(1, new uint[] { itemid }, rgsiGlyphs, rgdwSccStatus);
+ hr = sccProject2.SccGlyphChanged(0, null, null, null);
+ }
+ else
+ {
+ string fileName = GetFileName(hierarchy, itemid);
+ if (string.IsNullOrEmpty(fileName)) return;
+ VsStateIcon[] rgsiGlyphs = new VsStateIcon[1];
+ uint[] rgdwSccStatus = new uint[1];
+ GetSccGlyph(1, new string[] { fileName }, rgsiGlyphs, rgdwSccStatus);
+ hr = hierarchy.SetProperty(itemid, (int)__VSHPROPID.VSHPROPID_StateIconIndex, rgsiGlyphs[0]);
+ }
+ }
+ }
+ }
+}
BIN  lib/DiffieHellman.dll
Binary file not shown
BIN  lib/GitSharp.Core.dll
Binary file not shown
BIN  lib/GitSharp.dll
Binary file not shown
BIN  lib/ICSharpCode.SharpZipLib.dll
Binary file not shown
9,055 lib/ICSharpCode.SharpZipLib.xml
9,055 additions, 0 deletions not shown
BIN  lib/Org.Mentalis.Security.dll
Binary file not shown
BIN  lib/Tamir.SharpSSH.dll
Binary file not shown
BIN  lib/Winterdom.IO.FileMap.dll
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.