Skip to content

Commit

Permalink
fix the issue that detected special commit incorrectly in use Generat…
Browse files Browse the repository at this point in the history
…eExternalContributors.ps1 (Azure#14828)

Force merge due to timeout.

* fix the issue that detected special commit incorrectly in use GenerateExternalContributors.ps1.

* change code comment.

* adjust code to use logic and

Co-authored-by: Dingmeng Xue <dixue@microsoft.com>
Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 28, 2021
1 parent 1cc9482 commit 92f57a4
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions tools/GenerateExternalContributors.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ param(
[int]
$DaysBack = 28
)

$SinceDate = (Get-Date).AddDays((0-$DaysBack))
$SinceDateStr = $SinceDate.ToString('yyyy-MM-ddTHH:mm:ssZ')
$Branch = git branch --show-current # The Git 2.22 and above support.
Expand Down Expand Up @@ -74,28 +73,43 @@ $sortPRs = $validPRs | Sort-Object -Property @{Expression = {$_.author.login}; D

$skipContributors = @('aladdindoc')

$contributorsMDHeaderFlag = $True
# Get team members of the azure-powershell-team.
$teamMembers = (Invoke-WebRequest -Uri "https://api.github.com/orgs/Azure/teams/azure-powershell-team/members" -Authentication Bearer -Token $token).Content | ConvertFrom-Json

foreach ($members in $teamMembers) {
$skipContributors += $members.login
}

# Output external contributors information.
Write-Debug 'Output external contributors information.'
'### Thanks to our community contributors' | Out-File -FilePath $contributorsMDFile -Force
Write-Host '### Thanks to our community contributors'

for ($PR = 0; $PR -lt $sortPRs.Length; $PR++) {
if ($skipContributors.Contains($sortPRs[$PR].author.login))

$account = $sortPRs[$PR].author.login
$name = $sortPRs[$PR].commit.author.name
$index = $sortPRs[$PR].commit.message.IndexOf("`n`n")

if ($skipContributors.Contains($account))
{
continue
}

# Skip if commit author exists in skipContributors list.
if ([System.String]::IsNullOrEmpty($account) -and $skipContributors.Contains($name))
{
continue
}

# Check whether the contributor belongs to the Azure organization.
Invoke-RestMethod -Uri "https://api.github.com/orgs/Azure/members/$($sortPRs[$PR].author.login)" -Authentication Bearer -Token $token -ResponseHeadersVariable 'ResponseHeaders' -StatusCodeVariable 'StatusCode' -SkipHttpErrorCheck > $null
if ($StatusCode -eq '204') {
# Add internal contributors to skipContributors to reduce the number of https requests sent.
$skipContributors += $sortPRs[$PR].author.login
continue
}
if ($contributorsMDHeaderFlag) {
Write-Debug 'Output exteneral contributors infomation.'
'### Thanks to our community contributors' | Out-File -FilePath $contributorsMDFile -Force
Write-Host '### Thanks to our community contributors'
$contributorsMDHeaderFlag = $False
}
$account = $sortPRs[$PR].author.login
$name = $sortPRs[$PR].commit.author.name
$index = $sortPRs[$PR].commit.message.IndexOf("`n`n")

if ($index -lt 0) {
$commitMessage = $sortPRs[$PR].commit.message
} else {
Expand Down

0 comments on commit 92f57a4

Please sign in to comment.