Skip to content

Conversation

@isra-fel
Copy link
Member

@isra-fel isra-fel commented Oct 20, 2025

  • Introduced Merge-DevPullRequest cmdlet to facilitate merging pull requests in the azure-powershell repository.
  • Updated README.md to include usage instructions for the new cmdlet.
  • Added entry to CHANGELOG.md for the new feature.
  • Modified AzDev.psd1 to export the new cmdlet and its alias.

Description

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

- Introduced `Merge-DevPullRequest` cmdlet to facilitate merging pull requests in the azure-powershell repository.
- Updated README.md to include usage instructions for the new cmdlet.
- Added entry to CHANGELOG.md for the new feature.
- Modified AzDev.psd1 to export the new cmdlet and its alias.
@azure-client-tools-bot-prd
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

@isra-fel isra-fel marked this pull request as ready for review October 20, 2025 05:21
@Copilot Copilot AI review requested due to automatic review settings October 20, 2025 05:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new Merge-DevPullRequest cmdlet (alias Merge-DevPR) to assist with approving and merging pull requests in the azure-powershell repository. Updates documentation (README, CHANGELOG) and exports the new function and alias in AzDev.psd1.

  • Introduces GitHub.psm1 with Merge-DevPullRequest implementation.
  • Updates module manifest to load and export the new function and alias.
  • Adds README usage and CHANGELOG entry for the new feature.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
tools/AzDev/README.md Documents new GitHub helper section and usage examples for Merge-DevPullRequest.
tools/AzDev/CHANGELOG.md Adds dated entry describing new cmdlet feature.
tools/AzDev/AzDev/GitHub.psm1 Implements Merge-DevPullRequest cmdlet logic and exports it.
tools/AzDev/AzDev/AzDev.psd1 Registers new nested module, function export, and alias.

Comment on lines +180 to +188
if ($failedPRs.Count -gt 0) {
$errorMessage = "Failed to merge $($failedPRs.Count) pull request(s): $($failedPRs.number -join ', ')"
Write-Error $errorMessage
throw $errorMessage
}

# Return merged PRs in the format shown in README
return $mergedPRs | ForEach-Object {
[PSCustomObject]@{
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function throws (line 183) before reaching the return block (line 186) when any PR fails, contradicting the documented behavior that successfully merged PRs are still returned. Move the return construction before the throw or replace the throw with a non-terminating Write-Error so merged PRs are output. Example fix: build the result object, Write-Error if failures exist, then return the result without throwing.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is valid as there is no wrapping catch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated: merged PRs are returned before the errors are thrown

'No.' = $_.number
'Title' = $_.title
'CreatedBy' = $_.author.login
'CreatedAt' = [DateTime]::Parse($_.createdAt).ToString('M/d/yyyy h:mm:ss tt')
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a culture-dependent format ('M/d/yyyy h:mm:ss tt') produces ambiguous dates and hampers machine parsing. Prefer an invariant/ISO 8601 format such as ToString('yyyy-MM-ddTHH:mm:ssZ') (after ensuring UTC) or return the DateTime object directly for consumers to format.

Suggested change
'CreatedAt' = [DateTime]::Parse($_.createdAt).ToString('M/d/yyyy h:mm:ss tt')
'CreatedAt' = ([DateTime]::Parse($_.createdAt).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ'))

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isra-fel I believe this could be a valid point.

'No.' = $_.number
'Title' = $_.title
'CreatedBy' = $_.author.login
'CreatedAt' = [DateTime]::Parse($_.createdAt).ToString('M/d/yyyy h:mm:ss tt')
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a culture-dependent format ('M/d/yyyy h:mm:ss tt') produces ambiguous dates and hampers machine parsing. Prefer an invariant/ISO 8601 format such as ToString('yyyy-MM-ddTHH:mm:ssZ') (after ensuring UTC) or return the DateTime object directly for consumers to format.

Suggested change
'CreatedAt' = [DateTime]::Parse($_.createdAt).ToString('M/d/yyyy h:mm:ss tt')
'CreatedAt' = ([DateTime]::Parse($_.createdAt).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ'))

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'CreatedAt' = [DateTime]::Parse($_.createdAt).ToString('M/d/yyyy h:mm:ss tt')
'CreatedAt' = [DateTime]::Parse($_.createdAt).ToString('M/d/yyyy h:mm:ss tt')


With the `-AllArchivePR` switch, the cmdlet lists all the matching PRs, ordered by CreatedAt ascending, and prompts you to confirm before merging. Use the `-Force` switch to skip the confirmation. For safety, this parameter set only supports merging PRs with the "[skip ci]" prefix in the title and created by the `azure-powershell-bot` user, which are the archive PRs for generated modules.

The cmdlet returns the list of merged PRs. In case any PR fails to merge, an error is thrown, and the successfully merged PRs are still returned.
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation states merged PRs are still returned when an error occurs, but current implementation throws before returning (see lines 180-188 in GitHub.psm1). Update the code to return results on partial failure or adjust this sentence to reflect the actual behavior.

Suggested change
The cmdlet returns the list of merged PRs. In case any PR fails to merge, an error is thrown, and the successfully merged PRs are still returned.
The cmdlet returns the list of merged PRs. If any PR fails to merge, an error is thrown and no results are returned.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@DanielMicrosoft DanielMicrosoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is some valid points from Copilot we can address before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants