Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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