Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fbb0775c1 | |||
| d53e5b2fe4 | |||
| 52944936ed |
4 changed files with 31 additions and 2 deletions
|
|
@ -38,9 +38,26 @@ If the current directory is not in a git repo, a registration already exists by
|
||||||
|
|
||||||
`Get-GitRepoRegistration`
|
`Get-GitRepoRegistration`
|
||||||
|
|
||||||
|
Returns all currently registered git repositories, as well as their current branch.
|
||||||
|
|
||||||
|
```pwsh
|
||||||
|
PS D:/Repos/Project-a> Get-GitRepoRegistration
|
||||||
|
|
||||||
|
Name Location CurrentBranch
|
||||||
|
---- -------- -------------
|
||||||
|
test-repo D:/Repos/Project-a main
|
||||||
|
Project-a D:/Repos/Project-a main
|
||||||
|
```
|
||||||
|
|
||||||
|
The current branch is cached for 15 minutes for performance reasons so it may not be up to date if a git repo has recently had its branch changed.
|
||||||
|
|
||||||
## Show-GitRepoRegistration
|
## Show-GitRepoRegistration
|
||||||
|
|
||||||
`Show-GitRepoRegistration -Name string [-NoStack|-NoSetLocation]`
|
`Show-GitRepoRegistration -Name string [-NoStack|-NoPushLocation]`
|
||||||
|
|
||||||
|
Changes your location to the location of the git repo registered by the given `-Name`. If used without `-NoStack` or its alias `-NoPushLocation`, your original location will be preserved and can be returned to at any time via `Pop-Location`/`Popd`.
|
||||||
|
|
||||||
|
Using `-NoStack`/`-NoPushLocation` will not push your current location onto the stack, and will behave the same as `cd`/`Set-Location`.
|
||||||
|
|
||||||
## Remove-GitRepoRegistration
|
## Remove-GitRepoRegistration
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,11 @@ public class GitManager
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all currently registered git repositories, including additional information such as the git repositories
|
||||||
|
/// current branch.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public List<GitRegistration> ListRepos()
|
public List<GitRegistration> ListRepos()
|
||||||
{
|
{
|
||||||
return _registrations.Select(x =>
|
return _registrations.Select(x =>
|
||||||
|
|
@ -301,6 +306,10 @@ public class GitManager
|
||||||
|
|
||||||
public string Location { get; set; } = null!;
|
public string Location { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current branch of the repository. This value is cached for 15 minutes after which it becomes stale and
|
||||||
|
/// will be refreshed on the next call to this property.
|
||||||
|
/// </summary>
|
||||||
public string CurrentBranch => GetCurrentBranch();
|
public string CurrentBranch => GetCurrentBranch();
|
||||||
|
|
||||||
// TODO: not fully decided on if I want this feature or not, but keeping it in for now
|
// TODO: not fully decided on if I want this feature or not, but keeping it in for now
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ using ModuleCore.Git.Models;
|
||||||
|
|
||||||
namespace PowershellModule.Git.Commands;
|
namespace PowershellModule.Git.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lists all currently registered git repositories, with additional information such as their current branch.
|
||||||
|
/// </summary>
|
||||||
[Cmdlet(VerbsCommon.Get, GitCommands.GitRepoRegistrationNoun)]
|
[Cmdlet(VerbsCommon.Get, GitCommands.GitRepoRegistrationNoun)]
|
||||||
[OutputType(typeof(GitRegistration))]
|
[OutputType(typeof(GitRegistration))]
|
||||||
public class GetGitRepoRegistrationCommand : PSCmdlet
|
public class GetGitRepoRegistrationCommand : PSCmdlet
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class ShowGitRepoRegistrationCommand : PSCmdlet
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Mandatory = false,
|
Mandatory = false,
|
||||||
HelpMessage = "Changes directory directly instead of using Set-Location")]
|
HelpMessage = "Changes directory directly instead of using Set-Location")]
|
||||||
[Alias("NoSetLocation")]
|
[Alias("NoPushLocation")]
|
||||||
public SwitchParameter NoStack { get; set; }
|
public SwitchParameter NoStack { get; set; }
|
||||||
|
|
||||||
protected override void BeginProcessing()
|
protected override void BeginProcessing()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue