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.
  • Loading branch information
LucasYao93 committed Apr 26, 2021
1 parent 1fec5a2 commit d327bb3
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 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,46 @@ $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 exteneral contributors infomation.
Write-Debug 'Output exteneral contributors infomation.'
'### 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
}

if ([System.String]::IsNullOrEmpty($account))
{
# Skip if commit author exists in skipContributors list.
if ($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 d327bb3

Please sign in to comment.