Skip to content

Commit 6a89cb5

Browse files
Merge pull request #72 from StartAutomating/ugitMoving
UgitMoving
2 parents 03bb332 + d26d5fb commit 6a89cb5

File tree

7 files changed

+102
-1
lines changed

7 files changed

+102
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.7:
2+
* Adding support for git mv (#70, thanks @ninmonkey !)
3+
---
4+
15
## 0.2.6:
26
* Fixing git diff for binary files (#47)
37
---
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<#
2+
.Synopsis
3+
Git Move Extension
4+
.Description
5+
Outputs git mv as objects.
6+
.EXAMPLE
7+
git mv .\OldName.txt .\NewName.txt
8+
.EXAMPLE
9+
git mv .\OldName.txt .\NewName.txt --verbose
10+
#>
11+
[Management.Automation.Cmdlet("Out","Git")] # It's an extension for Out-Git
12+
[ValidatePattern("^git mv")] # that is run when the switch -o is used.
13+
[OutputType([IO.FileInfo])]
14+
param( )
15+
16+
begin {
17+
$moveLines = @()
18+
}
19+
20+
process {
21+
$moveLines += $gitOut
22+
}
23+
24+
end {
25+
if ($gitArgument -match '--(?>n|dry-run)') {
26+
return $moveLines
27+
}
28+
29+
# Take all non-dashed arguments to git.
30+
$cmd, # The first is 'mv'
31+
$source, # The second is the source
32+
$dest, # The third is the detination.
33+
$null = # (ignore anything else)
34+
$gitArgument -notlike '-*'
35+
36+
if (-not (Test-Path $dest)) { return $moveLines }
37+
38+
$destItem = Get-Item $dest -ErrorAction SilentlyContinue
39+
@(if ($destItem -is [IO.DirectoryInfo]) {
40+
$destItem = Get-Item (Join-Path $destItem $source)
41+
$destItem
42+
} elseif ($destItem) {
43+
$destItem
44+
} else {
45+
return $moveLines
46+
}) |
47+
Add-Member NoteProperty Source (Join-Path $gitRoot $source) -Force -PassThru |
48+
Add-Member NoteProperty Destination $destItem.FullName -Force -PassThru |
49+
Add-Member NoteProperty GitRoot $gitRoot -Force -PassThru |
50+
Add-Member NoteProperty GitCommand $gitCommand -Force -PassThru
51+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/
6767
* git commit
6868
* git diff
6969
* git log
70+
* git mv
7071
* git pull
7172
* git push
7273
* git reflog

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.7:
2+
* Adding support for git mv (#70, thanks @ninmonkey !)
3+
---
4+
15
## 0.2.6:
26
* Fixing git diff for binary files (#47)
37
---

docs/Git.Mv-Extension.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
Extensions/Git.Mv.UGit.Extension.ps1
3+
------------------------------------
4+
### Synopsis
5+
Git Move Extension
6+
7+
---
8+
### Description
9+
10+
Outputs git mv as objects.
11+
12+
---
13+
### Examples
14+
#### EXAMPLE 1
15+
```PowerShell
16+
git mv .\OldName.txt .\NewName.txt
17+
```
18+
19+
#### EXAMPLE 2
20+
```PowerShell
21+
git mv .\OldName.txt .\NewName.txt --verbose
22+
```
23+
24+
---
25+
### Outputs
26+
System.IO.FileInfo
27+
28+
29+
---
30+
### Syntax
31+
```PowerShell
32+
Extensions/Git.Mv.UGit.Extension.ps1 [<CommonParameters>]
33+
```
34+
---
35+
36+

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/
6767
* git commit
6868
* git diff
6969
* git log
70+
* git mv
7071
* git pull
7172
* git push
7273
* git reflog

ugit.psd1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.2.6'
2+
ModuleVersion = '0.2.7'
33
RootModule = 'ugit.psm1'
44
FormatsToProcess = 'ugit.format.ps1xml'
55
TypesToProcess = 'ugit.types.ps1xml'
@@ -16,6 +16,10 @@ PrivateData = @{
1616
ProjectURI = 'https://github.com/StartAutomating/ugit'
1717
LicenseURI = 'https://github.com/StartAutomating/ugit/blob/main/LICENSE'
1818
ReleaseNotes = @'
19+
## 0.2.7:
20+
* Adding support for git mv (#70, thanks @ninmonkey !)
21+
---
22+
1923
## 0.2.6:
2024
* Fixing git diff for binary files (#47)
2125
---

0 commit comments

Comments
 (0)