Skip to content

Commit b69183f

Browse files
committed
Rename repo to git-aliases-extra
1 parent 884fd45 commit b69183f

File tree

7 files changed

+173
-41
lines changed

7 files changed

+173
-41
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
if: startsWith(github.ref, 'refs/tags/v')
1717
shell: pwsh
1818
run: |
19-
$manifest = Test-ModuleManifest -Path .\GitAliases.Extras.psd1 -ErrorAction Stop
19+
$manifest = Test-ModuleManifest -Path .\git-aliases-extra.psd1 -ErrorAction Stop
2020
$tagVersion = '${{ github.ref_name }}'.TrimStart('v')
2121
if ($manifest.Version.ToString() -ne $tagVersion) {
2222
throw "Manifest version '$($manifest.Version)' does not match tag version '$tagVersion'."
@@ -40,7 +40,7 @@ jobs:
4040
throw "PSGALLERY_API_KEY secret is not set."
4141
}
4242
43-
$manifest = Test-ModuleManifest -Path .\GitAliases.Extras.psd1 -ErrorAction Stop
43+
$manifest = Test-ModuleManifest -Path .\git-aliases-extra.psd1 -ErrorAction Stop
4444
$moduleName = $manifest.Name
4545
$moduleVersion = $manifest.Version.ToString()
4646

README.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,70 @@
1-
# GitAliases.Extras
1+
# git-aliases-extra
22

3-
Custom PowerShell git aliases and tab completion helpers on top of `posh-git` and `git-aliases`.
3+
Custom PowerShell git aliases and tab completion helpers on top of `posh-git` and `git-aliases` with full tab completion support for aliased commands.
4+
5+
Mainly inspired by: https://github.com/zh30/zsh-shortcut-git
46

57
## Module installation
68

79
Install from PowerShell Gallery:
810

911
```powershell
10-
Install-Module GitAliases.Extras -Scope CurrentUser
11-
Import-Module GitAliases.Extras
12+
Install-Module git-aliases-extra -Scope CurrentUser
13+
Import-Module git-aliases-extra
1214
```
1315

1416
Install from source:
1517

1618
```powershell
17-
git clone https://github.com/PhysShell/GitAliases.Extras.git "$HOME\Documents\PowerShell\Modules\GitAliases.Extras"
18-
Import-Module GitAliases.Extras
19+
git clone https://github.com/PhysShell/git-aliases-extra.git "$HOME\Documents\PowerShell\Modules\git-aliases-extra"
20+
Import-Module git-aliases-extra
1921
```
2022

2123
Install dependencies:
2224

2325
```powershell
2426
Install-Module posh-git -Scope CurrentUser -Force
2527
Install-Module git-aliases -Scope CurrentUser -Force
26-
Install-Module GitAliases.Extras -Scope CurrentUser -Force
28+
Install-Module git-aliases-extra -Scope CurrentUser -Force
29+
```
30+
31+
## Alias discovery
32+
33+
Use `Get-Git-Aliases` to inspect available aliases and their definitions.
34+
35+
List all aliases:
36+
37+
```powershell
38+
Get-Git-Aliases
39+
```
40+
41+
Show one alias:
42+
43+
```powershell
44+
Get-Git-Aliases grsh
2745
```
2846

47+
List only aliases from `git-aliases`:
48+
49+
```powershell
50+
Get-Git-Aliases -Base
51+
```
52+
53+
List only aliases from `git-aliases-extra`:
54+
55+
```powershell
56+
Get-Git-Aliases -Extras
57+
```
58+
59+
`Get-Git-Aliases` includes aliases from both:
60+
- `git-aliases`
61+
- `git-aliases-extra`
62+
63+
Default output order:
64+
- `extras` group first
65+
- `base` group second
66+
- alphabetical order inside each group
67+
2968
## Quality checks
3069

3170
Run both lint and tests:
@@ -72,7 +111,7 @@ This repository includes:
72111
To publish from CI:
73112

74113
1. Add repository secret `PSGALLERY_API_KEY`.
75-
2. Bump `ModuleVersion` in `GitAliases.Extras.psd1`.
114+
2. Bump `ModuleVersion` in `git-aliases-extra.psd1`.
76115
3. Push a tag `v<ModuleVersion>` (for example, `v0.1.0`) or run the publish workflow manually.
77116

78117
## What CI checks
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
RootModule = 'GitAliases.Extras.psm1'
2+
RootModule = 'git-aliases-extra.psm1'
33
ModuleVersion = '0.1.0'
44
GUID = 'a5c2859e-7dce-4853-9db5-8cb7927dbdda'
55
Author = 'PhysShell'
@@ -47,9 +47,9 @@
4747
PrivateData = @{
4848
PSData = @{
4949
Tags = @('git', 'aliases', 'completion', 'posh-git', 'powershell')
50-
ProjectUri = 'https://github.com/PhysShell/GitAliases.Extras'
51-
LicenseUri = 'https://github.com/PhysShell/GitAliases.Extras/blob/main/LICENSE'
52-
RepositorySourceLocation = 'https://github.com/PhysShell/GitAliases.Extras'
50+
ProjectUri = 'https://github.com/PhysShell/git-aliases-extra'
51+
LicenseUri = 'https://github.com/PhysShell/git-aliases-extra/blob/main/LICENSE'
52+
RepositorySourceLocation = 'https://github.com/PhysShell/git-aliases-extra'
5353
ReleaseNotes = 'Standalone module extracted from dotfiles.'
5454
}
5555
}
Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===================================================================
2-
# GitAliases.Extras.psm1
2+
# git-aliases-extra.psm1
33
#
44
# Extends posh-git and git-aliases with custom functions and
55
# adds robust tab completion for all git aliases.
@@ -158,6 +158,11 @@ function Format-GitAliasDefinitionSafe {
158158
}
159159

160160
function Get-GitAliasEntries {
161+
param(
162+
[ValidateSet('all', 'base', 'extras')]
163+
[string]$Source = 'all'
164+
)
165+
161166
$blacklist = @(
162167
'Get-Git-CurrentBranch',
163168
'Remove-Alias',
@@ -169,13 +174,17 @@ function Get-GitAliasEntries {
169174
)
170175

171176
$modulePriority = @{
172-
'GitAliases.Extras' = 0
177+
'git-aliases-extra' = 0
173178
'git-aliases' = 1
174179
}
180+
$moduleSource = @{
181+
'git-aliases-extra' = 'extras'
182+
'git-aliases' = 'base'
183+
}
175184

176185
$entries = @()
177186
$aliasNamePattern = '^g[0-9A-Za-z!]+$'
178-
foreach ($moduleName in @('GitAliases.Extras', 'git-aliases')) {
187+
foreach ($moduleName in @('git-aliases-extra', 'git-aliases')) {
179188
$commands = Get-Command -Module $moduleName -ErrorAction SilentlyContinue |
180189
Where-Object {
181190
$_.Name -notin $blacklist -and
@@ -197,39 +206,72 @@ function Get-GitAliasEntries {
197206
Name = $command.Name
198207
Definition = $definition
199208
ModuleName = $moduleName
209+
Source = $moduleSource[$moduleName]
200210
Priority = $modulePriority[$moduleName]
201211
}
202212
}
203213
}
204214

205-
return $entries |
206-
Sort-Object Priority, Name |
207-
Group-Object Name |
208-
ForEach-Object { $_.Group[0] } |
209-
Sort-Object Name
215+
if ($Source -ne 'all') {
216+
return $entries |
217+
Where-Object { $_.Source -eq $Source } |
218+
Sort-Object Name
219+
}
220+
221+
$ordered = $entries | Sort-Object Priority, Name
222+
$seen = @{}
223+
$result = foreach ($entry in $ordered) {
224+
if (-not $seen.ContainsKey($entry.Name)) {
225+
$seen[$entry.Name] = $true
226+
$entry
227+
}
228+
}
229+
230+
return @($result)
210231
}
211232

212233
function Get-Git-Aliases {
213234
[CmdletBinding()]
214235
param(
215236
[AllowEmptyString()]
216-
[string]$Alias
237+
[string]$Alias,
238+
[switch]$Base,
239+
[switch]$Extras
217240
)
218241

242+
if ($Base -and $Extras) {
243+
Write-Error "Use either -Base or -Extras, not both." -ErrorAction Stop
244+
}
245+
246+
$source = 'all'
247+
if ($Base) { $source = 'base' }
248+
if ($Extras) { $source = 'extras' }
249+
219250
$Alias = if ($null -eq $Alias) { '' } else { $Alias.Trim() }
220-
$aliases = Get-GitAliasEntries
251+
$aliases = Get-GitAliasEntries -Source $source
221252

222253
if (-not ([string]::IsNullOrWhiteSpace($Alias))) {
223254
$foundAlias = $aliases | Where-Object { $_.Name -eq $Alias } | Select-Object -First 1
224255
if ($null -eq $foundAlias) {
225-
Write-Error "Alias '$Alias' not found." -ErrorAction Stop
256+
$scopeText = switch ($source) {
257+
'base' { ' in base aliases' }
258+
'extras' { ' in extras aliases' }
259+
default { '' }
260+
}
261+
Write-Error ("Alias '{0}' not found{1}." -f $Alias, $scopeText) -ErrorAction Stop
226262
}
227263

228264
return $foundAlias.Definition
229265
}
230266

267+
if ($source -in @('base', 'extras')) {
268+
return $aliases |
269+
Select-Object Name, Definition |
270+
Format-Table -AutoSize -Wrap
271+
}
272+
231273
return $aliases |
232-
Select-Object Name, ModuleName, Definition |
274+
Select-Object Name, Source, Definition |
233275
Format-Table -AutoSize -Wrap
234276
}
235277

tests/GitAliases.Extras.Integration.Tests.ps1 renamed to tests/git-aliases-extra.Integration.Tests.ps1

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ BeforeAll {
6969

7070
[string]$script:RepoRoot = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..') |
7171
Select-Object -ExpandProperty Path -First 1
72-
$script:ModuleManifest = Join-Path $script:RepoRoot 'GitAliases.Extras.psd1'
72+
$script:ModuleManifest = Join-Path $script:RepoRoot 'git-aliases-extra.psd1'
7373

7474
if (Get-Module -ListAvailable -Name git-aliases) {
7575
Import-Module git-aliases -DisableNameChecking -ErrorAction SilentlyContinue
@@ -80,12 +80,12 @@ BeforeAll {
8080
}
8181

8282
AfterAll {
83-
Remove-Module GitAliases.Extras -Force -ErrorAction SilentlyContinue
83+
Remove-Module git-aliases-extra -Force -ErrorAction SilentlyContinue
8484
}
8585

86-
Describe 'GitAliases.Extras module' {
86+
Describe 'git-aliases-extra module' {
8787
It 'imports successfully' {
88-
Get-Module GitAliases.Extras | Should -Not -BeNullOrEmpty
88+
Get-Module git-aliases-extra | Should -Not -BeNullOrEmpty
8989
}
9090

9191
It 'exports expected commands' {
@@ -106,11 +106,62 @@ Describe 'GitAliases.Extras module' {
106106
$definition | Should -Match 'git reset --soft HEAD~1'
107107
}
108108

109-
It 'Get-Git-Aliases lists aliases from GitAliases.Extras' {
109+
It 'Get-Git-Aliases lists aliases from git-aliases-extra' {
110110
$allAliasesText = (Get-Git-Aliases | Out-String)
111111
$allAliasesText | Should -Match '(?im)^\s*grsh\s+'
112112
$allAliasesText | Should -Match '(?im)^\s*gfp\s+'
113113
}
114+
115+
It 'Get-Git-Aliases returns extras first and keeps alphabetical order per group' {
116+
$allAliasesText = (Get-Git-Aliases | Out-String)
117+
$lines = $allAliasesText -split "`r?`n"
118+
119+
$extrasNames = @()
120+
$baseNames = @()
121+
$firstBaseLine = -1
122+
$lastExtrasLine = -1
123+
124+
for ($i = 0; $i -lt $lines.Count; $i++) {
125+
$line = $lines[$i]
126+
if ($line -match '^\s*([^\s]+)\s+extras\s+') {
127+
$extrasNames += $matches[1]
128+
$lastExtrasLine = $i
129+
continue
130+
}
131+
132+
if ($line -match '^\s*([^\s]+)\s+base\s+') {
133+
$baseNames += $matches[1]
134+
if ($firstBaseLine -lt 0) {
135+
$firstBaseLine = $i
136+
}
137+
}
138+
}
139+
140+
$extrasNames.Count | Should -BeGreaterThan 0
141+
$baseNames.Count | Should -BeGreaterThan 0
142+
(($extrasNames -join "`n") -eq (($extrasNames | Sort-Object) -join "`n")) | Should -BeTrue
143+
(($baseNames -join "`n") -eq (($baseNames | Sort-Object) -join "`n")) | Should -BeTrue
144+
$lastExtrasLine | Should -BeLessThan $firstBaseLine
145+
}
146+
147+
It 'Get-Git-Aliases -Base returns only base aliases' {
148+
$baseAliasesText = (Get-Git-Aliases -Base | Out-String)
149+
$baseAliasesText | Should -Match '(?im)^\s*ga\s+'
150+
$baseAliasesText | Should -Not -Match '(?im)^\s*grsh\s+'
151+
}
152+
153+
It 'Get-Git-Aliases -Extras returns only extras aliases' {
154+
$extrasAliasesText = (Get-Git-Aliases -Extras | Out-String)
155+
$extrasAliasesText | Should -Match '(?im)^\s*grsh\s+'
156+
$extrasAliasesText | Should -Not -Match '(?im)^\s*gaa\s+'
157+
}
158+
159+
It 'Get-Git-Aliases respects source filter for single alias lookup' {
160+
$extrasDefinition = Get-Git-Aliases -Alias grsh -Extras
161+
$extrasDefinition | Should -Match 'git reset --soft HEAD~1'
162+
163+
{ Get-Git-Aliases -Alias grsh -Base } | Should -Throw
164+
}
114165
}
115166

116167
Describe 'gfp integration' {
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Set-StrictMode -Version Latest
44
BeforeAll {
55
[string]$script:RepoRoot = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..') |
66
Select-Object -ExpandProperty Path -First 1
7-
$script:ModuleManifest = Join-Path $script:RepoRoot 'GitAliases.Extras.psd1'
7+
$script:ModuleManifest = Join-Path $script:RepoRoot 'git-aliases-extra.psd1'
88

99
if (Get-Module -ListAvailable -Name git-aliases) {
1010
Import-Module git-aliases -DisableNameChecking -ErrorAction SilentlyContinue
@@ -14,18 +14,18 @@ BeforeAll {
1414
}
1515

1616
AfterAll {
17-
Remove-Module GitAliases.Extras -Force -ErrorAction SilentlyContinue
17+
Remove-Module git-aliases-extra -Force -ErrorAction SilentlyContinue
1818
}
1919

20-
Describe 'GitAliases.Extras manifest' {
20+
Describe 'git-aliases-extra manifest' {
2121
It 'is a valid module manifest' {
2222
$manifest = Test-ModuleManifest -Path $script:ModuleManifest -ErrorAction Stop
23-
$manifest.Name | Should -Be 'GitAliases.Extras'
23+
$manifest.Name | Should -Be 'git-aliases-extra'
2424
}
2525

2626
It 'declares gallery metadata and required modules' {
2727
$manifest = Import-PowerShellDataFile -Path $script:ModuleManifest
28-
$manifest.PrivateData.PSData.ProjectUri | Should -Match '^https://github.com/PhysShell/GitAliases\.Extras'
28+
$manifest.PrivateData.PSData.ProjectUri | Should -Match '^https://github.com/PhysShell/git-aliases-extra'
2929
$manifest.PrivateData.PSData.LicenseUri | Should -Match '/LICENSE$'
3030

3131
$requiredModuleNames = @($manifest.RequiredModules | ForEach-Object {
@@ -36,9 +36,9 @@ Describe 'GitAliases.Extras manifest' {
3636
}
3737
}
3838

39-
Describe 'GitAliases.Extras module exports' {
39+
Describe 'git-aliases-extra module exports' {
4040
It 'imports successfully' {
41-
Get-Module GitAliases.Extras | Should -Not -BeNullOrEmpty
41+
Get-Module git-aliases-extra | Should -Not -BeNullOrEmpty
4242
}
4343

4444
It 'exports key commands' {
@@ -48,7 +48,7 @@ Describe 'GitAliases.Extras module exports' {
4848
}
4949
}
5050

51-
Describe 'GitAliases.Extras tooling' {
51+
Describe 'git-aliases-extra tooling' {
5252
It 'includes install-hooks and hook templates' {
5353
(Test-Path -LiteralPath (Join-Path $script:RepoRoot 'tools\install-hooks.ps1')) | Should -BeTrue
5454
(Test-Path -LiteralPath (Join-Path $script:RepoRoot 'tools\hooks\pre-commit')) | Should -BeTrue

tools/lint.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ if (-not (Test-Path -LiteralPath $settings)) {
2424
}
2525

2626
$targets = @(
27-
(Join-Path $repoRoot 'GitAliases.Extras.psm1'),
28-
(Join-Path $repoRoot 'GitAliases.Extras.psd1'),
27+
(Join-Path $repoRoot 'git-aliases-extra.psm1'),
28+
(Join-Path $repoRoot 'git-aliases-extra.psd1'),
2929
(Join-Path $repoRoot 'tests'),
3030
(Join-Path $repoRoot 'tools')
3131
) | Where-Object { Test-Path -LiteralPath $_ }

0 commit comments

Comments
 (0)