From 8d35f6230fe5e6471acc0e51005452d252b85303 Mon Sep 17 00:00:00 2001 From: Tim Heuer Date: Tue, 1 Aug 2023 16:41:20 -0700 Subject: [PATCH] Actually commit changes --- AddActionsWorkflow/AddActionsWorkflow.csproj | 6 +++- .../AddActionsWorkflowPackage.cs | 5 --- .../Commands/AddWorkflowCommand.cs | 33 +++++++++++++++---- AddActionsWorkflow/Options/General.cs | 2 +- vs-publish.json | 3 +- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/AddActionsWorkflow/AddActionsWorkflow.csproj b/AddActionsWorkflow/AddActionsWorkflow.csproj index 4e875ff..48c1f43 100644 --- a/AddActionsWorkflow/AddActionsWorkflow.csproj +++ b/AddActionsWorkflow/AddActionsWorkflow.csproj @@ -68,6 +68,10 @@ VsixManifestGenerator source.extension.cs + + Always + true + Always true @@ -93,7 +97,7 @@ 3.6.4 - + 17.0.507 diff --git a/AddActionsWorkflow/AddActionsWorkflowPackage.cs b/AddActionsWorkflow/AddActionsWorkflowPackage.cs index 4906883..7e92e47 100644 --- a/AddActionsWorkflow/AddActionsWorkflowPackage.cs +++ b/AddActionsWorkflow/AddActionsWorkflowPackage.cs @@ -20,10 +20,5 @@ public sealed class AddActionsWorkflowPackage : ToolkitPackage protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress progress) { await this.RegisterCommandsAsync(); - - // telemetry rating - RatingPrompt rating = new("TimHeuer.AddActionsWorkflow", Vsix.Name, await General.GetLiveInstanceAsync()); - rating.RegisterSuccessfulUsage(); - await rating.PromptAsync(); } } diff --git a/AddActionsWorkflow/Commands/AddWorkflowCommand.cs b/AddActionsWorkflow/Commands/AddWorkflowCommand.cs index bea720d..13846ed 100644 --- a/AddActionsWorkflow/Commands/AddWorkflowCommand.cs +++ b/AddActionsWorkflow/Commands/AddWorkflowCommand.cs @@ -1,8 +1,10 @@ using AddActionsWorkflow.Options; using CliWrap; using LibGit2Sharp; +using Microsoft; using System.Diagnostics; using System.IO; +using System.Linq; using System.Text; using System.Threading.Tasks; @@ -48,12 +50,12 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) proj = await sln.AddSolutionFolderAsync(options.SolutionFolderName); _ = await proj?.AddExistingFilesAsync(Path.Combine(slnDir, @$".github\workflows\{finaleWorkflowname}.yaml")); - await VS.StatusBar.ShowMessageAsync("GitHub Actions Worklfow creation finished."); + await VS.StatusBar.ShowMessageAsync("GitHub Actions Workflow creation finished."); } else { // didn't happen, show an error - await VS.StatusBar.ShowMessageAsync("GitHub Actions Worklfow creation failed."); + await VS.StatusBar.ShowMessageAsync("GitHub Actions Workflow creation failed."); } } @@ -89,14 +91,11 @@ internal async Task GetGitRootDirAsync(string workingDirectory, bool use await VS.StatusBar.ShowMessageAsync("Establishing git root directory..."); var rootGitDir = workingDirectory; - while (!Directory.Exists(Path.Combine(rootGitDir, ".git"))) - { - rootGitDir = Path.GetFullPath(Path.Combine(rootGitDir, "..")); - } + FindGitFolder(rootGitDir, out string gitPath); try { - using (var repo = new Repository(rootGitDir)) + using (var repo = new Repository(gitPath)) { if (useCurrentBranch) branchName = repo.Head.FriendlyName; rootGitDir = repo.Info.WorkingDirectory; @@ -109,4 +108,24 @@ internal async Task GetGitRootDirAsync(string workingDirectory, bool use return rootGitDir; } + + internal void FindGitFolder(string path, out string foundPath) + { + foundPath = null; + // Check if the current directory contains a .git folder + if (Directory.Exists(Path.Combine(path, ".git"))) + { + foundPath = path; + return; + } + else + { + string parentPath = Directory.GetParent(path)?.FullName; + if (!string.IsNullOrEmpty(parentPath)) + { + FindGitFolder(parentPath, out foundPath); // Recursively search the parent directory + } + } + return; + } } diff --git a/AddActionsWorkflow/Options/General.cs b/AddActionsWorkflow/Options/General.cs index 6f8133b..700b6d1 100644 --- a/AddActionsWorkflow/Options/General.cs +++ b/AddActionsWorkflow/Options/General.cs @@ -9,7 +9,7 @@ internal partial class OptionsProvider public class GeneralOptions : BaseOptionPage { } } -public class General : BaseOptionModel, IRatingConfig +public class General : BaseOptionModel { [Category("Generator")] [DisplayName("Default file name")] diff --git a/vs-publish.json b/vs-publish.json index 83d0a82..24b3156 100644 --- a/vs-publish.json +++ b/vs-publish.json @@ -7,5 +7,6 @@ }, "overview": "README.md", "publisher": "TimHeuer", - "repo": "https://github.com/timheuer/AddActionsWorkflow" + "repo": "https://github.com/timheuer/AddActionsWorkflow", + "qna": false }