-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Refactor Cmder.ps1: Apply PowerShell naming conventions and optimize code #3042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: DRSDavidSoft <[email protected]>
Co-authored-by: DRSDavidSoft <[email protected]>
…g regex Co-authored-by: DRSDavidSoft <[email protected]>
Co-authored-by: DRSDavidSoft <[email protected]>
Co-authored-by: DRSDavidSoft <[email protected]>
Co-authored-by: DRSDavidSoft <[email protected]>
|
@DRSDavidSoft We Just Vibe coding with @copilot at this point. You been on
fire you're blowing up my email box
…On November 8, 2025 4:12:40 PM Copilot ***@***.***> wrote:
@Copilot commented on this pull request.
In vendor/psmodules/Cmder.ps1:
> + [string]$UserVersion,
+ [Parameter(Mandatory = $false)]
+ [AllowNull()]
+ [string]$VendorVersion
+ )
+
+ if ($null -eq $UserVersion) { return -1 }
+ if ($null -eq $VendorVersion) { return 1 }
+
+ try {
+ $userVer = [version]$UserVersion
+ $vendorVer = [version]$VendorVersion
+ return $userVer.CompareTo($vendorVer)
+ } catch {
+ # Fallback to string comparison if version parsing fails
+ return [string]::Compare($UserVersion, $VendorVersion)
You're absolutely right! Improved in commit 456ddcc.
New dot-notation implementation:
Splits by dots: "2.49.0.windows.1" → ["2", "49", "0", "windows", "1"]
Compares each segment individually:
Numeric segments: Compared as integers (49 > 5) ✓
Text segments: Compared case-insensitively (lexicographic)
Mixed: Numeric sorts before text (so "2.0" < "2.0.rc.1")
Benefits over regex extraction:
Won't accidentally match unrelated numbers in the version string
Properly handles SemVer (major.minor.patch)
Correctly handles qualifiers and suffixes
More maintainable and predictable
All 11 tests pass including:
✓ 2.5.10.windows.2 < 2.49.0.windows.1
✓ 2.40.0.windows.1 < 2.40.0.windows.2
✓ 1.2.3 < 1.2.10 (SemVer)
✓ 2.0 < 2.0.rc.1 (qualifiers)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
|
Co-authored-by: DRSDavidSoft <[email protected]>
|
@daxgames I'm sorry for that 😅 Although it's not just vibe coding, I fixed some important bugs and merged some PRs. This Copilot thing is really addicting, sure it makes some mistakes here and there, but with proper reviewing, it's making some awesome progress! I opened this PR for refactoring changes to make the code more streamlined (performance optimizations & readability for better maintenance). I'm super sorry for not considering how many notifications it would generate in your mailbox 😬 Please feel free to unsubscribe from the PR, and I will definitely reduce generating any additional noises, Dax While you are here, can I please ask about some of the existing commits, e.g. the Posh Git version requirement, and some other mentions in the recent issues/PRs? (No hurries of course if you're busy, but I would definitely appreciate your involvement) The overall goal is to prepare for a new release so that I could get into more important priorities, merging parts of the Once again, sorry for all the noise, and thank you Dax! |
|
@DRSDavidSoft not complaining at all it just goes for months and there's no messages and then boom! |
✅ Cmder.ps1 Refactoring Complete
Successfully refactored and optimized Cmder.ps1 with PowerShell naming conventions
Summary of Changes
Function Naming (PowerShell Approved Verbs):
readGitVersion→Get-GitVersionisGitShim→Get-GitShimPathcompareVersions→Compare-Versioncompare_git_versions→Compare-GitVersionConfigure-Git→Set-GitPath(Configure is not an approved verb)checkGit→Show-GitStatusgetGitStatusSetting→Get-GitStatusSettingImport-Git→ Kept as-is (already correct)Code Optimizations:
Version Comparison Implementation:
Architecture-Aware Optimizations:
[Environment]::Is64BitOperatingSystemcheck for mingw directory selectionPosh-Git Compatibility:
Dependencies Updated:
Testing & Verification:
Benefits:
Files Modified:
vendor/psmodules/Cmder.ps1(160 insertions, 127 deletions)vendor/profile.ps1(8 insertions, 8 deletions)Security: No vulnerabilities introduced or detected.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.