Skip to content

Commit 853030c

Browse files
committed
Format document
1 parent 543bebb commit 853030c

File tree

1 file changed

+63
-62
lines changed

1 file changed

+63
-62
lines changed

download.build.artifacts.and.package.ps1

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Param(
2-
[string]$ref = "master",
2+
[string]$ref = "master",
33
[switch]$verbose = $False
44
)
55

@@ -9,95 +9,95 @@ $ErrorActionPreference = "Stop"
99
function Invoke-RestMethod-Ex($url, $downloadLocation) {
1010
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
1111

12-
$irmParams = @{
13-
}
12+
$irmParams = @{
13+
}
1414

15-
Write-Host -ForegroundColor "White" "-> Get $url"
15+
Write-Host -ForegroundColor "White" "-> Get $url"
1616

17-
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
18-
if ($proxy) {
19-
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
20-
$proxyUri = $proxy.GetProxy("$url")
17+
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
18+
if ($proxy) {
19+
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
20+
$proxyUri = $proxy.GetProxy("$url")
2121

22-
if ("$proxyUri" -ne "$url") {
23-
$irmParams.Proxy = "$proxyUri"
24-
$irmParams.ProxyUseDefaultCredentials = $true
22+
if ("$proxyUri" -ne "$url") {
23+
$irmParams.Proxy = "$proxyUri"
24+
$irmParams.ProxyUseDefaultCredentials = $true
25+
}
2526
}
26-
}
2727

28-
if ($downloadLocation) {
29-
$irmParams.OutFile = "$downloadLocation"
30-
}
28+
if ($downloadLocation) {
29+
$irmParams.OutFile = "$downloadLocation"
30+
}
3131

32-
$output = Invoke-RestMethod @irmParams -ContentType "application/json" -Method "Get" -Uri "$url"
32+
$output = Invoke-RestMethod @irmParams -ContentType "application/json" -Method "Get" -Uri "$url"
3333

34-
if ($verbose) {
35-
Write-Host -ForegroundColor "Gray" "output = $(ConvertTo-Json $output)"
36-
}
34+
if ($verbose) {
35+
Write-Host -ForegroundColor "Gray" "output = $(ConvertTo-Json $output)"
36+
}
3737

38-
return $output
38+
return $output
3939
}
4040

4141
function Extract-BuildIdentifier($statuses, $forContext) {
4242

43-
$status = $statuses | where { $_.context -eq $forContext } | select -First 1
43+
$status = $statuses | where { $_.context -eq $forContext } | select -First 1
4444

45-
if (($status -eq $null) -or ("success".CompareTo($status.state) -ne 0)) {
46-
throw "No successful status has been found for context `"$forContext`"."
47-
}
45+
if (($status -eq $null) -or ("success".CompareTo($status.state) -ne 0)) {
46+
throw "No successful status has been found for context `"$forContext`"."
47+
}
4848

49-
$buildNumber = $status.target_url.Split("/")[-1]
49+
$buildNumber = $status.target_url.Split("/")[-1]
5050

51-
return $buildNumber
51+
return $buildNumber
5252
}
5353

5454
function Download-AppVeyor-Artifacts($statuses, $downloadLocation) {
55-
$prOrBranch = "branch"
55+
$prOrBranch = "branch"
5656

57-
if ($ref.StartsWith("pull/")) {
58-
$prOrBranch = "pr"
59-
}
57+
if ($ref.StartsWith("pull/")) {
58+
$prOrBranch = "pr"
59+
}
6060

61-
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/appveyor/$prOrBranch"
61+
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/appveyor/$prOrBranch"
6262

63-
Write-Host -ForegroundColor "Yellow" "Retrieving AppVeyor build `"$buildIdentifier`""
64-
$build = Invoke-RestMethod-Ex "https://ci.appveyor.com/api/projects/libgit2/libgit2sharp-nativebinaries/build/$buildIdentifier"
63+
Write-Host -ForegroundColor "Yellow" "Retrieving AppVeyor build `"$buildIdentifier`""
64+
$build = Invoke-RestMethod-Ex "https://ci.appveyor.com/api/projects/libgit2/libgit2sharp-nativebinaries/build/$buildIdentifier"
6565

66-
$jobId = $build.build.jobs[0].jobId
66+
$jobId = $build.build.jobs[0].jobId
6767

68-
Write-Host -ForegroundColor "Yellow" "Retrieving AppVeyor job `"$jobId`" artifacts"
69-
$artifacts = Invoke-RestMethod-Ex "https://ci.appveyor.com/api/buildjobs/$jobId/artifacts"
68+
Write-Host -ForegroundColor "Yellow" "Retrieving AppVeyor job `"$jobId`" artifacts"
69+
$artifacts = Invoke-RestMethod-Ex "https://ci.appveyor.com/api/buildjobs/$jobId/artifacts"
7070

71-
ForEach ($artifact in $artifacts) {
72-
$artifactFileName = $artifacts[0].fileName
73-
$localArtifactPath = "$downloadLocation\$artifactFileName"
71+
ForEach ($artifact in $artifacts) {
72+
$artifactFileName = $artifacts[0].fileName
73+
$localArtifactPath = "$downloadLocation\$artifactFileName"
7474

75-
Write-Host -ForegroundColor "Yellow" "Downloading `"$artifactFileName`""
76-
Invoke-RestMethod-Ex "https://ci.appveyor.com/api/buildjobs/$jobId/artifacts/$artifactFileName" $localArtifactPath
77-
}
75+
Write-Host -ForegroundColor "Yellow" "Downloading `"$artifactFileName`""
76+
Invoke-RestMethod-Ex "https://ci.appveyor.com/api/buildjobs/$jobId/artifacts/$artifactFileName" $localArtifactPath
77+
}
7878
}
7979

8080
function Download-Travis-Artifacts($statuses, $downloadLocation) {
81-
$prOrBranch = "push"
81+
$prOrBranch = "push"
8282

83-
if ($ref.StartsWith("pull/")) {
84-
$prOrBranch = "pr"
85-
}
83+
if ($ref.StartsWith("pull/")) {
84+
$prOrBranch = "pr"
85+
}
8686

87-
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/travis-ci/$prOrBranch"
87+
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/travis-ci/$prOrBranch"
8888

89-
Write-Host -ForegroundColor "Yellow" "Retrieving Travis build `"$buildIdentifier`""
90-
$build = Invoke-RestMethod-Ex "https://api.travis-ci.org/builds/$buildIdentifier"
89+
Write-Host -ForegroundColor "Yellow" "Retrieving Travis build `"$buildIdentifier`""
90+
$build = Invoke-RestMethod-Ex "https://api.travis-ci.org/builds/$buildIdentifier"
9191

92-
$buildNumber = $build.number
92+
$buildNumber = $build.number
9393

94-
ForEach ($platform in @("linux", "osx")) {
95-
$artifactFileName = "binaries-$platform-$buildNumber.zip"
96-
$localArtifactPath = "$downloadLocation\$artifactFileName"
94+
ForEach ($platform in @("linux", "osx")) {
95+
$artifactFileName = "binaries-$platform-$buildNumber.zip"
96+
$localArtifactPath = "$downloadLocation\$artifactFileName"
9797

98-
Write-Host -ForegroundColor "Yellow" "Downloading `"$artifactFileName`""
99-
Invoke-RestMethod-Ex "https://dl.bintray.com/libgit2/compiled-binaries/$artifactFileName" $localArtifactPath
100-
}
98+
Write-Host -ForegroundColor "Yellow" "Downloading `"$artifactFileName`""
99+
Invoke-RestMethod-Ex "https://dl.bintray.com/libgit2/compiled-binaries/$artifactFileName" $localArtifactPath
100+
}
101101
}
102102

103103
######################################################
@@ -109,13 +109,14 @@ Write-Host -ForegroundColor "Yellow" "Creating temporary folder at `"$path`""
109109
New-Item "$path" -type Directory > $null
110110

111111
if ($ref.StartsWith("pull/")) {
112-
$pr = $ref.Replace("pull/", "")
113-
Write-Host -ForegroundColor "Yellow" "Retrieving pull request information for pull request $pr"
112+
$pr = $ref.Replace("pull/", "")
113+
Write-Host -ForegroundColor "Yellow" "Retrieving pull request information for pull request $pr"
114114

115-
$prData = Invoke-RestMethod-Ex "https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/pulls/$pr"
116-
$statusesUrl = $prData.statuses_url
117-
} else {
118-
$statusesUrl = "https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/commits/$ref/statuses"
115+
$prData = Invoke-RestMethod-Ex "https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/pulls/$pr"
116+
$statusesUrl = $prData.statuses_url
117+
}
118+
else {
119+
$statusesUrl = "https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/commits/$ref/statuses"
119120
}
120121

121122
Write-Host -ForegroundColor "Yellow" "Retrieving LibGit2Sharp.NativeBinaries latest CI statuses of `"$ref`""

0 commit comments

Comments
 (0)