Skip to content

Commit

Permalink
Block changes to Automatic review revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenkuttappan committed Dec 19, 2022
1 parent 4f6a9fd commit 596c191
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions eng/pipelines/apiview-review-gen-cadl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
-Reviews "$(Reviews)"
-OutputDir "$(Build.ArtifactStagingDirectory)"
-WorkingDir "$(Pipeline.Workspace)"
-GitPat "$(github-access-token)"
- task: PublishBuildArtifacts@1
inputs:
Expand Down
29 changes: 20 additions & 9 deletions eng/scripts/Create-Apiview-Token-Cadl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ param (
[ValidateNotNullOrEmpty()]
[string] $WorkingDir,
[ValidateNotNullOrEmpty()]
[string] $OutputDir
[string] $OutputDir,
[string] $GitPat = ""
)

Set-StrictMode -Version 3
Expand All @@ -20,7 +21,7 @@ function Sparse-Checkout($branchName, $packagePath)
}
git sparse-checkout init --cone
git sparse-checkout set $packagePath
git checkout $BranchName
git checkout $branchName
}

function Generate-Apiview-File($packagePath)
Expand Down Expand Up @@ -70,20 +71,30 @@ if ($revs)
Write-Host "URL to Repo: '$($GitRepoName), Branch name: '$($branchName), Package Path: '$($packagePath)"

$repoDirectory = Split-Path $GitRepoName -leaf
if (Test-Path $repoDirectory)
{
Write-Host "Destination path '$($repoDirectory)' already exists in working directory and is not an empty directory."
exit 1
}
# initialize git clone if current review is generated from different repo than previous one
if ($GitRepoName -ne $prevRepo)
{
git clone --no-checkout --filter=tree:0 "https://github.com/$GitRepoName"
$gitUrl = "https://github.com"
if ($GitPat)
{
$gitUrl = "https://$GitPat@github.com"
}

<<<<<<< HEAD
$gitUrl = "$gitUrl/$GitRepoName.git"
if (Test-Path $repoDirectory)
{
Write-Host "Destination path '$($repoDirectory)' already exists in working directory. Deleting '$($repoDirectory)'"
Remove-Item $repoDirectory -Force -Recurse
}
git clone --no-checkout --filter=tree:0 $gitUrl
=======
git clone --no-checkout --filter=tree:0 "$gitUrl/$GitRepoName"
>>>>>>> dcab34d3 (Update Git clone URL using pat)
if ($LASTEXITCODE) { exit $LASTEXITCODE }
$prevRepo = $GitRepoName
}

$repoDirectory = Split-Path $GitRepoName -leaf
Push-Location $repoDirectory
try
{
Expand Down
14 changes: 9 additions & 5 deletions src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Revisions.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
<partial name="Shared/_ReviewBadge" model=" Model.Review" />
</div>
</div>
<div class="row" asp-resource="@Model.Review" asp-requirement="@AutoReviewModifierRequirement.Instance">
<div class="bottom-right-floating">
<button type="button" class="btn btn-primary btn-circle btn-circle-xl" data-toggle="modal" data-target="#uploadModel"><small>ADD</small></br><i class="fas fa-sm fa-plus"></i></br><small>REVISION</small></button>
</div>
</div>
@if (Model.Review.FilterType == ReviewType.Manual)
{
<div class="row" asp-resource="@Model.Review" asp-requirement="@AutoReviewModifierRequirement.Instance">
<div class="bottom-right-floating">
<button type="button" class="btn btn-primary btn-circle btn-circle-xl" data-toggle="modal" data-target="#uploadModel"><small>ADD</small><br><i class="fas fa-sm fa-plus"></i><br><small>REVISION</small></button>
</div>
</div>
}


<div class="modal fade" id="uploadModel" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
Expand Down

0 comments on commit 596c191

Please sign in to comment.