Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

PR Summary

Eliminates code duplication in New-MacOsDistributionPackage by replacing manual temp directory creation with the existing New-TempFolder helper function.

PR Context

The New-MacOsDistributionPackage function manually created temp directories instead of using New-TempFolder, which is used throughout the rest of the codebase (e.g., in New-MacOSPackage).

Before:

$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tempDir -Force > $null

After:

$tempDir = New-TempFolder

Net: -1 line. The New-TempFolder helper includes a Test-Path check before creation, making it marginally safer than the original -Force approach.

Addresses #26441 (comment)

PR Checklist

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PowerShell/PowerShell/pulls/26441/comments
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix code duplication in packaging</issue_title>
<issue_description>### Prerequisites

Steps to reproduce

Address this comment #26441 (comment)

Expected behavior

Address this comment https://github.com/PowerShell/PowerShell/pull/26441#discussion_r2524372043

Actual behavior

Address this comment https://github.com/PowerShell/PowerShell/pull/26441#discussion_r2524372043

Error details

Environment data

Address this comment https://github.com/PowerShell/PowerShell/pull/26441#discussion_r2524372043

Visuals

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


πŸ’‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix code duplication in packaging Replace manual temp directory creation with New-TempFolder helper Nov 13, 2025
Copilot AI requested a review from TravisEz13 November 13, 2025 18:01
@TravisEz13 TravisEz13 requested a review from Copilot November 13, 2025 21:48
@TravisEz13 TravisEz13 added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Nov 13, 2025
@TravisEz13 TravisEz13 marked this pull request as ready for review November 13, 2025 21:49
@TravisEz13 TravisEz13 requested review from a team and jshigetomi as code owners November 13, 2025 21:49
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

This PR eliminates code duplication by replacing manual temporary directory creation with the existing New-TempFolder helper function in the New-MacOsDistributionPackage function.

  • Replaces two lines of manual temp directory creation with a single call to New-TempFolder
  • Makes the code more consistent with other functions in the same module (e.g., New-MacOSPackage)
  • Improves safety by using the helper's Test-Path check instead of -Force

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Nov 21, 2025
@kilasuit
Copy link
Collaborator

@TravisEz13 this pr isn't the right way for this direction of travel overall & I'm not quite happy with copliot having used cpu time on this for such little a gain in the grand scheme of things & as such I'd like it if we closed this.

Instead we should have a new cmdlet New-TemporaryDirectory much like New-TemporaryFile in the Microsoft.PowerShell.Utility module that can be called from in the same way in tooling like this & also aid in further reducing code duplication in this repo and for others down the line. It could have New-TempFolder as an alias and possibly there's other similar useful aliases that could be added too & would be a better way forward overall & has been approved by the Cmdlets WG in #25754

Hope that makes sense

@Unrepentant-Atheist
Copy link

Copilot is stupid.

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

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix code duplication in packaging

4 participants