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
14 changes: 13 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
env:
DOTNET_NOLOGO: true
SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }}
MSBUILDTERMINALLOGGER: auto
GH_TOKEN: ${{ secrets.GH_TOKEN }}
Configuration: ${{ github.event.inputs.configuration || 'Release' }}
SLEET_FEED_URL: ${{ vars.SLEET_FEED_URL }}

defaults:
run:
Expand Down Expand Up @@ -98,8 +102,16 @@ jobs:
name: pkg
path: bin

- name: ⚙ dotnet
uses: devlooped/actions-dotnet-env@v1

- name: 🙏 build
run: dotnet build

- name: 🧪 test
run: dotnet test --nologo -bl --logger:"console;verbosity=normal"
run: |
dotnet tool update -g dotnet-retest
dotnet retest -- --no-build

- name: 🐛 logs
uses: actions/upload-artifact@v4
Expand Down
63 changes: 58 additions & 5 deletions src/CredentialManager/CredentialManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using DotNetConfig;
using KnownEnvars = GitCredentialManager.Constants.EnvironmentVariables;
using KnownGitCfg = GitCredentialManager.Constants.GitConfiguration;

namespace GitCredentialManager;

Expand Down Expand Up @@ -68,8 +73,60 @@ class CommandContextWrapper(CommandContext context, string? @namespace) : IComma

class SettingsWrapper(ISettings settings, string? @namespace) : ISettings
{
static readonly Config gitconfig;

static SettingsWrapper()
{
string homeDir;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
}
else
{
// On Linux/Mac it's $HOME
homeDir = Environment.GetEnvironmentVariable("HOME")
?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
}

gitconfig = Config.Build(Path.Combine(homeDir, ".gitconfig"));
}

static bool TryGetWrappedSetting(string envarName, string section, string property, out string value)
{
if (envarName != null && Environment.GetEnvironmentVariable(envarName) is { Length: > 0 } envvar)
{
value = envvar;
return true;
}

return gitconfig.TryGetString(section, property, out value);
}

// Overriden namespace to scope credential operations.
public string CredentialNamespace => @namespace ?? settings.CredentialNamespace;
public string CredentialNamespace => @namespace ?? (
TryGetWrappedSetting(KnownEnvars.GcmCredNamespace,
KnownGitCfg.Credential.SectionName, KnownGitCfg.Credential.CredNamespace,
out var ns) ? ns : Constants.DefaultCredentialNamespace);

public string CredentialBackingStore =>
TryGetWrappedSetting(
KnownEnvars.GcmCredentialStore,
KnownGitCfg.Credential.SectionName,
KnownGitCfg.Credential.CredentialStore,
out string credStore)
? credStore
: null!;

public bool UseMsAuthDefaultAccount =>
TryGetWrappedSetting(
KnownEnvars.MsAuthUseDefaultAccount,
KnownGitCfg.Credential.SectionName,
KnownGitCfg.Credential.MsAuthUseDefaultAccount,
out string str)
? str.IsTruthy()
: PlatformUtils.IsDevBox(); // default to true in DevBox environment

#region pass-through impl.

Expand Down Expand Up @@ -99,8 +156,6 @@ class SettingsWrapper(ISettings settings, string? @namespace) : ISettings

public string ParentWindowId => settings.ParentWindowId;

public string CredentialBackingStore => settings.CredentialBackingStore;

public string CustomCertificateBundlePath => settings.CustomCertificateBundlePath;

public string CustomCookieFilePath => settings.CustomCookieFilePath;
Expand All @@ -111,8 +166,6 @@ class SettingsWrapper(ISettings settings, string? @namespace) : ISettings

public int AutoDetectProviderTimeout => settings.AutoDetectProviderTimeout;

public bool UseMsAuthDefaultAccount => settings.UseMsAuthDefaultAccount;

public bool UseSoftwareRendering => settings.UseSoftwareRendering;

public bool AllowUnsafeRemotes => settings.AllowUnsafeRemotes;
Expand Down
12 changes: 4 additions & 8 deletions src/CredentialManager/CredentialManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetConfig" Version="1.2.0" />
<PackageReference Include="NuGetizer" Version="1.2.3" PrivateAssets="all" />
<PackageReference Include="ILRepack" Version="2.0.33" Pack="false" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
Expand All @@ -28,11 +29,7 @@
<ProjectReference Include="..\Core\Core.csproj" Pack="false" />
</ItemGroup>

<Target Name="ILRepack" BeforeTargets="CopyFilesToOutputDirectory"
Inputs="@(IntermediateAssembly -> '%(FullPath)')"
Outputs="$(IntermediateOutputPath)ilrepack.txt"
Returns="@(MergedAssemblies)"
Condition="$(OS) == 'WINDOWS_NT' And Exists(@(IntermediateAssembly -&gt; '%(FullPath)'))">
<Target Name="ILRepack" BeforeTargets="CopyFilesToOutputDirectory" Inputs="@(IntermediateAssembly -> '%(FullPath)')" Outputs="$(IntermediateOutputPath)ilrepack.txt" Returns="@(MergedAssemblies)" Condition="$(OS) == 'WINDOWS_NT' And Exists(@(IntermediateAssembly -> '%(FullPath)'))">
<Message Text="Repacking" Importance="high" />
<ItemGroup>
<MergedAssemblies Include="@(ReferencePath)" Condition="'%(Extension)' == '.dll' And $([MSBuild]::ValueOrDefault('%(FileName)', '')) == 'Core'" />
Expand All @@ -42,7 +39,7 @@
<ILRepackArgs>$(ILRepackArgs) "@(IntermediateAssembly -> '%(FullPath)')"</ILRepackArgs>
<ILRepackArgs>$(ILRepackArgs) @(MergedAssemblies -> '"%(FullPath)"', ' ')</ILRepackArgs>
</PropertyGroup>
<Exec Command='"$(ILRepack)" /internalize:exclude.txt $(ILRepackArgs)' StandardErrorImportance="high" StandardOutputImportance="low" ConsoleToMSBuild="true" ContinueOnError="true">
<Exec Command="&quot;$(ILRepack)&quot; /internalize:exclude.txt $(ILRepackArgs)" StandardErrorImportance="high" StandardOutputImportance="low" ConsoleToMSBuild="true" ContinueOnError="true">
<Output TaskParameter="ConsoleOutput" PropertyName="ILRepackOutput" />
<Output TaskParameter="ExitCode" PropertyName="ExitCode" />
</Exec>
Expand All @@ -54,8 +51,7 @@
<MergedAssembliesToRemove Include="@(MergedAssemblies)" />
<MergedAssembliesToRemove Remove="@(ReferenceToPreserve)" />
</ItemGroup>
<Delete Files="@(MergedAssembliesToRemove -> '$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')"
Condition="Exists('$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')" />
<Delete Files="@(MergedAssembliesToRemove -> '$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')" Condition="Exists('$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageReference Include="Devlooped.CredentialManager" Version="42.*" Condition="!$(CI)" />
<PackageReference Include="Devlooped.CredentialManager" Version="42.42.42-main.*" Condition="!$(CI)" />
<PackageReference Include="Devlooped.CredentialManager" Version="$(Version)" Condition="$(CI) And Exists('$(PackageOutputPath)')" />
</ItemGroup>

Expand Down
Loading