From d327bb30430ae17282b255591e5f84bbb38a41d8 Mon Sep 17 00:00:00 2001 From: Lucas Yao Date: Mon, 26 Apr 2021 14:24:19 +0800 Subject: [PATCH 1/3] fix the issue that detected special commit incorrectly in use GenerateExternalContributors.ps1. --- tools/GenerateExternalContributors.ps1 | 41 ++++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/tools/GenerateExternalContributors.ps1 b/tools/GenerateExternalContributors.ps1 index 281ccf281580..9ed602076f7d 100644 --- a/tools/GenerateExternalContributors.ps1 +++ b/tools/GenerateExternalContributors.ps1 @@ -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. @@ -74,12 +73,38 @@ $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') { @@ -87,15 +112,7 @@ for ($PR = 0; $PR -lt $sortPRs.Length; $PR++) { $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 { From 4dde0b9cbdd93f2f6184367a716a0826ad7485df Mon Sep 17 00:00:00 2001 From: Lucas Yao Date: Mon, 26 Apr 2021 16:03:48 +0800 Subject: [PATCH 2/3] change code comment. --- tools/GenerateExternalContributors.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/GenerateExternalContributors.ps1 b/tools/GenerateExternalContributors.ps1 index 9ed602076f7d..5f6edf0b61b4 100644 --- a/tools/GenerateExternalContributors.ps1 +++ b/tools/GenerateExternalContributors.ps1 @@ -80,8 +80,8 @@ foreach ($members in $teamMembers) { $skipContributors += $members.login } -# Output exteneral contributors infomation. -Write-Debug 'Output exteneral contributors infomation.' +# 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' From 9f58e47746a352f985d7dbfa23bf262cfc565740 Mon Sep 17 00:00:00 2001 From: Lucas Yao Date: Mon, 26 Apr 2021 16:29:29 +0800 Subject: [PATCH 3/3] adjust code to use logic and --- tools/GenerateExternalContributors.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/GenerateExternalContributors.ps1 b/tools/GenerateExternalContributors.ps1 index 5f6edf0b61b4..653972f4ca4e 100644 --- a/tools/GenerateExternalContributors.ps1 +++ b/tools/GenerateExternalContributors.ps1 @@ -96,13 +96,10 @@ for ($PR = 0; $PR -lt $sortPRs.Length; $PR++) { continue } - if ([System.String]::IsNullOrEmpty($account)) + # Skip if commit author exists in skipContributors list. + if ([System.String]::IsNullOrEmpty($account) -and $skipContributors.Contains($name)) { - # Skip if commit author exists in skipContributors list. - if ($skipContributors.Contains($name)) - { - continue - } + continue } # Check whether the contributor belongs to the Azure organization.