Skip to content

Commit 78c647b

Browse files
committed
Refactor wrappers to single file to allow external use
Other repositories can sync this file as-is (i.e. via dotnet-file sync) and reuse the wrappers to also get git-less usage of GCM in their own scenarios.
1 parent 32c27e8 commit 78c647b

File tree

3 files changed

+207
-204
lines changed

3 files changed

+207
-204
lines changed
Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using GitCredentialManager.Interop.Windows;
1+
using System.Collections.Generic;
42

53
namespace GitCredentialManager;
64

@@ -42,113 +40,4 @@ class CredentialManagerStore(ICredentialStore store, ICommandContext context) :
4240
public IList<string> GetAccounts(string service) => store.GetAccounts(service);
4341
public bool Remove(string service, string account) => store.Remove(service, account);
4442
}
45-
46-
class CommandContextWrapper(CommandContext context, string? @namespace) : ICommandContext
47-
{
48-
readonly ISettings settings = new SettingsWrapper(
49-
context.Settings is WindowsSettings ?
50-
new NoGitWindowsSettings(context.Environment, context.Git, context.Trace) :
51-
new NoGitSettings(context.Environment, context.Git), @namespace);
52-
53-
public ISettings Settings => settings;
54-
55-
#region pass-through impl.
56-
57-
public string ApplicationPath { get => ((ICommandContext)context).ApplicationPath; set => ((ICommandContext)context).ApplicationPath = value; }
58-
59-
public string InstallationDirectory => ((ICommandContext)context).InstallationDirectory;
60-
61-
public IStandardStreams Streams => ((ICommandContext)context).Streams;
62-
63-
public ITerminal Terminal => ((ICommandContext)context).Terminal;
64-
65-
public ISessionManager SessionManager => ((ICommandContext)context).SessionManager;
66-
67-
public ITrace Trace => ((ICommandContext)context).Trace;
68-
69-
public ITrace2 Trace2 => ((ICommandContext)context).Trace2;
70-
71-
public IFileSystem FileSystem => ((ICommandContext)context).FileSystem;
72-
73-
public ICredentialStore CredentialStore => ((ICommandContext)context).CredentialStore;
74-
75-
public IHttpClientFactory HttpClientFactory => ((ICommandContext)context).HttpClientFactory;
76-
77-
public IGit Git => new NoGit(context.Git);
78-
79-
public IEnvironment Environment => ((ICommandContext)context).Environment;
80-
81-
public IProcessManager ProcessManager => ((ICommandContext)context).ProcessManager;
82-
83-
public void Dispose() => ((IDisposable)context).Dispose();
84-
85-
#endregion
86-
}
87-
88-
class NoGitSettings(IEnvironment environment, IGit git) : Settings(environment, new NoGit(git)) { }
89-
90-
class NoGitWindowsSettings(IEnvironment environment, IGit git, ITrace trace) : WindowsSettings(environment, new NoGit(git), trace) { }
91-
92-
class SettingsWrapper(ISettings settings, string? @namespace) : ISettings
93-
{
94-
public string CredentialNamespace => @namespace ?? settings.CredentialNamespace;
95-
96-
#region pass-through impl.
97-
98-
public string CredentialBackingStore => settings.CredentialBackingStore;
99-
100-
public bool UseMsAuthDefaultAccount => settings.UseMsAuthDefaultAccount;
101-
102-
public IEnumerable<string> GetSettingValues(string envarName, string section, string property, bool isPath)
103-
=> settings.GetSettingValues(envarName, section, property, isPath);
104-
105-
public bool GetTracingEnabled(out string value) => settings.GetTracingEnabled(out value);
106-
public bool TryGetPathSetting(string envarName, string section, string property, out string value) => settings.TryGetPathSetting(envarName, section, property, out value);
107-
public bool TryGetSetting(string envarName, string section, string property, out string value) => settings.TryGetSetting(envarName, section, property, out value);
108-
109-
public Uri RemoteUri { get => settings.RemoteUri; set => settings.RemoteUri = value; }
110-
111-
public bool IsDebuggingEnabled => settings.IsDebuggingEnabled;
112-
113-
public bool IsTerminalPromptsEnabled => settings.IsTerminalPromptsEnabled;
114-
115-
public bool IsGuiPromptsEnabled { get => settings.IsGuiPromptsEnabled; set => settings.IsGuiPromptsEnabled = value; }
116-
117-
public bool IsInteractionAllowed => settings.IsInteractionAllowed;
118-
119-
public bool IsSecretTracingEnabled => settings.IsSecretTracingEnabled;
120-
121-
public bool IsMsalTracingEnabled => settings.IsMsalTracingEnabled;
122-
123-
public string ProviderOverride => settings.ProviderOverride;
124-
125-
public string LegacyAuthorityOverride => settings.LegacyAuthorityOverride;
126-
127-
public bool IsWindowsIntegratedAuthenticationEnabled => settings.IsWindowsIntegratedAuthenticationEnabled;
128-
129-
public bool IsCertificateVerificationEnabled => settings.IsCertificateVerificationEnabled;
130-
131-
public bool AutomaticallyUseClientCertificates => settings.AutomaticallyUseClientCertificates;
132-
133-
public string ParentWindowId => settings.ParentWindowId;
134-
135-
public string CustomCertificateBundlePath => settings.CustomCertificateBundlePath;
136-
137-
public string CustomCookieFilePath => settings.CustomCookieFilePath;
138-
139-
public TlsBackend TlsBackend => settings.TlsBackend;
140-
141-
public bool UseCustomCertificateBundleWithSchannel => settings.UseCustomCertificateBundleWithSchannel;
142-
143-
public int AutoDetectProviderTimeout => settings.AutoDetectProviderTimeout;
144-
145-
public bool UseSoftwareRendering => settings.UseSoftwareRendering;
146-
147-
public bool AllowUnsafeRemotes => settings.AllowUnsafeRemotes;
148-
149-
public void Dispose() => settings.Dispose();
150-
public ProxyConfiguration GetProxyConfiguration() => settings.GetProxyConfiguration();
151-
public Trace2Settings GetTrace2Settings() => settings.GetTrace2Settings();
152-
#endregion
153-
}
15443
}

src/CredentialManager/NoGit.cs

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)