-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovePRFiles.ps1
More file actions
100 lines (82 loc) · 2.39 KB
/
MovePRFiles.ps1
File metadata and controls
100 lines (82 loc) · 2.39 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Param([string]$repo)
Write-Output("Getting difference to master")
$cwd = Get-Location
Set-Location "$ENV:BUILD_SOURCESDIRECTORY\$repo"
$diffFiles = $(git diff origin/master --name-only)
$projectName = $ENV:PROJECTNAME
$project = $projectName
If($project -match "_Toolkit$")
{
$parts = $projectName.split("_")
$project = $parts[0]
}
$pathOM = "$ENV:BUILD_SOURCESDIRECTORY\PRTestFiles\" + $projectName + "\" + $project + "_oM"
$pathEngine = "$ENV:BUILD_SOURCESDIRECTORY\PRTestFiles\" + $projectName + "\" + $project + "_Engine"
$pathAdapter = "$ENV:BUILD_SOURCESDIRECTORY\PRTestFiles\" + $projectName + "\" + $project+ "_Adapter"
If(!(test-path $pathOM))
{
New-Item -ItemType Directory -Force -Path $pathOM
}
If(!(test-path $pathEngine))
{
New-Item -ItemType Directory -Force -Path $pathEngine
}
If(!(test-path $pathAdapter))
{
New-Item -ItemType Directory -Force -Path $pathAdapter
}
$oMName = $project + "_oM"
$engineName = $project + "_Engine"
$adapterName = $project + "_Adapter"
Foreach($diff in $diffFiles)
{
If(test-path $diff)
{
$folderPathParts = $diff.split("/")
If($diff -like "*_oM*")
{
$index = [array]::indexof($folderPathParts, $oMName)
$savePath = $pathOM
For($x = $index + 1; $x -lt $folderPathParts.Count - 1; $x++)
{
$savePath = $savePath + "\" + $folderPathParts[$x]
}
If(!(test-path $savePath))
{
New-Item -ItemType Directory -Force -Path $savePath
}
Write-Output("Copying " + $diff + " to " + $savePath)
Copy-Item $diff -Destination $savePath
}
If($diff -like "*_Engine*")
{
$index = [array]::indexof($folderPathParts, $engineName)
$savePath = $pathEngine
For($x = $index + 1; $x -lt $folderPathParts.Count - 1; $x++)
{
$savePath = $savePath + "\" + $folderPathParts[$x]
}
If(!(test-path $savePath))
{
New-Item -ItemType Directory -Force -Path $savePath
}
Write-Output("Copying " + $diff + " to " + $savePath)
Copy-Item $diff -Destination $savePath
}
If($diff -like "*_Adapter*")
{
$index = [array]::indexof($folderPathParts, $adapterName)
$savePath = $pathAdapter
For($x = $index + 1; $x -lt $folderPathParts.Count - 1; $x++)
{
$savePath = $savePath + "\" + $folderPathParts[$x]
}
If(!(test-path $savePath))
{
New-Item -ItemType Directory -Force -Path $savePath
}
Write-Output("Copying " + $diff + " to " + $savePath)
Copy-Item $diff -Destination $savePath
}
}
}