Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{
await "dotnet tool restore";
await "dotnet build -c Release --verbosity minimal";
await "dotnet test --configuration Release --logger GitHubActions -- RunConfiguration.CollectSourceInformation=true";
});

app.Add("publish", async (Cancel _) =>
Expand Down
15 changes: 12 additions & 3 deletions src/Elastic.Markdown/IO/GitConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ public static GitConfiguration Create(IFileSystem fileSystem)
if (!gitConfig.Exists)
throw new Exception($"{Paths.Root.FullName} is not a git repository.");

var head = Read(".git/HEAD").Replace("ref: ", string.Empty);
var gitRef = Read(".git/" + head);
var head = Read(".git/HEAD");
var gitRef = head;
var branch = head.Replace("refs/heads/", string.Empty);
//not detached HEAD
if (head.StartsWith("ref:"))
{
head = head.Replace("ref: ", string.Empty);
gitRef = Read(".git/" + head);
}
else
branch = "detached/head";

var ini = new FileIniDataParser();
using var stream = gitConfig.OpenRead();
Expand All @@ -42,7 +50,8 @@ public static GitConfiguration Create(IFileSystem fileSystem)
remote = BranchTrackingRemote("main", config);
if (string.IsNullOrEmpty(remote))
remote = BranchTrackingRemote("master", config);

if (string.IsNullOrEmpty(remote))
remote = Environment.GetEnvironmentVariable("GITHUB_REPOSITORY") ?? "elastic/docs-builder-unknown";

return new GitConfiguration { Ref = gitRef, Branch = branch, Remote = remote };

Expand Down
40 changes: 21 additions & 19 deletions tests/Elastic.Markdown.Tests/Elastic.Markdown.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="21.0.29" />
<PackageReference Include="Verify.Xunit" Version="27.0.1" />
<PackageReference Include="xunit" Version="2.9.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="FluentAssertions" Version="6.12.1"/>
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="21.0.29"/>
<PackageReference Include="Verify.Xunit" Version="27.0.1"/>
<PackageReference Include="xunit" Version="2.9.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Elastic.Markdown\Elastic.Markdown.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Elastic.Markdown\Elastic.Markdown.csproj"/>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
Expand Down
Loading