Skip to content

Commit 92f57a4

Browse files
LucasYao93dingmeng-xuewyunchi-ms
authored
fix the issue that detected special commit incorrectly in use GenerateExternalContributors.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 <[email protected]> Co-authored-by: Yunchi Wang <[email protected]>
1 parent 1cc9482 commit 92f57a4

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

tools/GenerateExternalContributors.ps1

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ param(
1717
[int]
1818
$DaysBack = 28
1919
)
20-
2120
$SinceDate = (Get-Date).AddDays((0-$DaysBack))
2221
$SinceDateStr = $SinceDate.ToString('yyyy-MM-ddTHH:mm:ssZ')
2322
$Branch = git branch --show-current # The Git 2.22 and above support.
@@ -74,28 +73,43 @@ $sortPRs = $validPRs | Sort-Object -Property @{Expression = {$_.author.login}; D
7473

7574
$skipContributors = @('aladdindoc')
7675

77-
$contributorsMDHeaderFlag = $True
76+
# Get team members of the azure-powershell-team.
77+
$teamMembers = (Invoke-WebRequest -Uri "https://api.github.com/orgs/Azure/teams/azure-powershell-team/members" -Authentication Bearer -Token $token).Content | ConvertFrom-Json
78+
79+
foreach ($members in $teamMembers) {
80+
$skipContributors += $members.login
81+
}
82+
83+
# Output external contributors information.
84+
Write-Debug 'Output external contributors information.'
85+
'### Thanks to our community contributors' | Out-File -FilePath $contributorsMDFile -Force
86+
Write-Host '### Thanks to our community contributors'
87+
7888
for ($PR = 0; $PR -lt $sortPRs.Length; $PR++) {
79-
if ($skipContributors.Contains($sortPRs[$PR].author.login))
89+
90+
$account = $sortPRs[$PR].author.login
91+
$name = $sortPRs[$PR].commit.author.name
92+
$index = $sortPRs[$PR].commit.message.IndexOf("`n`n")
93+
94+
if ($skipContributors.Contains($account))
8095
{
8196
continue
8297
}
98+
99+
# Skip if commit author exists in skipContributors list.
100+
if ([System.String]::IsNullOrEmpty($account) -and $skipContributors.Contains($name))
101+
{
102+
continue
103+
}
104+
83105
# Check whether the contributor belongs to the Azure organization.
84106
Invoke-RestMethod -Uri "https://api.github.com/orgs/Azure/members/$($sortPRs[$PR].author.login)" -Authentication Bearer -Token $token -ResponseHeadersVariable 'ResponseHeaders' -StatusCodeVariable 'StatusCode' -SkipHttpErrorCheck > $null
85107
if ($StatusCode -eq '204') {
86108
# Add internal contributors to skipContributors to reduce the number of https requests sent.
87109
$skipContributors += $sortPRs[$PR].author.login
88110
continue
89111
}
90-
if ($contributorsMDHeaderFlag) {
91-
Write-Debug 'Output exteneral contributors infomation.'
92-
'### Thanks to our community contributors' | Out-File -FilePath $contributorsMDFile -Force
93-
Write-Host '### Thanks to our community contributors'
94-
$contributorsMDHeaderFlag = $False
95-
}
96-
$account = $sortPRs[$PR].author.login
97-
$name = $sortPRs[$PR].commit.author.name
98-
$index = $sortPRs[$PR].commit.message.IndexOf("`n`n")
112+
99113
if ($index -lt 0) {
100114
$commitMessage = $sortPRs[$PR].commit.message
101115
} else {

0 commit comments

Comments
 (0)