diff --git a/tools/Gen2Master/MoveFromGeneration2Master.ps1 b/tools/Gen2Master/MoveFromGeneration2Master.ps1 index af43b56f7769..fab91e39d968 100644 --- a/tools/Gen2Master/MoveFromGeneration2Master.ps1 +++ b/tools/Gen2Master/MoveFromGeneration2Master.ps1 @@ -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())