@@ -117,6 +117,7 @@ public override BIDSFeatureCategories FeatureCategory
117117
118118 public static string PROVIDER_NAME_SOURCESAFE = "MSSCCI:Microsoft Visual SourceSafe" ;
119119 public static string PROVIDER_NAME_TFS = "{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}" ;
120+ public static string PROVIDER_NAME_GIT = "Git" ; //made up this provider name for integration with the previous flow
120121
121122 public override void Exec ( )
122123 {
@@ -138,6 +139,8 @@ public override void Exec()
138139 }
139140 }
140141
142+
143+
141144 private void ExecInternal ( )
142145 {
143146 try
@@ -202,6 +205,23 @@ private void ExecInternal()
202205 }
203206 }
204207 }
208+ else
209+ {
210+ try
211+ {
212+ if ( GitHelper . IsPathInGitRepository ( projItem . get_FileNames ( 0 ) ) )
213+ {
214+ sSourceControlServerName = GitHelper . GetGitRepositoryPath ( projItem . get_FileNames ( 0 ) ) ;
215+ sDefaultSourceSafePath = "$/" + GitHelper . GetRelativePath ( projItem . get_FileNames ( 0 ) ) ;
216+ sProvider = PROVIDER_NAME_GIT ;
217+ }
218+ }
219+ catch ( Exception ex )
220+ {
221+ package . Log . Exception ( "Could not check whether solution is a Git repository" , ex ) ;
222+ }
223+
224+ }
205225 }
206226
207227 if ( projItem . Document != null && ! projItem . Document . Saved )
@@ -213,7 +233,7 @@ private void ExecInternal()
213233 SSIS . SmartDiff form = new BIDSHelper . SSIS . SmartDiff ( ) ;
214234 form . SourceControlProvider = sProvider ;
215235 form . DefaultWindowsPath = projItem . get_FileNames ( 0 ) ;
216- if ( sProvider == PROVIDER_NAME_SOURCESAFE || sProvider == PROVIDER_NAME_TFS )
236+ if ( sProvider == PROVIDER_NAME_SOURCESAFE || sProvider == PROVIDER_NAME_TFS || sProvider == PROVIDER_NAME_GIT )
217237 {
218238 form . DefaultSourceSafePath = sDefaultSourceSafePath ;
219239 form . SourceSafeIniDirectory = sSourceControlServerName ;
@@ -266,6 +286,8 @@ private void ExecInternal()
266286 GetSourceSafeFile ( sSourceControlServerName , form . txtCompare . Text , sOldFile ) ;
267287 else if ( sProvider == PROVIDER_NAME_TFS )
268288 GetTFSFile ( sSourceControlServerName , form . txtCompare . Text , sOldFile ) ;
289+ else if ( sProvider == PROVIDER_NAME_GIT )
290+ GetGitFile ( sSourceControlServerName , form . txtCompare . Text , sOldFile ) ;
269291 sOldFileName += " (server)" ;
270292 }
271293 else
@@ -280,6 +302,8 @@ private void ExecInternal()
280302 GetSourceSafeFile ( sSourceControlServerName , form . txtTo . Text , sNewFile ) ;
281303 else if ( sProvider == PROVIDER_NAME_TFS )
282304 GetTFSFile ( sSourceControlServerName , form . txtTo . Text , sNewFile ) ;
305+ else if ( sProvider == PROVIDER_NAME_GIT )
306+ GetGitFile ( sSourceControlServerName , form . txtTo . Text , sNewFile ) ;
283307 sNewFileName += " (server)" ;
284308 }
285309 else
@@ -328,10 +352,29 @@ public static string[] GetSourceControlVersions(string sIniDirectory, string sSo
328352 {
329353 return GetTFSVersions ( sIniDirectory , sSourceSafePath ) ;
330354 }
355+ else if ( sProvider == PROVIDER_NAME_GIT )
356+ {
357+ return GitHelper . GetHistoryOfFile ( sIniDirectory , sSourceSafePath ) ;
358+ }
331359 throw new Exception ( "Invalid provider" ) ;
332360 }
333361
334362
363+ #region Git Access Methods
364+ private static void GetGitFile ( string sRepositoryPath , string sGitPath , string sLocalPath )
365+ {
366+ string sha = null ;
367+ if ( sGitPath . Contains ( ":" ) )
368+ {
369+ sha = sGitPath . Substring ( sGitPath . IndexOf ( ':' ) + 1 ) ;
370+ sGitPath = sGitPath . Substring ( 0 , sGitPath . IndexOf ( ':' ) ) ;
371+ }
372+
373+ bool bResult = GitHelper . GetSpecificVersionOfFile ( sRepositoryPath , sGitPath , sLocalPath , sha ) ;
374+ if ( ! bResult ) throw new Exception ( "Could not get file from Git" ) ;
375+ }
376+ #endregion
377+
335378 #region SourceSafe Access Methods
336379 //allows late-binding so that you don't have to have SourceSafe installed to compile BIDS Helper
337380 private static string VSS_ASSEMBLY_FULL_NAME = "Microsoft.VisualStudio.SourceSafe.Interop, Version=5.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ;
@@ -732,16 +775,15 @@ private void ShowDiff(string oldFile, string newFile, bool bIgnoreCase, bool bIg
732775 ProjectItem projItem = ( ProjectItem ) hierItem . Object ;
733776 string sTabName = projItem . Name + " (BIDS Helper Smart Diff)" ;
734777
735- System . IServiceProvider provider = null ;
736- if ( projItem . ContainingProject is System . IServiceProvider )
737- {
738- provider = ( System . IServiceProvider ) projItem . ContainingProject ;
739- }
740- else
741- {
742- provider = TabularHelpers . GetTabularServiceProviderFromBimFile ( hierItem , false ) ;
743- }
744- //TODO: test .rdlc inside C# projects
778+ System . IServiceProvider provider = package . ServiceProvider ; //works in all project types even C# projects
779+ //if (projItem.ContainingProject is System.IServiceProvider)
780+ //{
781+ // provider = (System.IServiceProvider)projItem.ContainingProject;
782+ //}
783+ //else
784+ //{
785+ // provider = TabularHelpers.GetTabularServiceProviderFromBimFile(hierItem, false);
786+ //}
745787
746788 Type t = vsAssembly . GetType ( "Microsoft.VisualStudio.Shell.Interop.IVsDifferenceService" ) ;
747789 object oVsDifferenceService = provider . GetService ( vsAssembly . GetType ( "Microsoft.VisualStudio.Shell.Interop.SVsDifferenceService" ) ) ;
@@ -892,6 +934,5 @@ public static string CustomDiffViewer
892934 }
893935 }
894936 }
895-
896-
937+
897938}
0 commit comments