Skip to content

Commit

Permalink
Fixed the problem of not triggered by pull request.
Browse files Browse the repository at this point in the history
  • Loading branch information
sima-zhu committed Aug 17, 2020
2 parents 4333bbc + 4a9ca5f commit 753557b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
Empty file removed eng/common/Test.md
Empty file.
11 changes: 0 additions & 11 deletions eng/common/pipelines/templates/steps/azure-pipeline.yml

This file was deleted.

2 changes: 1 addition & 1 deletion eng/common/pipelines/templates/steps/verify-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ steps:
-rootUrl "file://$(Build.SourcesDirectory)/${{ parameters.Directory }}"
-recursive $false
-ignoreLinksFile ${{ parameters.IgnoreLinksFile }}
-branchReplaceRegex "(https://github.com/.*/blob/)link_replace_test(/.*)"
-branchReplaceRegex "(https://github.com/.*/blob/)link_replace_test(/.*)"
19 changes: 14 additions & 5 deletions eng/common/scripts/Verify-Links.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,21 @@ function CheckLink ([System.Uri]$linkUri)
}
$checkedLinks[$linkUri] = $true;
}
$ReplacementPattern = "`${1}$branchReplacementName`$2"

function ReplaceGithubLink([string]$originLink) {
if ($branchReplacementName -eq "") {
return $originLink
if (-not $branchReplacementName) {
try {
$branchReplacementName = $(system.pullRequest.sourceCommitId)
if (-not $branchReplacementName) {
$ReplacementPattern = "`${1}$branchReplacementName`$2"
return $originLink -replace $branchReplaceRegex, $ReplacementPattern
}
}
catch {
Write-Verbose "It is not triggered by pull request. Skip the replace link steps."
}
}
return $originLink -replace $branchReplaceRegex, $ReplacementPattern
return $originLink
}

function GetLinks([System.Uri]$pageUri)
Expand Down Expand Up @@ -217,7 +226,7 @@ function GetLinks([System.Uri]$pageUri)

return $links;
}
Write-Host "Check the source commit var $(system.pullRequest.sourceCommitId)."

if ($urls) {
if ($urls.Count -eq 0) {
Write-Host "Usage $($MyInvocation.MyCommand.Name) <urls>";
Expand Down

0 comments on commit 753557b

Please sign in to comment.