Skip to content

Commit d0ed669

Browse files
author
Qingqing Sun
committed
update appveyor
1 parent f6b4577 commit d0ed669

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

appveyor.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ build_script:
88
99
$docPath = Join-Path (Get-Item -Path ".\" -Verbose).FullName $env:DocFolder
1010
$files = Get-ChildItem -Path $docPath -Recurse | where {$_.extension -eq $env:Extension} | % { $_.FullName }
11-
$source_repo = "source_repo: " + $env:SourceRepo
12-
$source_branch = "source_branch: " + $env:SourceBranch
11+
$pattern = '^(?s)\s*[-]{3}(.*?)[-]{3}\r?\n'
1312
1413
Write-Host "Found " $files.count "Files"
1514
1615
foreach($file in $files)
1716
{
18-
if(!((Get-Content $file | Out-String) -match '^(?s)\s*[-]{3}(.*?)[-]{3}\r?\n'))
17+
if(!((Get-Content $file | Out-String) -match $pattern))
1918
{
2019
continue
2120
}
@@ -26,7 +25,7 @@ build_script:
2625
#metadata: updated_at
2726
$date = [datetime](Get-ItemProperty -Path $file -Name LastWriteTime).lastwritetime
2827
29-
if($header -match '$env:updateat[\s\S].*')
28+
if($header -match 'updated_at[\s\S].*')
3029
{
3130
$new_header = $new_header.replace($matches[0], 'updated_at: ' + (Get-Date $date -format g))
3231
}
@@ -35,23 +34,28 @@ build_script:
3534
$new_header = $new_header + 'updated_at: ' + (Get-Date $date -format g) + "`r`n"
3635
}
3736
#metadata: ms.date
38-
if($header -match 'ms.date:[\s\S].*')
37+
if($header -match 'ms.date[\s\S].*')
3938
{
4039
$new_header = $new_header.replace($matches[0], 'ms.date: ' + (Get-Date $date -format d))
4140
}
4241
else
4342
{
4443
$new_header = $new_header + 'ms.date: ' + (Get-Date $date -format d) + "`r`n"
4544
}
45+
Set-Content $file (Get-Content $file | Out-String).replace($header, $new_header) -NoNewline
4646
47+
(Get-Content $file | Out-String) -match $pattern | out-null
48+
$header = $matches[1]
49+
$new_header = $matches[1]
50+
4751
#metadata: ms.topic
4852
$topicType = 'reference'
4953
if($header -match 'Module Name')
5054
{
5155
$topicType = 'conceptual'
5256
}
5357
54-
if($header -match 'ms.topic:[\s|\S].*')
58+
if($header -match 'ms.topic[\s\S].*')
5559
{
5660
$new_header = $new_header.replace($matches[0], 'ms.topic: ' + $topicType)
5761
}
@@ -60,35 +64,42 @@ build_script:
6064
$new_header = $new_header + 'ms.topic: ' + $topicType + "`r`n"
6165
}
6266
63-
#metadata: source_repo
64-
if($header -match 'source_repo[\s|\S].*')
67+
#metadata: content_git_url and original_content_git_url
68+
$rel_path = Get-Item $file | Resolve-Path -Relative
69+
$git_url_path = $env:source_repo + '/blob/' + $env:source_branch +'/' + $rel_path
70+
$git_url = (New-object System.Uri $git_url_path).AbsoluteUri
71+
72+
if($header -match 'content_git_url[\s\S].*')
6573
{
66-
$new_header = $new_header.replace($matches[0], $source_repo)
74+
$new_header = $new_header.replace($matches[0], 'content_git_url: ' + $git_url)
6775
}
6876
else
6977
{
70-
$new_header = $new_header + $source_repo +"`r`n"
78+
$new_header = $new_header + 'content_git_url: ' + $git_url + "`r`n"
7179
}
72-
73-
#metadata: source_branch
74-
if($header -match 'source_branch[\s|\S].*')
80+
81+
if($header -match 'original_content_git_url[\s\S].*')
7582
{
76-
$new_header = $new_header.replace($matches[0], $source_branch)
83+
$new_header = $new_header.replace($matches[0], 'original_content_git_url: ' + $git_url)
7784
}
7885
else
7986
{
80-
$new_header = $new_header + $source_branch + "`r`n"
87+
$new_header = $new_header + 'original_content_git_url: ' + $git_url + "`r`n"
8188
}
8289
83-
#metadata: git_commit
90+
#metadata: gitcommit
8491
$commitId = (git rev-list -1 HEAD $file)
85-
if($header -match 'git_commit:[\s|\S].*')
92+
$git_commit_path = $env:source_repo + '/blob/' + $commitId + '/' + $rel_path
93+
$git_commit_url = (New-object System.Uri $git_commit_path).AbsoluteUri
94+
95+
if($header -match 'gitcommit[\s\S].*')
8696
{
87-
$new_header = $new_header.replace($matches[0], 'git_commit: ' + $commitId)
97+
98+
$new_header = $new_header.replace($matches[0], 'gitcommit: ' + $git_commit_url)
8899
}
89100
else
90101
{
91-
$new_header = $new_header + 'git_commit: ' + $commitId + "`r`n"
102+
$new_header = $new_header + 'gitcommit: ' + $git_commit_url + "`r`n"
92103
}
93104
94105
#filter invalid characters

0 commit comments

Comments
 (0)