-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from StartAutomating/ugitMoving
UgitMoving
- Loading branch information
Showing
7 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>] | ||
``` | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters