Skip to content

Commit

Permalink
Update the logic of get commit id in autorest generation (#20827)
Browse files Browse the repository at this point in the history
* Update the logic of get commit id in autorest generation

* Update the logic of get commit id in autorest generation
  • Loading branch information
wyunchi-ms authored Feb 2, 2023
1 parent bc01fa8 commit d2fbb74
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/Gen2Master/MoveFromGeneration2Master.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,14 @@ Function Move-Generation2Master {

#Region generate-info.json Here have a issue that user may not use latest version to generate the code.
$generateInfo = [ordered]@{}
$repo = "https://github.com/Azure/azure-rest-api-specs"
$commit = git ls-remote $repo HEAD
$generateInfo.Add("swagger_commit", $commit.Substring(0, 40))
$content = Get-Content README.md
$commitId = [System.Text.RegularExpressions.Regex]::New("(?i)\bbranch\b:[ \t]*([0-9a-zA-Z]+)").Matches($content) | % {$_.groups[1].Value}
if ($commitId -eq $null -or $commitId -eq "main")
{
$repo = "https://github.com/Azure/azure-rest-api-specs"
$commitId = git ls-remote $repo HEAD
}
$generateInfo.Add("swagger_commit", $commitId.Substring(0, 40))
$generateInfo.Add("node", (node --version))
$autorest_info = (npm ls -g @autorest/autorest).Split('@')
$generateInfo.Add("autorest", ($autorest_info[$autorest_info.count - 2]).trim())
Expand Down

0 comments on commit d2fbb74

Please sign in to comment.