diff --git a/CHANGELOG.md b/CHANGELOG.md index b6b7d3a8..d5e5dae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## 0.3.8: + +* Use-Git can now be extended (#140, #97), letting you add PowerShell parameters to any git command +* Initial input extensions + * git.clone.input (#141) (--progress is inferred so Write-Progress happens automagically) + * git.log.input (#142) (Added -Before/-After/-Author/-CurrentBranch) + * git.commit.input (#144) (Added -Message/-Body/-Title/-Trailer) +* Other Improvements: + * git log will not process --pretty/--format (Fixes #143) + * git log now supports .Trailers (Fixes #112) + * git remote formatting improved (Fixes #145) + * git remote now works for multiple remotes (Fixes #136) + * Updated logo (#139) + +--- + ## 0.3.7: * git remote diff --git a/Extensions/Git.Clone.Input.UGit.Extension.ps1 b/Extensions/Git.Clone.Input.UGit.Extension.ps1 new file mode 100644 index 00000000..5f9c247f --- /dev/null +++ b/Extensions/Git.Clone.Input.UGit.Extension.ps1 @@ -0,0 +1,19 @@ +<# +.SYNOPSIS + Git Clone extended input +.DESCRIPTION + Extends the input for git clone. + + By default, if --progress is not found, it will be added to any git clone. +.EXAMPLE + git clone https://github.com/MDN/content.git # This is a big repo. Progress bars will be very welcome. +#> +[ValidatePattern('^git clone')] +[Management.Automation.Cmdlet("Use","Git")] +[CmdletBinding(PositionalBinding=$false)] +param( +) + +if ($gitArgument -notcontains '--progress') { + '--progress' +} \ No newline at end of file diff --git a/Extensions/Git.Commit.Input.UGit.Extension.ps1 b/Extensions/Git.Commit.Input.UGit.Extension.ps1 new file mode 100644 index 00000000..252dcc74 --- /dev/null +++ b/Extensions/Git.Commit.Input.UGit.Extension.ps1 @@ -0,0 +1,66 @@ +<# +.SYNOPSIS + Git Commit Input +.DESCRIPTION + Makes Git Commit easier to use from PowerShell by providing parameters for the -Message, -Title, -Body, and -Trailers +.EXAMPLE + git commit -Title "Fixing Something" +.EXAMPLE + git commit -Title "Changing Stuff" -Trailers @{"Co-Authored-By"="SOMEONE ELSE "} +#> +[ValidatePattern('^git commit')] +[Management.Automation.Cmdlet('Use','Git')] +[CmdletBinding(PositionalBinding=$false)] +param( +# The message used for the commit +[string] +$Message, + +# The title of the commit. If -Message is also provided, this will become part of the -Body +[string] +$Title, + +# The body of the commit. +[string] +$Body, + +# Any git trailers to add to the commit. +# git trailers are key-value pairs you can use to associate metadata with a commit. +# As this uses --trailer, this requires git version 2.33 or greater. +[Alias('Trailer','CommitMetadata','GitMetadata')] +[Collections.IDictionary] +$Trailers, + +# If set, will amend an existing commit. +[switch] +$Amend +) + + + +if ($Message) { + "-m" + $message +} + +if ($Title) { + "-m" + $title +} + +if ($Body) { + "-m" + $body +} + +if ($Trailers) { + foreach ($kv in $Trailers.GetEnumerator()) { + foreach ($val in $kv.Value) { + "--trailer=$($kv.Key -replace ':','_colon_' -replace '\s', '-')=$val" + } + } +} + +if ($amend) { + "--amend" +} \ No newline at end of file diff --git a/Extensions/Git.Log.Input.UGit.Extension.ps1 b/Extensions/Git.Log.Input.UGit.Extension.ps1 new file mode 100644 index 00000000..8cf746a9 --- /dev/null +++ b/Extensions/Git.Log.Input.UGit.Extension.ps1 @@ -0,0 +1,77 @@ +<# +.SYNOPSIS + git log input +.DESCRIPTION + Extends the parameters for git log, making it easier to use from PowerShell. + + Allows timeframe parameters to be tab-completed: + * After/Since become --after + * Before/Until become --before + * Author/Committer become --author + + Adds -CurrentBranch, which gives the changes between the upstream branch and the current branch. + + Also adds -IssueNumber, which searchers for commits that reference particular issues. +.EXAMPLE + git log -CurrentBranch +#> +[ValidatePattern('^git log')] +[Management.Automation.Cmdlet("Use","Git")] +[CmdletBinding(PositionalBinding=$false)] +param( +# Gets logs after a given date +[DateTime] +[Alias('Since')] +$After, + +# Gets before a given date +[DateTime] +[Alias('Until')] +$Before, + +# Gets lof from a given author or committer +[Alias('Committer')] +[string] +$Author, + +# If set, will get all changes between the upstream branch and the current branch. +[Alias('UpstreamDelta','ThisBranch')] +[switch] +$CurrentBranch, + +# One or more issue numbers. Providing an issue number of 0 will find all log entries that reference an issue. +[Parameter(ValueFromPipelineByPropertyName)] +[Alias('ReferenceNumbers','ReferenceNumber','IssueNumbers','WorkItemID','WorkItemIDs')] +[int[]] +$IssueNumber +) + +foreach ($dashToDoubleDash in 'after', 'before', 'author') { + if ($PSBoundParameters[$dashToDoubleDash]) { + "--$dashToDoubleDash" + "$($PSBoundParameters[$dashToDoubleDash])" + } +} + +if ($CurrentBranch) { + $headbranch = git remote | git remote show | Select-Object -ExpandProperty HeadBranch + $currentBranchName = git branch | Where-Object IsCurrentBranch + if ($currentBranchName -ne $headbranch) { + "$headbranch..$currentBranchName" + } else { + Write-Warning "On $headBranch" + } +} + +if ($IssueNumber) { + "--perl-regexp" + foreach ($IssueNum in $IssueNumber) { + '--grep' + if ($IssueNum -eq 0) { + '\#\d+\D' + } else { + "\#$IssueNum\D" + } + } + +} \ No newline at end of file diff --git a/Extensions/Git.Log.UGit.Extension.ps1 b/Extensions/Git.Log.UGit.Extension.ps1 index b09cf6b9..c4264586 100644 --- a/Extensions/Git.Log.UGit.Extension.ps1 +++ b/Extensions/Git.Log.UGit.Extension.ps1 @@ -113,6 +113,21 @@ begin { } } + if ($gitLogOut.CommitMessage) { + $gitTrailers = [Ordered]@{} + foreach ($commitMessageLine in $gitLogOut.CommitMessage -split '(?>\r\n|\n)') { + if ($commitMessageLine -notmatch '\s{0,}(?\S+):\s(?[\s\S]+$)') { + continue + } + if (-not $gitTrailers[$matches.k]) { + $gitTrailers[$matches.k] = $matches.v + } else { + $gitTrailers[$matches.k] = @($gitTrailers[$matches.k]) + $v + } + } + $gitLogOut.Trailers = $gitTrailers + } + if ($GitArgument -contains '--shortstat' -or $GitArgument -contains '--stat') { foreach ($linePart in $OutputLines[-2] -split ',' -replace '[\s\w\(\)-[\d]]') { if ($linePart.Contains('+')) { @@ -167,6 +182,9 @@ begin { process { + if ($gitCommand -match '--(?>pretty|format)') { + continue + } if ("$gitOut" -like 'Commit*' -and $lines) { OutGitLog $lines diff --git a/Extensions/Git.Remote.UGit.Extension.ps1 b/Extensions/Git.Remote.UGit.Extension.ps1 index 63af1690..c664b793 100644 --- a/Extensions/Git.Remote.UGit.Extension.ps1 +++ b/Extensions/Git.Remote.UGit.Extension.ps1 @@ -35,21 +35,32 @@ end { switch -Regex ($gitCommand) { 'git remote\s{0,}$' { # With no other parameters, it returns the remote name. - return [PSCustomObject][Ordered]@{ - PSTypename = 'git.remote.name' - RemoteName = $remoteLines -join ' ' -replace '\s' - GitRoot = $gitRoot + foreach ($remoteLine in $remoteLines) { + if (-not $remoteLine.Trim()) { + continue + } + [PSCustomObject][Ordered]@{ + PSTypename = 'git.remote.name' + RemoteName = $remoteLine -join ' ' -replace '\s' + GitRoot = $gitRoot + } } } 'git remote get-url (?\S+)\s{0,}$' { - # With get-url, it returns the URL - return [PSCustomObject][Ordered]@{ - PSTypename = 'git.remote.url' - RemoteName = $matches.RemoteName - RemoteUrl = $remoteLines -join ' ' -replace '\s' - GitOutputLines = $remoteLines - GitRoot = $gitRoot - } + + foreach ($remoteline in $remoteLines) { + if (-not $remoteLine.Trim()) { + continue + } + # With get-url, it returns the URL + return [PSCustomObject][Ordered]@{ + PSTypename = 'git.remote.url' + RemoteName = $matches.RemoteName + RemoteUrl = $remoteLines -join ' ' -replace '\s' + GitOutputLines = $remoteLines + GitRoot = $gitRoot + } + } } 'git remote show (?\S+)\s{0,}$' { # With show, it returns _a lot_ of stuff. We want to track: diff --git a/Formatting/Git.Remote.format.ps1 b/Formatting/Git.Remote.format.ps1 index c67e3ef6..838a34f6 100644 --- a/Formatting/Git.Remote.format.ps1 +++ b/Formatting/Git.Remote.format.ps1 @@ -20,18 +20,24 @@ Write-FormatView -TypeName Git.Remote.Show -Action { [Environment]::NewLine + (' ' * 4) ) } - Write-FormatViewExpression -Newline - Write-FormatViewExpression -Text ' Remote Branches:' - Write-FormatViewExpression -Newline - Write-FormatViewExpression -ControlName GitRemoteBranchList -Property RemoteBranches - Write-FormatViewExpression -Newline - Write-FormatViewExpression -Text ' Local Branches:' - Write-FormatViewExpression -Newline - Write-FormatViewExpression -ControlName GitRemoteBranchList -Property LocalBranches - Write-FormatViewExpression -Text ' Tracked Upstreams:' - Write-FormatViewExpression -Newline - Write-FormatViewExpression -ControlName GitRemoteBranchList -Property TrackedUpstreams - Write-FormatViewExpression -Newline + Write-FormatViewExpression -If { $_.RemoteBranches } -ScriptBlock { + [Environment]::NewLine + ' Remote Branches:' + [Environment]::NewLine + } + + Write-FormatViewExpression -If { $_.RemoteBranches } -ControlName GitRemoteBranchList -Property RemoteBranches + + Write-FormatViewExpression -If { $_.LocalBranches } -ScriptBlock { + [Environment]::NewLine + ' Local Branches:' + [Environment]::NewLine + } + + Write-FormatViewExpression -If { $_.LocalBranches } -ControlName GitRemoteBranchList -Property LocalBranches + + + Write-FormatViewExpression -If { $_.TrackedUpstreams } -ScriptBlock { + [Environment]::NewLine + ' Tracked Upstreams:' + [Environment]::NewLine + } + + Write-FormatViewExpression -If { $_.TrackedUpstreams } -ControlName GitRemoteBranchList -Property TrackedUpstreams } Write-FormatView -TypeName n/a -Name GitRemoteBranchList -AsControl -Action { diff --git a/README.md b/README.md index b4423712..4b3232d6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@
- +ugit + + +
Updated Git: A powerful PowerShell wrapper for git that lets you extend git, automate multiple repos, and output git as objects. @@ -13,10 +16,12 @@ This enables _a lot_ of interesting scenarios, giving you and updated way to wor ## Getting started -### Installing ugit ~~~PowerShell +# Install ugit from the PowerShell Gallery Install-Module ugit -Scope CurrentUser +# Then import it. Import-Module ugit -Force -PassThru + # Once you've imported ugit, just run git commands normally. # If ugit has an extension for the command, it will output as an object. # These objects can be formatted by PowerShell @@ -27,7 +32,6 @@ git log -n 5 | Get-Member ~~~ - ## How ugit works: ugit only has a few commands: @@ -62,82 +66,11 @@ If this pattern matches the given git command, the extension will run. Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/Piecemeal) -## Git Commands Extended - - -* [Git Branch](docs/Git.Branch-Extension.md) - - -* [Git Checkout](docs/Git.Checkout-Extension.md) - - -* [Git Clone](docs/Git.Clone-Extension.md) - - -* [Git Commit](docs/Git.Commit-Extension.md) - - -* [Git Diff](docs/Git.Diff-Extension.md) - - -* [Git FileName](docs/Git.FileName-Extension.md) - - -* [Git Grep](docs/Git.Grep-Extension.md) - - -* [Git Help All](docs/Git.Help.All-Extension.md) - - -* [Git Init](docs/Git.Init-Extension.md) - - -* [Git Log](docs/Git.Log-Extension.md) - - -* [Git Mv](docs/Git.Mv-Extension.md) - - -* [Git Pull](docs/Git.Pull-Extension.md) - - -* [Git Push](docs/Git.Push-Extension.md) - - -* [Git RefLog](docs/Git.RefLog-Extension.md) - - -* [Git Remote](docs/Git.Remote-Extension.md) - - -* [Git Rm](docs/Git.Rm-Extension.md) - - -* [Git Shortlog](docs/Git.Shortlog-Extension.md) - - -* [Git Stash](docs/Git.Stash-Extension.md) - - -* [Git Status](docs/Git.Status-Extension.md) - - - -### Extensions that may apply to any git command: - -* Git.FileName - -This applies to any git command that uses --name-only. -It will attempt to return the name as a file, or as an object containing the name. - -* Git.FileOutput - -This applies to an git command that uses the -o flag. -It will attempt to locate any output specified by -o and return it as a file or directory. - - ## ugit examples +ugit comes packed with many examples. +You might want to try giving some of these a try. + ### Git.Branch Example 1 @@ -169,6 +102,13 @@ It will attempt to locate any output specified by -o and return it as a file or git checkout main ~~~ +### Git.Clone.Input Example 1 + + +~~~PowerShell + git clone https://github.com/MDN/content.git # This is a big repo. Progress bars will be very welcome. +~~~ + ### Git.Clone Example 1 @@ -185,6 +125,20 @@ It will attempt to locate any output specified by -o and return it as a file or git clone https://github.com/Azure/azure-quickstart-templates --progress ~~~ +### Git.Commit.Input Example 1 + + +~~~PowerShell + git commit -Title "Fixing Something" +~~~ + +### Git.Commit.Input Example 2 + + +~~~PowerShell + git commit -Title "Changing Stuff" -Trailers @{"Co-Authored-By"="SOMEONE ELSE "} +~~~ + ### Git.Commit Example 1 @@ -242,6 +196,13 @@ It will attempt to locate any output specified by -o and return it as a file or git init # Initialize the current directory as a repository ~~~ +### Git.Log.Input Example 1 + + +~~~PowerShell + git log -CurrentBranch +~~~ + ### Git.Log Example 1 @@ -415,4 +376,98 @@ It will attempt to locate any output specified by -o and return it as a file or git status | Select-Object -ExpandProperty Untracked ~~~ +## Out-Git Extensions + +### Git Commands + +Most extensions handle output from a single git command. + + +* [Git Branch](docs/Git.Branch-Extension.md) + + +* [Git Checkout](docs/Git.Checkout-Extension.md) + + +* [Git Clone](docs/Git.Clone-Extension.md) + + +* [Git Commit](docs/Git.Commit-Extension.md) + + +* [Git Diff](docs/Git.Diff-Extension.md) + + +* [Git FileName](docs/Git.FileName-Extension.md) + + +* [Git Grep](docs/Git.Grep-Extension.md) + + +* [Git Help All](docs/Git.Help.All-Extension.md) + + +* [Git Init](docs/Git.Init-Extension.md) + + +* [Git Log](docs/Git.Log-Extension.md) + + +* [Git Mv](docs/Git.Mv-Extension.md) + + +* [Git Pull](docs/Git.Pull-Extension.md) + + +* [Git Push](docs/Git.Push-Extension.md) + + +* [Git RefLog](docs/Git.RefLog-Extension.md) + + +* [Git Remote](docs/Git.Remote-Extension.md) + + +* [Git Rm](docs/Git.Rm-Extension.md) + + +* [Git Shortlog](docs/Git.Shortlog-Extension.md) + + +* [Git Stash](docs/Git.Stash-Extension.md) + + +* [Git Status](docs/Git.Status-Extension.md) + + + +### Additional Output Extensions + +A few extensions handle output from any number of git commands, depending on the arguments. + +* Git.FileName + +This applies to any git command that uses --name-only. +It will attempt to return the name as a file, or as an object containing the name. + +* Git.FileOutput + +This applies to an git command that uses the -o flag. +It will attempt to locate any output specified by -o and return it as a file or directory. + +## Use-Git Extensions + +ugit also allows you to extend the input for git. + + +* [Git Clone Input](docs/Git.Clone.Input-Extension.md) + + +* [Git Commit Input](docs/Git.Commit.Input-Extension.md) + + +* [Git Log Input](docs/Git.Log.Input-Extension.md) + + + diff --git a/README.ps1.md b/README.ps1.md index bc5b349e..1c192948 100644 --- a/README.ps1.md +++ b/README.ps1.md @@ -1,5 +1,8 @@
- +ugit + + +
Updated Git: A powerful PowerShell wrapper for git that lets you extend git, automate multiple repos, and output git as objects. @@ -13,10 +16,12 @@ This enables _a lot_ of interesting scenarios, giving you and updated way to wor ## Getting started -### Installing ugit ~~~PowerShell +# Install ugit from the PowerShell Gallery Install-Module ugit -Scope CurrentUser +# Then import it. Import-Module ugit -Force -PassThru + # Once you've imported ugit, just run git commands normally. # If ugit has an extension for the command, it will output as an object. # These objects can be formatted by PowerShell @@ -27,7 +32,6 @@ git log -n 5 | Get-Member ~~~ - ## How ugit works: ugit only has a few commands: @@ -62,11 +66,34 @@ If this pattern matches the given git command, the extension will run. Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/Piecemeal) -## Git Commands Extended +## ugit examples + +ugit comes packed with many examples. +You might want to try giving some of these a try. ~~~PipeScript { - $null = Import-Module .\ugit.psd1 -Global - Get-UGitExtension | + $null = Import-Module .\ugit.psd1 -Global + @(foreach ($ugitExt in Get-UGitExtension) { + $examples = @($ugitExt.Examples) + for ($exampleNumber = 1; $exampleNumber -le $examples.Length; $exampleNumber++) { + @("### $($ugitExt.DisplayName) Example $($exampleNumber)", + [Environment]::Newline, + "~~~PowerShell", + $examples[$exampleNumber - 1], + "~~~") -join [Environment]::Newline + } + }) -join ([Environment]::Newline * 2) +} +~~~ + +## Out-Git Extensions + +### Git Commands + +Most extensions handle output from a single git command. + +~~~PipeScript { + Get-UGitExtension -CommandName Out-Git | Where-Object DisplayName -notIn 'Git.FileOutput' | .InputObject { "[$($_.DisplayName -replace '\.', ' ')]($('docs/' + $_.DisplayName + '-Extension.md'))" @@ -74,7 +101,9 @@ Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/ } ~~~ -### Extensions that may apply to any git command: +### Additional Output Extensions + +A few extensions handle output from any number of git commands, depending on the arguments. * Git.FileName @@ -86,20 +115,15 @@ It will attempt to return the name as a file, or as an object containing the nam This applies to an git command that uses the -o flag. It will attempt to locate any output specified by -o and return it as a file or directory. +## Use-Git Extensions -## ugit examples +ugit also allows you to extend the input for git. -~~~PipeScript { - @(foreach ($ugitExt in Get-UGitExtension) { - $examples = @($ugitExt.Examples) - for ($exampleNumber = 1; $exampleNumber -le $examples.Length; $exampleNumber++) { - @("### $($ugitExt.DisplayName) Example $($exampleNumber)", - [Environment]::Newline, - "~~~PowerShell", - $examples[$exampleNumber - 1], - "~~~") -join [Environment]::Newline - } - }) -join ([Environment]::Newline * 2) +~~~PipeScript { + Get-UGitExtension -CommandName Use-Git | + .InputObject { + "[$($_.DisplayName -replace '\.', ' ')]($('docs/' + $_.DisplayName + '-Extension.md'))" + } .BulletPoint = { $true } } ~~~ diff --git a/Use-Git.ps1 b/Use-Git.ps1 index 15abda80..251d4d12 100644 --- a/Use-Git.ps1 +++ b/Use-Git.ps1 @@ -52,6 +52,40 @@ $InputObject ) + dynamicParam { + $myInv = $MyInvocation + + $callstackPeek = @(Get-PSCallStack)[1] + $callingContext = + if ($callstackPeek.InvocationInfo.MyCommand.ScriptBlock) { + @($callstackPeek.InvocationInfo.MyCommand.ScriptBlock.Ast.FindAll({ + param($ast) + $ast.Extent.StartLineNumber -eq $myInv.ScriptLineNumber -and + $ast.Extent.StartColumnNumber -eq $myInv.OffsetInLine -and + $ast -is [Management.Automation.Language.CommandAst] + },$true))[0] + } + + $ToValidate = + if (-not $callingContext -and + $callstackPeek.Command -like 'TabExpansion*' -and + $callstackPeek.InvocationInfo.BoundParameters.InputScript + ) { + $callstackPeek.InvocationInfo.BoundParameters.InputScript.ToString() + } else { + $callingContext.CommandElements -join ' ' + } + + $dynamicParameterSplat = [Ordered]@{ + CommandName='Use-Git' + ValidateInput=$ToValidate + DynamicParameter=$true + DynamicParameterSetName='__AllParameterSets' + NoMandatoryDynamicParameter=$true + } + Get-UGitExtension @dynamicParameterSplat + } + begin { if (-not $script:CachedGitCmd) { # If we haven't cahced the git command # go get it. @@ -212,33 +246,63 @@ $InputDirectories[$dir] = @($null) # go over an empty collection } - foreach ($inObject in $InputDirectories[$dir]) { - if (-not $inObject -and $myInv.PipelinePosition -gt 1) { continue } - $AllGitArgs = @(@($GitArgument) + $inObject) # Then we collect the combined arguments - $AllGitArgs = @($AllGitArgs -ne '') # (skipping any empty arguments) - $OutGitParams = @{GitArgument=$AllGitArgs} # and prepare a splat (to save precious space when reporting errors). - $dirCount++ + $dirCount++ - if ($WhatIfPreference) { - [ScriptBlock]::Create("git $($allGitArgs -join ' ')") | - Add-Member NoteProperty GitRoot $dir -Force -PassThru - Pop-Location - continue + if (-not $script:RepoRoots[$dir]) { # and see if we have a repo root + $script:RepoRoots[$dir] = + @("$(& $script:CachedGitCmd rev-parse --show-toplevel *>&1)") -like "*/*" -replace '/', [io.path]::DirectorySeparatorChar + if (-not $script:RepoRoots[$dir] -and # If we did not have a repo root + -not ($gitArgument -match "(?>$($RepoNotRequired -join '|'))") # and we are not doing an operation that does not require one + ) { + Write-Warning "'$($dir)' is not a git repository" # warn that there is no repo (#21) + Pop-Location # pop back out of the directory + continue nextDirectory # and continue to the next directory. } + } + + # Walk over each input for each directory + :nextInput foreach ($inObject in $InputDirectories[$dir]) { + # Continue if there was no input and we were not the first step of the pipeline. + if (-not $inObject -and $myInv.PipelinePosition -gt 1) { continue } + + $AllGitArgs = @(@($GitArgument) + $inObject) # Then we collect the combined arguments + $GitCommand = "git $AllGitArgs" - if (-not $script:RepoRoots[$dir]) { # and see if we have a repo root - $script:RepoRoots[$dir] = - @("$(& $script:CachedGitCmd rev-parse --show-toplevel *>&1)") -like "*/*" -replace '/', [io.path]::DirectorySeparatorChar - if (-not $script:RepoRoots[$dir] -and # If we did not have a repo root - -not ($gitArgument -match "(?>$($RepoNotRequired -join '|'))") # and we are not doing an operation that does not require one - ) { - Write-Warning "'$($dir)' is not a git repository" # warn that there is no repo (#21) - Pop-Location # pop back out of the directory - continue nextDirectory # and continue to the next directory. + # Get any arguments from extensions + $extensionOutputs = @( + Get-UGitExtension -CommandName Use-Git -Run -Parameter $paramCopy -Stream -ValidateInput $GitCommand + ) + + # By default, we want to run git + $RunGit = $true + # with whatever strings came back from extensions as additional arguments. + $extensionArgs = @() + + # So we walk over each output from the extensions + foreach ($extensionOutput in $extensionOutputs) { + if ($extensionOutput -is [string]) { + # and accumulate string arguments. + $extensionArgs += $extensionOutput + } else { + # However, if we have non-string arguments + $extensionOutput + $RunGit = $false } } + if (-not $RunGit) { continue } + + if ($inObject -isnot [string] -and + $inObject.ToString -isnot [Management.Automation.PSScriptMethod]) { + Write-Verbose "Input was not a string or ugit object" + $inObject = $null + } + + $AllGitArgs = @(@($GitArgument) + $extensionArgs + $inObject) # Then we collect the combined arguments + $AllGitArgs = @($AllGitArgs -ne '') # (skipping any empty arguments) + $OutGitParams = @{GitArgument=$AllGitArgs} # and prepare a splat (to save precious space when reporting errors). + $OutGitParams.GitRoot = "$($script:RepoRoots[$dir])" Write-Verbose "Calling git with $AllGitArgs" diff --git a/assets/ugit.svg b/assets/ugit.svg index 4f67e585..4a8fdd5d 100644 --- a/assets/ugit.svg +++ b/assets/ugit.svg @@ -3,6 +3,9 @@ - - ugit + + + u + git + diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 25330ec9..1750d556 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,19 @@ +## 0.3.8: + +* Use-Git can now be extended (#140, #97), letting you add PowerShell parameters to any git command +* Initial input extensions + * git.clone.input (#141) (--progress is inferred so Write-Progress happens automagically) + * git.log.input (#142) (Added -Before/-After/-Author/-CurrentBranch) + * git.commit.input (#144) (Added -Message/-Body/-Title/-Trailer) +* Other Improvements: + * git log will not process --pretty/--format (Fixes #143) + * git log now supports .Trailers (Fixes #112) + * git remote formatting improved (Fixes #145) + * git remote now works for multiple remotes (Fixes #136) + * Updated logo (#139) + +--- + ## 0.3.7: * git remote diff --git a/docs/Git.Branch-Extension.md b/docs/Git.Branch-Extension.md index 666c3821..36c13a85 100644 --- a/docs/Git.Branch-Extension.md +++ b/docs/Git.Branch-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Branch.UGit.Extension.ps1 ---------------------------------------- @@ -62,7 +61,3 @@ git branch | # Get all branches ```PowerShell Extensions/Git.Branch.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Checkout-Extension.md b/docs/Git.Checkout-Extension.md index e7aa98f0..3011c8eb 100644 --- a/docs/Git.Checkout-Extension.md +++ b/docs/Git.Checkout-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Checkout.UGit.Extension.ps1 ------------------------------------------ @@ -42,7 +41,3 @@ git checkout main ```PowerShell Extensions/Git.Checkout.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Clone-Extension.md b/docs/Git.Clone-Extension.md index 0e788f80..dfd5106c 100644 --- a/docs/Git.Clone-Extension.md +++ b/docs/Git.Clone-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Clone.UGit.Extension.ps1 --------------------------------------- @@ -55,7 +54,3 @@ git clone https://github.com/Azure/azure-quickstart-templates --progress ```PowerShell Extensions/Git.Clone.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Clone.Input-Extension.md b/docs/Git.Clone.Input-Extension.md new file mode 100644 index 00000000..5882a77e --- /dev/null +++ b/docs/Git.Clone.Input-Extension.md @@ -0,0 +1,40 @@ +Extensions/Git.Clone.Input.UGit.Extension.ps1 +--------------------------------------------- + + + + +### Synopsis +Git Clone extended input + + + +--- + + +### Description + +Extends the input for git clone. + +By default, if --progress is not found, it will be added to any git clone. + + + +--- + + +### Examples +#### EXAMPLE 1 +```PowerShell +git clone https://github.com/MDN/content.git # This is a big repo. Progress bars will be very welcome. +``` + + + +--- + + +### Syntax +```PowerShell +Extensions/Git.Clone.Input.UGit.Extension.ps1 [] +``` diff --git a/docs/Git.Commit-Extension.md b/docs/Git.Commit-Extension.md index 9d97a523..572395ee 100644 --- a/docs/Git.Commit-Extension.md +++ b/docs/Git.Commit-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Commit.UGit.Extension.ps1 ---------------------------------------- @@ -54,7 +53,3 @@ $commitMessage.Amend("Committing stuff") # that's better ```PowerShell Extensions/Git.Commit.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Commit.Input-Extension.md b/docs/Git.Commit.Input-Extension.md new file mode 100644 index 00000000..89728882 --- /dev/null +++ b/docs/Git.Commit.Input-Extension.md @@ -0,0 +1,126 @@ +Extensions/Git.Commit.Input.UGit.Extension.ps1 +---------------------------------------------- + + + + +### Synopsis +Git Commit Input + + + +--- + + +### Description + +Makes Git Commit easier to use from PowerShell by providing parameters for the -Message, -Title, -Body, and -Trailers + + + +--- + + +### Examples +#### EXAMPLE 1 +```PowerShell +git commit -Title "Fixing Something" +``` + +#### EXAMPLE 2 +```PowerShell +"} +``` + + + +--- + + +### Parameters +#### **Message** + +The message used for the commit + + + + + + +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[String]`|false |named |false | + + + +#### **Title** + +The title of the commit. If -Message is also provided, this will become part of the -Body + + + + + + +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[String]`|false |named |false | + + + +#### **Body** + +The body of the commit. + + + + + + +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[String]`|false |named |false | + + + +#### **Trailers** + +Any git trailers to add to the commit. +git trailers are key-value pairs you can use to associate metadata with a commit. +As this uses --trailer, this requires git version 2.33 or greater. + + + + + + +|Type |Required|Position|PipelineInput|Aliases | +|---------------|--------|--------|-------------|------------------------------------------| +|`[IDictionary]`|false |named |false |Trailer
CommitMetadata
GitMetadata| + + + +#### **Amend** + +If set, will amend an existing commit. + + + + + + +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[Switch]`|false |named |false | + + + + + +--- + + +### Syntax +```PowerShell +Extensions/Git.Commit.Input.UGit.Extension.ps1 [-Message ] [-Title ] [-Body ] [-Trailers ] [-Amend] [] +``` diff --git a/docs/Git.Diff-Extension.md b/docs/Git.Diff-Extension.md index fea48009..6eff1042 100644 --- a/docs/Git.Diff-Extension.md +++ b/docs/Git.Diff-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Diff.UGit.Extension.ps1 -------------------------------------- @@ -40,7 +39,3 @@ Outputs git diff entries as objects ```PowerShell Extensions/Git.Diff.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.FileName-Extension.md b/docs/Git.FileName-Extension.md index e5e55106..800280a9 100644 --- a/docs/Git.FileName-Extension.md +++ b/docs/Git.FileName-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.FileName.UGit.Extension.ps1 ------------------------------------------ @@ -58,7 +57,3 @@ git diff --name-only ```PowerShell Extensions/Git.FileName.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.FileOutput-Extension.md b/docs/Git.FileOutput-Extension.md index 7813198d..62f13224 100644 --- a/docs/Git.FileOutput-Extension.md +++ b/docs/Git.FileOutput-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.FileOutput.UGit.Extension.ps1 -------------------------------------------- @@ -39,7 +38,3 @@ git archive -o My.zip ```PowerShell Extensions/Git.FileOutput.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Grep-Extension.md b/docs/Git.Grep-Extension.md index 36df3b78..4c657919 100644 --- a/docs/Git.Grep-Extension.md +++ b/docs/Git.Grep-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Grep.UGit.Extension.ps1 -------------------------------------- @@ -60,7 +59,3 @@ git grep '-i' example # look for all examples in the repository ```PowerShell Extensions/Git.Grep.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Help.All-Extension.md b/docs/Git.Help.All-Extension.md index e4211e2c..395c8678 100644 --- a/docs/Git.Help.All-Extension.md +++ b/docs/Git.Help.All-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Help.All.UGit.Extension.ps1 ------------------------------------------ @@ -53,7 +52,3 @@ git help --all ```PowerShell Extensions/Git.Help.All.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Init-Extension.md b/docs/Git.Init-Extension.md index 45afc9e7..78053d2e 100644 --- a/docs/Git.Init-Extension.md +++ b/docs/Git.Init-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Init.UGit.Extension.ps1 -------------------------------------- @@ -48,7 +47,3 @@ git init # Initialize the current directory as a repository ```PowerShell Extensions/Git.Init.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Log-Extension.md b/docs/Git.Log-Extension.md index 31c2b440..40f0e053 100644 --- a/docs/Git.Log-Extension.md +++ b/docs/Git.Log-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Log.UGit.Extension.ps1 ------------------------------------- @@ -81,7 +80,3 @@ git log --merges ```PowerShell Extensions/Git.Log.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Log.Input-Extension.md b/docs/Git.Log.Input-Extension.md new file mode 100644 index 00000000..6ddb8289 --- /dev/null +++ b/docs/Git.Log.Input-Extension.md @@ -0,0 +1,128 @@ +Extensions/Git.Log.Input.UGit.Extension.ps1 +------------------------------------------- + + + + +### Synopsis +git log input + + + +--- + + +### Description + +Extends the parameters for git log, making it easier to use from PowerShell. + +Allows timeframe parameters to be tab-completed: +* After/Since become --after +* Before/Until become --before +* Author/Committer become --author + +Adds -CurrentBranch, which gives the changes between the upstream branch and the current branch. + +Also adds -IssueNumber, which searchers for commits that reference particular issues. + + + +--- + + +### Examples +#### EXAMPLE 1 +```PowerShell +git log -CurrentBranch +``` + + + +--- + + +### Parameters +#### **After** + +Gets logs after a given date + + + + + + +|Type |Required|Position|PipelineInput|Aliases| +|------------|--------|--------|-------------|-------| +|`[DateTime]`|false |named |false |Since | + + + +#### **Before** + +Gets before a given date + + + + + + +|Type |Required|Position|PipelineInput|Aliases| +|------------|--------|--------|-------------|-------| +|`[DateTime]`|false |named |false |Until | + + + +#### **Author** + +Gets lof from a given author or committer + + + + + + +|Type |Required|Position|PipelineInput|Aliases | +|----------|--------|--------|-------------|---------| +|`[String]`|false |named |false |Committer| + + + +#### **CurrentBranch** + +If set, will get all changes between the upstream branch and the current branch. + + + + + + +|Type |Required|Position|PipelineInput|Aliases | +|----------|--------|--------|-------------|----------------------------| +|`[Switch]`|false |named |false |UpstreamDelta
ThisBranch| + + + +#### **IssueNumber** + +One or more issue numbers. Providing an issue number of 0 will find all log entries that reference an issue. + + + + + + +|Type |Required|Position|PipelineInput |Aliases | +|-----------|--------|--------|---------------------|------------------------------------------------------------------------------------| +|`[Int32[]]`|false |named |true (ByPropertyName)|ReferenceNumbers
ReferenceNumber
IssueNumbers
WorkItemID
WorkItemIDs| + + + + + +--- + + +### Syntax +```PowerShell +Extensions/Git.Log.Input.UGit.Extension.ps1 [-After ] [-Before ] [-Author ] [-CurrentBranch] [-IssueNumber ] [] +``` diff --git a/docs/Git.Mv-Extension.md b/docs/Git.Mv-Extension.md index 90bc8bb6..cf54fa05 100644 --- a/docs/Git.Mv-Extension.md +++ b/docs/Git.Mv-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Mv.UGit.Extension.ps1 ------------------------------------ @@ -53,7 +52,3 @@ git mv .\OldName.txt .\NewName.txt --verbose ```PowerShell Extensions/Git.Mv.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Pull-Extension.md b/docs/Git.Pull-Extension.md index 72cde24a..76494216 100644 --- a/docs/Git.Pull-Extension.md +++ b/docs/Git.Pull-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Pull.UGit.Extension.ps1 -------------------------------------- @@ -68,7 +67,3 @@ git pull ```PowerShell Extensions/Git.Pull.UGit.Extension.ps1 [[-GitOut] ] [] ``` - - - - diff --git a/docs/Git.Push-Extension.md b/docs/Git.Push-Extension.md index 46c6482b..54da95e0 100644 --- a/docs/Git.Push-Extension.md +++ b/docs/Git.Push-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Push.UGit.Extension.ps1 -------------------------------------- @@ -48,7 +47,3 @@ git push ```PowerShell Extensions/Git.Push.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.RefLog-Extension.md b/docs/Git.RefLog-Extension.md index b2d5ea42..abbfa2db 100644 --- a/docs/Git.RefLog-Extension.md +++ b/docs/Git.RefLog-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.RefLog.UGit.Extension.ps1 ---------------------------------------- @@ -48,7 +47,3 @@ git reflog ```PowerShell Extensions/Git.RefLog.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Remote-Extension.md b/docs/Git.Remote-Extension.md index 14db4090..98319fdd 100644 --- a/docs/Git.Remote-Extension.md +++ b/docs/Git.Remote-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Remote.UGit.Extension.ps1 ---------------------------------------- @@ -64,7 +63,3 @@ git remote | git remote show ```PowerShell Extensions/Git.Remote.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Rm-Extension.md b/docs/Git.Rm-Extension.md index 967f5737..7340dff6 100644 --- a/docs/Git.Rm-Extension.md +++ b/docs/Git.Rm-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Rm.UGit.Extension.ps1 ------------------------------------ @@ -48,7 +47,3 @@ git rm .\FileIDontCareAbout.txt ```PowerShell Extensions/Git.Rm.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Shortlog-Extension.md b/docs/Git.Shortlog-Extension.md index affe71b5..4278dac3 100644 --- a/docs/Git.Shortlog-Extension.md +++ b/docs/Git.Shortlog-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Shortlog.UGit.Extension.ps1 ------------------------------------------ @@ -52,7 +51,3 @@ git shortlog --sumary --email # Get a shortlog summary, with email. ```PowerShell Extensions/Git.Shortlog.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Stash-Extension.md b/docs/Git.Stash-Extension.md index 9035b2f4..55113c9c 100644 --- a/docs/Git.Stash-Extension.md +++ b/docs/Git.Stash-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Stash.UGit.Extension.ps1 --------------------------------------- @@ -37,7 +36,3 @@ git stash list ```PowerShell Extensions/Git.Stash.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/Git.Status-Extension.md b/docs/Git.Status-Extension.md index 29b1c1cd..7c95e556 100644 --- a/docs/Git.Status-Extension.md +++ b/docs/Git.Status-Extension.md @@ -1,4 +1,3 @@ - Extensions/Git.Status.UGit.Extension.ps1 ---------------------------------------- @@ -42,7 +41,3 @@ git status | Select-Object -ExpandProperty Untracked ```PowerShell Extensions/Git.Status.UGit.Extension.ps1 [] ``` - - - - diff --git a/docs/README.md b/docs/README.md index 80768a9e..8d2cdd6d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,8 @@
- +ugit + + +
Updated Git: A powerful PowerShell wrapper for git that lets you extend git, automate multiple repos, and output git as objects. @@ -13,10 +16,12 @@ This enables _a lot_ of interesting scenarios, giving you and updated way to wor ## Getting started -### Installing ugit ~~~PowerShell +# Install ugit from the PowerShell Gallery Install-Module ugit -Scope CurrentUser +# Then import it. Import-Module ugit -Force -PassThru + # Once you've imported ugit, just run git commands normally. # If ugit has an extension for the command, it will output as an object. # These objects can be formatted by PowerShell @@ -27,7 +32,6 @@ git log -n 5 | Get-Member ~~~ - ## How ugit works: ugit only has a few commands: @@ -62,82 +66,11 @@ If this pattern matches the given git command, the extension will run. Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/Piecemeal) -## Git Commands Extended - - -* [Git Branch](Git.Branch-Extension.md) - - -* [Git Checkout](Git.Checkout-Extension.md) - - -* [Git Clone](Git.Clone-Extension.md) - - -* [Git Commit](Git.Commit-Extension.md) - - -* [Git Diff](Git.Diff-Extension.md) - - -* [Git FileName](Git.FileName-Extension.md) - - -* [Git Grep](Git.Grep-Extension.md) - - -* [Git Help All](Git.Help.All-Extension.md) - - -* [Git Init](Git.Init-Extension.md) - - -* [Git Log](Git.Log-Extension.md) - - -* [Git Mv](Git.Mv-Extension.md) - - -* [Git Pull](Git.Pull-Extension.md) - - -* [Git Push](Git.Push-Extension.md) - - -* [Git RefLog](Git.RefLog-Extension.md) - - -* [Git Remote](Git.Remote-Extension.md) - - -* [Git Rm](Git.Rm-Extension.md) - - -* [Git Shortlog](Git.Shortlog-Extension.md) - - -* [Git Stash](Git.Stash-Extension.md) - - -* [Git Status](Git.Status-Extension.md) - - - -### Extensions that may apply to any git command: - -* Git.FileName - -This applies to any git command that uses --name-only. -It will attempt to return the name as a file, or as an object containing the name. - -* Git.FileOutput - -This applies to an git command that uses the -o flag. -It will attempt to locate any output specified by -o and return it as a file or directory. - - ## ugit examples +ugit comes packed with many examples. +You might want to try giving some of these a try. + ### Git.Branch Example 1 @@ -169,6 +102,13 @@ It will attempt to locate any output specified by -o and return it as a file or git checkout main ~~~ +### Git.Clone.Input Example 1 + + +~~~PowerShell + git clone https://github.com/MDN/content.git # This is a big repo. Progress bars will be very welcome. +~~~ + ### Git.Clone Example 1 @@ -185,6 +125,20 @@ It will attempt to locate any output specified by -o and return it as a file or git clone https://github.com/Azure/azure-quickstart-templates --progress ~~~ +### Git.Commit.Input Example 1 + + +~~~PowerShell + git commit -Title "Fixing Something" +~~~ + +### Git.Commit.Input Example 2 + + +~~~PowerShell + git commit -Title "Changing Stuff" -Trailers @{"Co-Authored-By"="SOMEONE ELSE "} +~~~ + ### Git.Commit Example 1 @@ -242,6 +196,13 @@ It will attempt to locate any output specified by -o and return it as a file or git init # Initialize the current directory as a repository ~~~ +### Git.Log.Input Example 1 + + +~~~PowerShell + git log -CurrentBranch +~~~ + ### Git.Log Example 1 @@ -415,6 +376,94 @@ It will attempt to locate any output specified by -o and return it as a file or git status | Select-Object -ExpandProperty Untracked ~~~ +## Out-Git Extensions + +### Git Commands + +Most extensions handle output from a single git command. + + +* [Git Branch](Git.Branch-Extension.md) + + +* [Git Checkout](Git.Checkout-Extension.md) + + +* [Git Clone](Git.Clone-Extension.md) + + +* [Git Commit](Git.Commit-Extension.md) + + +* [Git Diff](Git.Diff-Extension.md) + + +* [Git FileName](Git.FileName-Extension.md) + + +* [Git Grep](Git.Grep-Extension.md) + + +* [Git Help All](Git.Help.All-Extension.md) + + +* [Git Init](Git.Init-Extension.md) + + +* [Git Log](Git.Log-Extension.md) + + +* [Git Mv](Git.Mv-Extension.md) + + +* [Git Pull](Git.Pull-Extension.md) + + +* [Git Push](Git.Push-Extension.md) + + +* [Git RefLog](Git.RefLog-Extension.md) + + +* [Git Remote](Git.Remote-Extension.md) + + +* [Git Rm](Git.Rm-Extension.md) + +* [Git Shortlog](Git.Shortlog-Extension.md) + +* [Git Stash](Git.Stash-Extension.md) + + +* [Git Status](Git.Status-Extension.md) + + +### Additional Output Extensions + +A few extensions handle output from any number of git commands, depending on the arguments. + +* Git.FileName + +This applies to any git command that uses --name-only. +It will attempt to return the name as a file, or as an object containing the name. + +* Git.FileOutput + +This applies to an git command that uses the -o flag. +It will attempt to locate any output specified by -o and return it as a file or directory. + +## Use-Git Extensions + +ugit also allows you to extend the input for git. + + +* [Git Clone Input](Git.Clone.Input-Extension.md) + + +* [Git Commit Input](Git.Commit.Input-Extension.md) + + +* [Git Log Input](Git.Log.Input-Extension.md) diff --git a/docs/assets/ugit.svg b/docs/assets/ugit.svg index 4f67e585..4a8fdd5d 100644 --- a/docs/assets/ugit.svg +++ b/docs/assets/ugit.svg @@ -3,6 +3,9 @@ - - ugit + + + u + git + diff --git a/ugit.GitHubWorkflow.PSDevOps.ps1 b/ugit.GitHubWorkflow.PSDevOps.ps1 index c606101b..acf820a6 100644 --- a/ugit.GitHubWorkflow.PSDevOps.ps1 +++ b/ugit.GitHubWorkflow.PSDevOps.ps1 @@ -1,7 +1,12 @@ #requires -Module PSDevOps Push-Location $PSScriptRoot Import-BuildStep -ModuleName ugit -New-GitHubWorkflow -Name "Analyze, Test, Tag, and Publish" -On Push, PullRequest, Demand -Job PowerShellStaticAnalysis, TestPowerShellOnLinux, TagReleaseAndPublish, buildugit | - Set-Content .\.github\workflows\TestAndPublish.yml -Encoding UTF8 -PassThru +New-GitHubWorkflow -Name "Analyze, Test, Tag, and Publish" -On Push, PullRequest, Demand -Job PowerShellStaticAnalysis, + TestPowerShellOnLinux, + TagReleaseAndPublish, + buildugit -OutputPath .\.github\workflows\TestAndPublish.yml + +New-GitHubWorkflow -On Issue, + Demand -Job RunGitPub -Name OnIssueChanged -OutputPath .\.github\workflows\OnIssue.yml Pop-Location \ No newline at end of file diff --git a/ugit.PSSVG.ps1 b/ugit.PSSVG.ps1 index bc4e2e47..dfebcf68 100644 --- a/ugit.PSSVG.ps1 +++ b/ugit.PSSVG.ps1 @@ -1,8 +1,8 @@ #requires -Module PSSVG $psChevron = - = -Id psChevron -Content @( - = -Points (@( + svg.symbol -Id psChevron -Content @( + svg.polygon -Points (@( "40,20" "45,20" "60,50" @@ -12,19 +12,18 @@ $psChevron = ) -join ' ') ) -ViewBox 100, 100 -PreserveAspectRatio $false - $assetsPath = Join-Path $PSScriptRoot assets if (-not (Test-Path $assetsPath)) { $null = New-item -ItemType Directory -Path $assetsPath } -= -ViewBox 300, 100 @( +svg -ViewBox 300, 100 @( $psChevron - - = -Href '#psChevron' -Fill '#4488ff' -X 120 -Y 37.5% -Width 10% -Height 25% - = -X 50% -Y 50% -TextAnchor 'middle' -DominantBaseline 'middle' -Content @( - "ugit" - ) -FontFamily 'serif' -Fill '#4488ff' -) -OutputPath (Join-Path $assetsPath ugit.svg) - + svg.use -Href '#psChevron' -Fill '#4488ff' -X 30% -Y 37.5% -Width 10% -Height 25% + + svg.text -X 50% -Y 50% -TextAnchor 'middle' -DominantBaseline 'middle' -Content @( + SVG.tspan -FontSize .5em -Content 'u' + SVG.tspan -FontSize 1em -Content 'git' -Dx -.25em + ) -FontFamily 'serif' -Fill '#4488ff' -FontSize 4em +) -OutputPath (Join-Path $assetsPath ugit.svg) \ No newline at end of file diff --git a/ugit.format.ps1xml b/ugit.format.ps1xml index d7b9741c..cb455e42 100644 --- a/ugit.format.ps1xml +++ b/ugit.format.ps1xml @@ -2186,27 +2186,51 @@ $BackgroundColor ) - - Remote Branches: - + + $_.RemoteBranches + + + [Environment]::NewLine + ' Remote Branches:' + [Environment]::NewLine + + + + + $_.RemoteBranches + RemoteBranches GitRemoteBranchList - - Local Branches: - + + $_.LocalBranches + + + [Environment]::NewLine + ' Local Branches:' + [Environment]::NewLine + + + + + $_.LocalBranches + LocalBranches GitRemoteBranchList - Tracked Upstreams: - + + $_.TrackedUpstreams + + + [Environment]::NewLine + ' Tracked Upstreams:' + [Environment]::NewLine + + + + + $_.TrackedUpstreams + TrackedUpstreams GitRemoteBranchList - diff --git a/ugit.psd1 b/ugit.psd1 index 94412c93..12e017c8 100644 --- a/ugit.psd1 +++ b/ugit.psd1 @@ -1,5 +1,5 @@ @{ - ModuleVersion = '0.3.7' + ModuleVersion = '0.3.8' RootModule = 'ugit.psm1' FormatsToProcess = 'ugit.format.ps1xml' TypesToProcess = 'ugit.types.ps1xml' @@ -17,6 +17,22 @@ PrivateData = @{ LicenseURI = 'https://github.com/StartAutomating/ugit/blob/main/LICENSE' BuildModule = @('EZOut', 'Piecemeal', 'PipeScript') ReleaseNotes = @' +## 0.3.8: + +* Use-Git can now be extended (#140, #97), letting you add PowerShell parameters to any git command +* Initial input extensions + * git.clone.input (#141) (--progress is inferred so Write-Progress happens automagically) + * git.log.input (#142) (Added -Before/-After/-Author/-CurrentBranch) + * git.commit.input (#144) (Added -Message/-Body/-Title/-Trailer) +* Other Improvements: + * git log will not process --pretty/--format (Fixes #143) + * git log now supports .Trailers (Fixes #112) + * git remote formatting improved (Fixes #145) + * git remote now works for multiple remotes (Fixes #136) + * Updated logo (#139) + +--- + ## 0.3.7: * git remote