-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtfs-garbage.ps1
More file actions
66 lines (54 loc) · 1.43 KB
/
tfs-garbage.ps1
File metadata and controls
66 lines (54 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# home for all this TFS VC garbage
function commit (
$files = ".", # . or named items
$comment, # a nice string, required
[switch] $recursive = $true,
[switch] $bypass) {
$cmd = "tf checkin $files /comment:$comment"
if ($recursive) {
cmd += " /r"
}
if ($bypass) {
$cmd += " /noprompt /bypass";
}
Invoke-Expression $cmd
}
function tf-undo ($f) {
tf undo $f /noprompt
}
function tf-diff {
tf diff . /r /format:unified /type:text /ignorespace | color-udiff
}
function color-udiff {
Param(
[Parameter(
Position=0,
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[Alias('l')] [String[]] $lines)
process {
foreach ($line in $lines) {
if ($line.length -gt 1) {
$start = $_.substring(0, 1)
switch ($start) {
"+" { ansi green $line; break; }
"-" { ansi red $line; break; }
"@" { ansi magenta $line; break; }
default { $line; break; }
}
} else {
$line;
}
}
}
}
function ansi ($color, $text) {
$c = [char]0x001b # the magic escape
switch ($color.toLower()) {
"red" { return "${c}[31m${text}${c}[39m"; }
"green" { return "${c}[32m${text}${c}[39m"; }
"magenta" { return "${c}[35m${text}${c}[39m"; }
default { return "${text}"; }
}
}