public static bool ValidateSolution(string solutionDirectory, string solutionFile) { // We set solution info from solution load event on the filter, and display the filter button at the same time, // so just to be safe, check if info was set before user clicked the button if (string.IsNullOrEmpty(solutionDirectory) || string.IsNullOrEmpty(solutionFile)) { ErrorPresenter.ShowError( "Unable to get Solution from Visual Studio services.\n" + "If the error persists, please restart Visual Studio with this solution as the start-up solution."); return(false); } return(true); }
public static bool ValidateBranch(IGitBranchDifferPackage package) { if (package is null) { MessageBox.Show( "Unable to load Git Branch Differ plug-in. It is possible Visual Studio is still initializing, please wait and try again.", "Git Branch Differ"); return(false); } if (package.BranchToDiffAgainst is null || package.BranchToDiffAgainst == string.Empty) { ErrorPresenter.ShowError("Branch to diff against is not set. Go to Options -> Git Branch Differ -> Set \"Branch To Diff Against\""); return(false); } return(true); }
public void ShowFileDiffWithBaseBranch(string baseBranchToDiffAgainst) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); var fileDiffController = DIContainer.Instance.GetService(typeof(GitFileDiffController)) as GitFileDiffController; Assumes.Present(fileDiffController); // Get branch pairs to diff and Get the revision of file in the branch-to-diff-against try { var branchPairs = fileDiffController.GetDiffBranchPair(this.solutionPath, baseBranchToDiffAgainst); var baseBranchFilePath = string.IsNullOrEmpty(this.OldDocumentPath) ? this.DocumentPath : this.OldDocumentPath; var leftFileMoniker = fileDiffController.GetBaseBranchRevisionOfFile(this.solutionPath, baseBranchToDiffAgainst, baseBranchFilePath); var rightFileMoniker = this.DocumentPath; this.PresentComparisonWindow(branchPairs, leftFileMoniker, rightFileMoniker); } catch (GitOperationException e) { ErrorPresenter.ShowError(e.Message); } }
protected override async Task <IReadOnlyObservableSet> GetIncludedItemsAsync(IEnumerable <IVsHierarchyItem> rootItems) { if (BranchDiffFilterValidator.ValidateBranch(this.package)) { // Create new tag tables everytime the filter is applied BranchDiffFilterProvider.TagManager.CreateTagTables(); IVsHierarchyItem root = HierarchyUtilities.FindCommonAncestor(rootItems); if (BranchDiffFilterValidator.ValidateSolution(this.solutionDirectory, this.solutionFile)) { try { // TODO: The solution directory path may not always be the Git repo path! // Git repo could be setup higher up. Write a service to find the Git repo upwards in the heirarchy and pass that here. this.changeSet = this.branchDiffWorker.GenerateDiff(this.solutionDirectory, this.package.BranchToDiffAgainst); } catch (GitOperationException e) { ErrorPresenter.ShowError(e.Message); return(null); } IReadOnlyObservableSet <IVsHierarchyItem> sourceItems = await this.vsHierarchyItemCollectionProvider.GetDescendantsAsync( root.HierarchyIdentity.NestedHierarchy, CancellationToken); IFilteredHierarchyItemSet includedItems = await this.vsHierarchyItemCollectionProvider.GetFilteredHierarchyItemsAsync( sourceItems, ShouldIncludeInFilter, CancellationToken); return(includedItems); } } return(null); }