Skip to content

Commit

Permalink
Merge pull request #72 from StartAutomating/ugitMoving
Browse files Browse the repository at this point in the history
UgitMoving
  • Loading branch information
StartAutomating committed Jul 29, 2022
2 parents 03bb332 + d26d5fb commit 6a89cb5
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.7:
* Adding support for git mv (#70, thanks @ninmonkey !)
---

## 0.2.6:
* Fixing git diff for binary files (#47)
---
Expand Down
51 changes: 51 additions & 0 deletions Extensions/Git.Mv.UGit.Extension.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<#
.Synopsis
Git Move Extension
.Description
Outputs git mv as objects.
.EXAMPLE
git mv .\OldName.txt .\NewName.txt
.EXAMPLE
git mv .\OldName.txt .\NewName.txt --verbose
#>
[Management.Automation.Cmdlet("Out","Git")] # It's an extension for Out-Git
[ValidatePattern("^git mv")] # that is run when the switch -o is used.
[OutputType([IO.FileInfo])]
param( )

begin {
$moveLines = @()
}

process {
$moveLines += $gitOut
}

end {
if ($gitArgument -match '--(?>n|dry-run)') {
return $moveLines
}

# Take all non-dashed arguments to git.
$cmd, # The first is 'mv'
$source, # The second is the source
$dest, # The third is the detination.
$null = # (ignore anything else)
$gitArgument -notlike '-*'

if (-not (Test-Path $dest)) { return $moveLines }

$destItem = Get-Item $dest -ErrorAction SilentlyContinue
@(if ($destItem -is [IO.DirectoryInfo]) {
$destItem = Get-Item (Join-Path $destItem $source)
$destItem
} elseif ($destItem) {
$destItem
} else {
return $moveLines
}) |
Add-Member NoteProperty Source (Join-Path $gitRoot $source) -Force -PassThru |
Add-Member NoteProperty Destination $destItem.FullName -Force -PassThru |
Add-Member NoteProperty GitRoot $gitRoot -Force -PassThru |
Add-Member NoteProperty GitCommand $gitCommand -Force -PassThru
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/
* git commit
* git diff
* git log
* git mv
* git pull
* git push
* git reflog
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.7:
* Adding support for git mv (#70, thanks @ninmonkey !)
---

## 0.2.6:
* Fixing git diff for binary files (#47)
---
Expand Down
36 changes: 36 additions & 0 deletions docs/Git.Mv-Extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

Extensions/Git.Mv.UGit.Extension.ps1
------------------------------------
### Synopsis
Git Move Extension

---
### Description

Outputs git mv as objects.

---
### Examples
#### EXAMPLE 1
```PowerShell
git mv .\OldName.txt .\NewName.txt
```

#### EXAMPLE 2
```PowerShell
git mv .\OldName.txt .\NewName.txt --verbose
```

---
### Outputs
System.IO.FileInfo


---
### Syntax
```PowerShell
Extensions/Git.Mv.UGit.Extension.ps1 [<CommonParameters>]
```
---


1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/
* git commit
* git diff
* git log
* git mv
* git pull
* git push
* git reflog
Expand Down
6 changes: 5 additions & 1 deletion ugit.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.2.6'
ModuleVersion = '0.2.7'
RootModule = 'ugit.psm1'
FormatsToProcess = 'ugit.format.ps1xml'
TypesToProcess = 'ugit.types.ps1xml'
Expand All @@ -16,6 +16,10 @@ PrivateData = @{
ProjectURI = 'https://github.com/StartAutomating/ugit'
LicenseURI = 'https://github.com/StartAutomating/ugit/blob/main/LICENSE'
ReleaseNotes = @'
## 0.2.7:
* Adding support for git mv (#70, thanks @ninmonkey !)
---
## 0.2.6:
* Fixing git diff for binary files (#47)
---
Expand Down

0 comments on commit 6a89cb5

Please sign in to comment.