Skip to content

Commit 80a4d9c

Browse files
Merge pull request #188 from StartAutomating/ugit-an-update
ugit 0.4.1
2 parents 525290d + d81f224 commit 80a4d9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+777
-389
lines changed

.github/workflows/SendPSA.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
name: ugit-psa
3+
on:
4+
workflow_dispatch:
5+
jobs:
6+
SendPSA:
7+
runs-on: ubuntu-latest
8+
if: ${{ success() }}
9+
steps:
10+
- name: Check out repository
11+
uses: actions/checkout@v2
12+
- name: PSA
13+
uses: StartAutomating/PSA@main
14+
id: PSA
15+
env:
16+
AT_PROTOCOL_HANDLE: mrpowershell.bsky.social
17+
AT_PROTOCOL_APP_PASSWORD: ${{ secrets.AT_PROTOCOL_APP_PASSWORD }}

.github/workflows/TestAndPublish.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,4 +591,9 @@ jobs:
591591
- name: Run HelpOut
592592
uses: StartAutomating/HelpOut@master
593593
id: HelpOut
594-
594+
- name: PSA
595+
uses: StartAutomating/PSA@main
596+
id: PSA
597+
env:
598+
AT_PROTOCOL_HANDLE: mrpowershell.bsky.social
599+
AT_PROTOCOL_APP_PASSWORD: ${{ secrets.AT_PROTOCOL_APP_PASSWORD }}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 0.4.1:
2+
3+
* New Git Command Support:
4+
* git submodule status (#183)
5+
* New Git ScriptMethods:
6+
* git.branch.diff (#187)
7+
* git.branch.rename (#86)
8+
* Easier Input:
9+
* git commit -CommitDate (#184)
10+
* git log -CurrentBranch (fixing forks, #179)
11+
* Announcing Releases with [PSA](https://github.com/StartAutomating/PSA)
12+
13+
---
14+
115
## 0.4:
216

317
* Adding Sponsorship! (#174)

Extensions/Git.Commit.Input.UGit.Extension.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ $Trailers,
3333

3434
# If set, will amend an existing commit.
3535
[switch]
36-
$Amend
36+
$Amend,
37+
38+
# The commit date.
39+
[Parameter(ValueFromPipelineByPropertyName)]
40+
[Alias('Date','Time','DateTime','Timestamp')]
41+
[datetime]
42+
$CommitDate
3743
)
3844

3945

@@ -63,4 +69,9 @@ if ($Trailers) {
6369

6470
if ($amend) {
6571
"--amend"
72+
}
73+
74+
if ($CommitDate) {
75+
"--date"
76+
$CommitDate.ToString("o")
6677
}

Extensions/Git.Log.Input.UGit.Extension.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ foreach ($dashToDoubleDash in 'after', 'before', 'author') {
8484
}
8585

8686
if ($CurrentBranch) {
87-
$headbranch = git remote | git remote show | Select-Object -ExpandProperty HeadBranch
87+
$headbranch = git remote | git remote show | Select-Object -ExpandProperty HeadBranch -First 1
8888
$currentBranchName = git branch | Where-Object IsCurrentBranch
8989
if ($currentBranchName -ne $headbranch) {
9090
"$headbranch..$currentBranchName"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<#
2+
.Synopsis
3+
Git Submodule Extension
4+
.Description
5+
Git Submodule as objects.
6+
.EXAMPLE
7+
git submodule
8+
#>
9+
[Management.Automation.Cmdlet("Out","Git")] # It's an extension for Out-Git
10+
[ValidatePattern("^(?:git)\s(?:submodule)\s(?:status)?$")] # that is run when git submodule is run (with no other options (except for status)).
11+
param()
12+
13+
begin {
14+
$submoduleLines = @()
15+
}
16+
17+
process {
18+
$submoduleLines += $gitOut
19+
}
20+
21+
end {
22+
if ($gitArgument -match '--(?>n|dry-run)') {
23+
return $submoduleLines
24+
}
25+
26+
foreach ($line in $submoduleLines) {
27+
if ($line -match '^\s{0,}[\+]?(?<CommitHash>[0-9a-f]{10,})\s(?<SubModule>\S+)\s\((?<Reference>[^\)]+)\)') {
28+
$Matches.Remove(0)
29+
$toObject = [Ordered]@{
30+
PSTypeName = 'git.submodule.status'
31+
GitOutputLines = $submoduleLines
32+
GitRoot = $gitRoot
33+
} + $Matches
34+
[PSCustomObject]$toObject
35+
}
36+
}
37+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Write-FormatView -TypeName git.submodule.status -Property Submodule, Reference, CommitHash

Get-UGitExtension.ps1

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Piecemeal [ 0.3.10 ] : Easy Extensible Plugins for PowerShell
1+
#region Piecemeal [ 0.4.1 ] : Easy Extensible Plugins for PowerShell
22
# Install-Module Piecemeal -Scope CurrentUser
33
# Import-Module Piecemeal -Force
44
# Install-Piecemeal -ExtensionModule 'ugit' -ExtensionModuleAlias 'git' -ExtensionNoun 'UGitExtension' -ExtensionTypeName 'ugit.extension' -OutputPath '.\Get-UGitExtension.ps1'
@@ -614,6 +614,8 @@ function Get-UGitExtension
614614

615615
$ExtensionDynamicParameters = [Management.Automation.RuntimeDefinedParameterDictionary]::new()
616616
$Extension = $this
617+
$ExtensionMetadata = $Extension -as [Management.Automation.CommandMetaData]
618+
if (-not $ExtensionMetadata) { return $ExtensionDynamicParameters }
617619

618620
:nextDynamicParameter foreach ($in in @(($Extension -as [Management.Automation.CommandMetaData]).Parameters.Keys)) {
619621
$attrList = [Collections.Generic.List[Attribute]]::new()
@@ -1042,12 +1044,16 @@ function Get-UGitExtension
10421044

10431045
if ($Force) {
10441046
$script:UGitExtensions = $null
1047+
$script:UGitExtensionsByName = $null
10451048
$script:AllCommands = @()
10461049
}
10471050
if (-not $script:UGitExtensions)
10481051
{
1049-
$script:UGitExtensionsFromFiles = [Ordered]@{}
1050-
$script:UGitExtensionsFileTimes = [Ordered]@{}
1052+
$script:UGitExtensionsFromFiles = [Ordered]@{}
1053+
$script:UGitExtensionsFileTimes = [Ordered]@{}
1054+
$script:UGitExtensionsByName = [Ordered]@{}
1055+
$script:UGitExtensionsByDisplayName = [Ordered]@{}
1056+
$script:UGitExtensionsByPattern = [Ordered]@{}
10511057
$script:UGitExtensions =
10521058
@(@(
10531059
#region Find UGitExtension in Loaded Modules
@@ -1093,14 +1099,54 @@ function Get-UGitExtension
10931099
$ExecutionContext.SessionState.InvokeCommand.GetCommands('*', 'Function,Alias',$true) -match $extensionFullRegex
10941100
#endregion Find UGitExtension in Loaded Commands
10951101
) | Select-Object -Unique | Sort-Object Rank, Name)
1102+
1103+
foreach ($extCmd in $script:UGitExtensions) {
1104+
if (-not $script:UGitExtensionsByName[$extCmd.Name]) {
1105+
$script:UGitExtensionsByName[$extCmd.Name] = $extCmd
1106+
}
1107+
else {
1108+
$script:UGitExtensionsByName[$extCmd.Name] = @($script:UGitExtensionsByName[$extCmd.Name]) + $extCmd
1109+
}
1110+
if ($extCmd.DisplayName) {
1111+
if (-not $script:UGitExtensionsByDisplayName[$extCmd.DisplayName]) {
1112+
$script:UGitExtensionsByDisplayName[$extCmd.DisplayName] = $extCmd
1113+
}
1114+
else {
1115+
$script:UGitExtensionsByDisplayName[$extCmd.DisplayName] = @($script:UGitExtensionsByDisplayName[$extCmd.DisplayName]) + $extCmd
1116+
}
1117+
}
1118+
$ExtensionCommandAliases = @($extCmd.Attributes.AliasNames)
1119+
$ExtensionCommandAliasRegexes = @($ExtensionCommandAliases -match '^/' -match '/$')
1120+
$ExtensionCommandNormalAliases = @($ExtensionCommandAliases -notmatch '^/')
1121+
if ($ExtensionCommandAliasRegexes) {
1122+
foreach ($extensionAliasRegex in $ExtensionCommandAliasRegexes) {
1123+
$regex = [Regex]::New($extensionAliasRegex -replace '^/' -replace '/$', 'IgnoreCase,IgnorePatternWhitespace')
1124+
if (-not $script:UGitExtensionsByPattern[$regex]) {
1125+
$script:UGitExtensionsByPattern[$regex] = $extCmd
1126+
} else {
1127+
$script:UGitExtensionsByPattern[$regex] = @($script:UGitExtensionsByPattern[$regex]) + $extCmd
1128+
}
1129+
}
1130+
}
1131+
if ($ExtensionCommandNormalAliases) {
1132+
foreach ($extensionAlias in $ExtensionCommandNormalAliases) {
1133+
if (-not $script:UGitExtensionsByName[$extensionAlias]) {
1134+
$script:UGitExtensionsByName[$extensionAlias] = $extCmd
1135+
} else {
1136+
$script:UGitExtensionsByName[$extensionAlias] = @($script:UGitExtensionsByName[$extensionAlias]) + $extCmd
1137+
}
1138+
}
1139+
}
1140+
1141+
}
10961142
}
10971143
#endregion Find Extensions
10981144
}
10991145

11001146
process {
11011147

11021148
if ($UGitExtensionPath) {
1103-
@(foreach ($_ in Get-ChildItem -Recurse -Path $UGitExtensionPath -File) {
1149+
@(foreach ($_ in Get-ChildItem -Recurse:$($UGitExtensionPath -notmatch '^\.[\\/]') -Path $UGitExtensionPath -File) {
11041150
if ($_.Name -notmatch $extensionFullRegex) { continue }
11051151
if ($CommandName -or $UGitExtensionName) {
11061152
ConvertToExtension $_ |
@@ -1118,14 +1164,34 @@ function Get-UGitExtension
11181164
# This section can be updated by using Install-Piecemeal -ForeachObject
11191165
#endregion Install-Piecemeal -ForeachObject
11201166
} elseif ($CommandName -or $UGitExtensionName) {
1121-
$script:UGitExtensions |
1122-
. WhereExtends $CommandName |
1123-
OutputExtension
1167+
if (-not $CommandName -and -not $like -and -not $Match) {
1168+
foreach ($exn in $UGitExtensionName) {
1169+
if ($script:UGitExtensionsByName[$exn]) {
1170+
$script:UGitExtensionsByName[$exn] | OutputExtension
1171+
}
1172+
if ($script:UGitExtensionsByDisplayName[$exn]) {
1173+
$script:UGitExtensionsByDisplayName[$exn] | OutputExtension
1174+
}
1175+
if ($script:UGitExtensionsByPattern.Count) {
1176+
foreach ($patternAndValue in $script:UGitExtensionsByPattern.GetEnumerator()) {
1177+
if ($patternAndValue.Key.IsMatch($exn)) {
1178+
$patternAndValue.Value | OutputExtension
1179+
}
1180+
}
1181+
$script:UGitExtensionsByDisplayName[$exn]
1182+
}
1183+
}
1184+
} else {
1185+
$script:UGitExtensions |
1186+
. WhereExtends $CommandName |
1187+
OutputExtension
1188+
}
1189+
11241190
} else {
11251191
$script:UGitExtensions |
11261192
OutputExtension
11271193
}
11281194
}
11291195
}
1130-
#endregion Piecemeal [ 0.3.10 ] : Easy Extensible Plugins for PowerShell
1196+
#endregion Piecemeal [ 0.4.1 ] : Easy Extensible Plugins for PowerShell
11311197

GitHub/Jobs/SendPSA.psd1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@{
2+
"runs-on" = "ubuntu-latest"
3+
if = '${{ success() }}'
4+
steps = @(
5+
@{
6+
name = 'Check out repository'
7+
uses = 'actions/checkout@v2'
8+
},
9+
@{
10+
name = 'PSA'
11+
uses = 'StartAutomating/PSA@main'
12+
id = 'PSA'
13+
}
14+
)
15+
}

GitHub/Jobs/buildugit.psd1

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@
66
name = 'Check out repository'
77
uses = 'actions/checkout@v2'
88
},
9+
@{
10+
name = 'GitLogger'
11+
uses = 'GitLogging/GitLoggerAction@main'
12+
id = 'GitLogger'
13+
},
914
@{
1015
name = 'Use PSSVG Action'
1116
uses = 'StartAutomating/PSSVG@main'
1217
id = 'PSSVG'
1318
},
1419
'RunPipeScript',
1520
'RunPiecemeal',
16-
'RunEZOut',
17-
'RunHelpOut'
21+
'RunEZOut',
22+
@{
23+
name = 'Run HelpOut'
24+
uses = 'StartAutomating/HelpOut@master'
25+
id = 'HelpOut'
26+
},
27+
@{
28+
name = 'PSA'
29+
uses = 'StartAutomating/PSA@main'
30+
id = 'PSA'
31+
}
1832
)
1933
}

0 commit comments

Comments
 (0)