From a107afdcdb9c352d9afa3282b5ce3293d0777c0a Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Sat, 17 Sep 2022 16:41:39 +0200 Subject: [PATCH 1/5] Add list of contributor names to output --- .../tools/Get-FormattedGitHubRelease.ps1 | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/utilities/tools/Get-FormattedGitHubRelease.ps1 b/utilities/tools/Get-FormattedGitHubRelease.ps1 index 38f00ebe7b..8ffe2d7c49 100644 --- a/utilities/tools/Get-FormattedGitHubRelease.ps1 +++ b/utilities/tools/Get-FormattedGitHubRelease.ps1 @@ -102,11 +102,15 @@ function Get-FormattedGitHubRelease { # Process content # # =================== # $categories = @() + $contributors = @() foreach ($line in $correctlyFormatted) { - $match = [regex]::Match($line, '\[(.+?)\].+') - $categories += $match.Captures.Groups[1].Value + $matchCategory = [regex]::Match($line, '\[(.+?)\].+') + $categories += $matchCategory.Captures.Groups[1].Value + $matchContributor = [regex]::Match($line, '\@(.*?)\s') + $contributors += $matchContributor.Value } $foundCategories = $categories | Select-Object -Unique + $foundContributors = $contributors | Select-Object -Unique $output = @() foreach ($category in $foundCategories) { @@ -122,6 +126,21 @@ function Get-FormattedGitHubRelease { } $output += '' } + $output += '### Contributors' + foreach ($contributor in $foundContributors) { + $contributorHandle = $contributor -replace '@', '' + #$output += "* $contributor" + $requestInputObject = @{ + Method = 'GET' + Uri = "https://api.github.com/users/$contributorHandle" + Headers = @{ + Authorization = "Bearer $PersonalAccessToken" + } + } + $response = Invoke-RestMethod @requestInputObject + $contributorName = $response.name + $output += $contributorName + } return $output } From 3f15fdd78f18349b8a9bbc5129e837e62351ff2a Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Sat, 17 Sep 2022 16:44:23 +0200 Subject: [PATCH 2/5] formatting --- utilities/tools/Get-FormattedGitHubRelease.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utilities/tools/Get-FormattedGitHubRelease.ps1 b/utilities/tools/Get-FormattedGitHubRelease.ps1 index 8ffe2d7c49..6326033680 100644 --- a/utilities/tools/Get-FormattedGitHubRelease.ps1 +++ b/utilities/tools/Get-FormattedGitHubRelease.ps1 @@ -125,11 +125,13 @@ function Get-FormattedGitHubRelease { $output += '* {0}' -f $simplifiedItem.Trim() } $output += '' + $output += '#############' + $output += '' } - $output += '### Contributors' + $output += '***Contributors***' foreach ($contributor in $foundContributors) { $contributorHandle = $contributor -replace '@', '' - #$output += "* $contributor" + # TODO: Return Warning if not found $requestInputObject = @{ Method = 'GET' Uri = "https://api.github.com/users/$contributorHandle" @@ -141,6 +143,7 @@ function Get-FormattedGitHubRelease { $contributorName = $response.name $output += $contributorName } + $output += '' return $output } From 2772bf0d1a6388753bfbe0545708469211e80b4e Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Sat, 17 Sep 2022 18:54:01 +0200 Subject: [PATCH 3/5] statistics --- .../tools/Get-FormattedGitHubRelease.ps1 | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/utilities/tools/Get-FormattedGitHubRelease.ps1 b/utilities/tools/Get-FormattedGitHubRelease.ps1 index 6326033680..4046d599b6 100644 --- a/utilities/tools/Get-FormattedGitHubRelease.ps1 +++ b/utilities/tools/Get-FormattedGitHubRelease.ps1 @@ -113,6 +113,10 @@ function Get-FormattedGitHubRelease { $foundContributors = $contributors | Select-Object -Unique $output = @() + + # =================== # + # PRs by category # + $output += '### Highlights' foreach ($category in $foundCategories) { $output += "***$category***" $categoryItems = $correctlyFormatted | Where-Object { $_ -imatch ".+\[$category\].+" } @@ -125,10 +129,11 @@ function Get-FormattedGitHubRelease { $output += '* {0}' -f $simplifiedItem.Trim() } $output += '' - $output += '#############' - $output += '' } - $output += '***Contributors***' + # ================ # + # Contributors # + $output += '' + $output += '### Contributors' foreach ($contributor in $foundContributors) { $contributorHandle = $contributor -replace '@', '' # TODO: Return Warning if not found @@ -141,9 +146,19 @@ function Get-FormattedGitHubRelease { } $response = Invoke-RestMethod @requestInputObject $contributorName = $response.name - $output += $contributorName + $output += '| ' + $contributorHandle + ' | ' + $contributorName + ' |' } + + $output += '' + + # ============== # + # Statistics # $output += '' + $output += '### Statistics' + $output += "* Count of Merged PRs: $($content.count)" + $output += "* Count of Contributors: $($foundContributors.count)" + $output += '* Count of New Contributors: TODO' + $output += '' return $output } From 6dee66fd93c935ef3604f53c5b1d4de280a6a13b Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Sun, 18 Sep 2022 19:10:51 +0200 Subject: [PATCH 4/5] new contributors --- .../tools/Get-FormattedGitHubRelease.ps1 | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/utilities/tools/Get-FormattedGitHubRelease.ps1 b/utilities/tools/Get-FormattedGitHubRelease.ps1 index 4046d599b6..13719c7c55 100644 --- a/utilities/tools/Get-FormattedGitHubRelease.ps1 +++ b/utilities/tools/Get-FormattedGitHubRelease.ps1 @@ -78,17 +78,21 @@ function Get-FormattedGitHubRelease { Write-Error "Request failed. Reponse: [$response]" } - $content = $response.Body -split '\n' | Where-Object { + $changedContent = $response.Body -split '\n' | Where-Object { $_ -like '`**' -and # For example: * [Modules] Update scope @carml in https://github.com/Azure/ResourceModules/pull/0 $_ -notlike '`* @*' -and # For example: @carml made their first contribution in https://github.com/Azure/ResourceModules/pull/0 $_ -notlike '`*`**' # For example: **Full Changelog**: https://github.com/Azure/ResourceModules/compare/v0.0.0...v1.0.0 } + $newContributorContent = $response.Body -split '\n' | Where-Object { + $_ -like '`* @*' # For example: @carml made their first contribution in https://github.com/Azure/ResourceModules/pull/0 + } + # =================== # # Analyze content # # =================== # - $correctlyFormatted = $content | Where-Object { $_ -match '$* \[.*' } - $incorrectlyFormatted = $content | Where-Object { $_ -notmatch '$* \[.*' } + $correctlyFormatted = $changedContent | Where-Object { $_ -match '$* \[.*' } + $incorrectlyFormatted = $changedContent | Where-Object { $_ -notmatch '$* \[.*' } if ($incorrectlyFormatted.Count -gt 0) { Write-Verbose '#############################' -Verbose @@ -106,17 +110,25 @@ function Get-FormattedGitHubRelease { foreach ($line in $correctlyFormatted) { $matchCategory = [regex]::Match($line, '\[(.+?)\].+') $categories += $matchCategory.Captures.Groups[1].Value - $matchContributor = [regex]::Match($line, '\@(.*?)\s') + $matchContributor = [regex]::Match($line, 'by \@(.*?)\s') $contributors += $matchContributor.Value } $foundCategories = $categories | Select-Object -Unique $foundContributors = $contributors | Select-Object -Unique + $newContributors = @() + foreach ($line in $newContributorContent) { + $matchNewContributor = [regex]::Match($line, '\@(.*?)\s') + $newContributors += $matchNewContributor.Value + } + $output = @() - # =================== # # PRs by category # + # =================== # + $output += '' $output += '### Highlights' + $output += '' foreach ($category in $foundCategories) { $output += "***$category***" $categoryItems = $correctlyFormatted | Where-Object { $_ -imatch ".+\[$category\].+" } @@ -130,13 +142,16 @@ function Get-FormattedGitHubRelease { } $output += '' } - # ================ # + # Contributors # + # ================ # $output += '' $output += '### Contributors' + $output += '' + $output += '| GH handle | GH name |' + $output += '| :-- | :-- |' foreach ($contributor in $foundContributors) { - $contributorHandle = $contributor -replace '@', '' - # TODO: Return Warning if not found + $contributorHandle = $contributor -replace 'by @', '' $requestInputObject = @{ Method = 'GET' Uri = "https://api.github.com/users/$contributorHandle" @@ -146,19 +161,21 @@ function Get-FormattedGitHubRelease { } $response = Invoke-RestMethod @requestInputObject $contributorName = $response.name - $output += '| ' + $contributorHandle + ' | ' + $contributorName + ' |' + $contributorNames += $contributorName + ', ' + $output += ('| {0} | {1} |' -f $contributorHandle, $contributorName) } $output += '' + $output += '* CC: ' + $contributorNames - # ============== # # Statistics # + # ================ # $output += '' $output += '### Statistics' - - $output += "* Count of Merged PRs: $($content.count)" + $output += '' + $output += "* Count of Merged PRs: $($changedContent.count)" $output += "* Count of Contributors: $($foundContributors.count)" - $output += '* Count of New Contributors: TODO' + $output += "* Count of New Contributors: $($newContributors.count)" $output += '' return $output } From 9e5d9b3592589f4c04dcbd7871e41fd7457bf2a9 Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Sun, 18 Sep 2022 19:18:15 +0200 Subject: [PATCH 5/5] s --- utilities/tools/Get-FormattedGitHubRelease.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities/tools/Get-FormattedGitHubRelease.ps1 b/utilities/tools/Get-FormattedGitHubRelease.ps1 index 13719c7c55..1f90b4844b 100644 --- a/utilities/tools/Get-FormattedGitHubRelease.ps1 +++ b/utilities/tools/Get-FormattedGitHubRelease.ps1 @@ -84,7 +84,7 @@ function Get-FormattedGitHubRelease { $_ -notlike '`*`**' # For example: **Full Changelog**: https://github.com/Azure/ResourceModules/compare/v0.0.0...v1.0.0 } - $newContributorContent = $response.Body -split '\n' | Where-Object { + $newContributorsContent = $response.Body -split '\n' | Where-Object { $_ -like '`* @*' # For example: @carml made their first contribution in https://github.com/Azure/ResourceModules/pull/0 } @@ -117,7 +117,7 @@ function Get-FormattedGitHubRelease { $foundContributors = $contributors | Select-Object -Unique $newContributors = @() - foreach ($line in $newContributorContent) { + foreach ($line in $newContributorsContent) { $matchNewContributor = [regex]::Match($line, '\@(.*?)\s') $newContributors += $matchNewContributor.Value }