Skip to content

Commit

Permalink
Actually commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
timheuer committed Aug 1, 2023
1 parent 4a5778d commit 8d35f62
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
6 changes: 5 additions & 1 deletion AddActionsWorkflow/AddActionsWorkflow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<Generator>VsixManifestGenerator</Generator>
<LastGenOutput>source.extension.cs</LastGenOutput>
</None>
<Content Include="lib\win32\x64\git2-e632535.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="LICENSE.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
Expand All @@ -93,7 +97,7 @@
<PackageReference Include="CliWrap">
<Version>3.6.4</Version>
</PackageReference>
<PackageReference Include="Community.VisualStudio.Toolkit.17">
<PackageReference Include="Community.VisualStudio.Toolkit.17" ExcludeAssets="runtime">
<Version>17.0.507</Version>
</PackageReference>
<PackageReference Include="Community.VisualStudio.VSCT" Version="16.0.29.6" PrivateAssets="all" />
Expand Down
5 changes: 0 additions & 5 deletions AddActionsWorkflow/AddActionsWorkflowPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,5 @@ public sealed class AddActionsWorkflowPackage : ToolkitPackage
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await this.RegisterCommandsAsync();

// telemetry rating
RatingPrompt rating = new("TimHeuer.AddActionsWorkflow", Vsix.Name, await General.GetLiveInstanceAsync());
rating.RegisterSuccessfulUsage();
await rating.PromptAsync();
}
}
33 changes: 26 additions & 7 deletions AddActionsWorkflow/Commands/AddWorkflowCommand.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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.");
}
}

Expand Down Expand Up @@ -89,14 +91,11 @@ internal async Task<String> 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;
Expand All @@ -109,4 +108,24 @@ internal async Task<String> 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;
}
}
2 changes: 1 addition & 1 deletion AddActionsWorkflow/Options/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal partial class OptionsProvider
public class GeneralOptions : BaseOptionPage<General> { }
}

public class General : BaseOptionModel<General>, IRatingConfig
public class General : BaseOptionModel<General>
{
[Category("Generator")]
[DisplayName("Default file name")]
Expand Down
3 changes: 2 additions & 1 deletion vs-publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
},
"overview": "README.md",
"publisher": "TimHeuer",
"repo": "https://github.com/timheuer/AddActionsWorkflow"
"repo": "https://github.com/timheuer/AddActionsWorkflow",
"qna": false
}

0 comments on commit 8d35f62

Please sign in to comment.