Skip to content

Commit d2e09b4

Browse files
committed
Format document
1 parent d451f5a commit d2e09b4

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

@@ -8,95 +8,95 @@ $ErrorActionPreference = "Stop"
88

99
function Invoke-RestMethod-Ex($url, $downloadLocation) {
1010

11-
$irmParams = @{
12-
}
11+
$irmParams = @{
12+
}
1313

14-
Write-Host -ForegroundColor "White" "-> Get $url"
14+
Write-Host -ForegroundColor "White" "-> Get $url"
1515

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

21-
if ("$proxyUri" -ne "$url") {
22-
$irmParams.Proxy = "$proxyUri"
23-
$irmParams.ProxyUseDefaultCredentials = $true
21+
if ("$proxyUri" -ne "$url") {
22+
$irmParams.Proxy = "$proxyUri"
23+
$irmParams.ProxyUseDefaultCredentials = $true
24+
}
2425
}
25-
}
2626

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

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

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

37-
return $output
37+
return $output
3838
}
3939

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

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

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

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

50-
return $buildNumber
50+
return $buildNumber
5151
}
5252

5353
function Download-AppVeyor-Artifacts($statuses, $downloadLocation) {
54-
$prOrBranch = "branch"
54+
$prOrBranch = "branch"
5555

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

60-
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/appveyor/$prOrBranch"
60+
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/appveyor/$prOrBranch"
6161

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

65-
$jobId = $build.build.jobs[0].jobId
65+
$jobId = $build.build.jobs[0].jobId
6666

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

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

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

7979
function Download-Travis-Artifacts($statuses, $downloadLocation) {
80-
$prOrBranch = "push"
80+
$prOrBranch = "push"
8181

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

86-
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/travis-ci/$prOrBranch"
86+
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/travis-ci/$prOrBranch"
8787

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

91-
$buildNumber = $build.number
91+
$buildNumber = $build.number
9292

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

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

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

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

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

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

0 commit comments

Comments
 (0)