Skip to content

Commit 242073a

Browse files
committed
azrepos: add cmd to clear the authority cache
Add a command to enable clearing of the Azure authority cache manually.
1 parent 8e351df commit 242073a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

docs/usage.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ Read the [Git manual](https://git-scm.com/docs/gitcredentials#_custom_helpers) a
3030
Set your user-level Git configuration (`~/.gitconfig`) to use GCM Core. If you pass
3131
`--system` to these commands, they act on the system-level Git configuration
3232
(`/etc/gitconfig`) instead.
33+
34+
### azure-repos (experimental)
35+
36+
Interact with the Azure Repos host provider to manage the authentication
37+
authority cache.

src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the MIT license.
33
using System;
44
using System.Collections.Generic;
5+
using System.CommandLine;
6+
using System.CommandLine.Invocation;
57
using System.Linq;
68
using System.Net.Http;
79
using System.Threading.Tasks;
@@ -12,7 +14,7 @@
1214

1315
namespace Microsoft.AzureRepos
1416
{
15-
public class AzureReposHostProvider : DisposableObject, IHostProvider, IConfigurableComponent
17+
public class AzureReposHostProvider : DisposableObject, IHostProvider, IConfigurableComponent, ICommandProvider
1618
{
1719
private readonly ICommandContext _context;
1820
private readonly IAzureDevOpsRestApi _azDevOps;
@@ -452,5 +454,29 @@ public Task UnconfigureAsync(ConfigurationTarget target)
452454
}
453455

454456
#endregion
457+
458+
#region ICommandProvider
459+
460+
ProviderCommand ICommandProvider.CreateCommand()
461+
{
462+
var clearCacheCmd = new Command("clear-cache")
463+
{
464+
Description = "Clear the Azure authority cache",
465+
Handler = CommandHandler.Create(ClearCacheCmd),
466+
};
467+
468+
var rootCmd = new ProviderCommand(this);
469+
rootCmd.AddCommand(clearCacheCmd);
470+
return rootCmd;
471+
}
472+
473+
private int ClearCacheCmd()
474+
{
475+
_authorityCache.Clear();
476+
_context.Streams.Out.WriteLine("Authority cache cleared");
477+
return 0;
478+
}
479+
480+
#endregion
455481
}
456482
}

0 commit comments

Comments
 (0)