GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — correctly handle `uname-cmd` that doesn't point to an executable file by gcmarx · Pull Request #2026 · gitpython-developers/GitPython

Conversation

@gcmarx

@gcmarx gcmarx commented May 22, 2025

Copy link
Copy Markdown
Contributor

I also ran into the issue from #1979. My proposed solution is that GitPython should only try to run uname_cmd if it points to an executable file. I also wrote a short test class for the is_cygwin_git function. I don't have a machine with Cygwin, so I can't test that it actually does work, but I trust the Python docs when they say that on Cygwin, sys.platform will be cygwin.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gcmarx added 10 commits May 21, 2025 15:48
@gcmarx
add tests for is_cygwin_git
ec00872
@gcmarx
check for the existence/execute bit on the uname command before tryin…
de5e57c
…g to run it
@gcmarx
adding self to authors
428be1a
@gcmarx
Revert "check for the existence/execute bit on the uname command befo…
58ff723
…re trying to run it"

This reverts commit de5e57c.
@gcmarx
use pathlib.Path instead of os.path.isfile
7187984
@gcmarx
don't keep checking if sys.platform isn't 'cygwin'
3f5a942
@gcmarx
check that uname_cmd points to a file; if uname_cmd were a directory,…
226f4ff
… it could both exist and have os.X_OK but not work
@gcmarx
don't use match-case, since it's a 3.10 feature
22d6284
@gcmarx
it's is_file(), not isfile()
b1289ee
@gcmarx
turns out f-strings before 3.8 don't support {variable=} notation, ta…
cffa264
…ke that out
@gcmarx

gcmarx commented May 22, 2025

Copy link
Copy Markdown
Contributor Author

honestly, after having written this code, I'm not sure why we're not just delegating is_cygwin_git to sys.platform == "cygwin".

eighthave reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gcmarx gcmarx mentioned this pull request May 22, 2025
use sys.platform == "cygwin" to figure out when we are using cygwin #2027
Closed
@gcmarx

gcmarx commented May 22, 2025

Copy link
Copy Markdown
Contributor Author

see #2027 for a different implementation of the same basic logic

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron requested review from EliahKagan and Copilot May 23, 2025 06:51
Copilot AI reviewed May 23, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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 fixes the handling of cases where the uname command (used to detect Cygwin Git) is not an executable file and adds unit tests for verifying the behavior of is_cygwin_git. It also includes an update to the AUTHORS file to add a new contributor.

  • Updated test_util.py to add tests for is_cygwin_git.
  • Revised git/util.py to check if uname_cmd is an executable file before invoking it.
  • Updated AUTHORS list.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/test_util.py Added unit tests for is_cygwin_git functionality
git/util.py Updated uname command executable check and caching logic
AUTHORS Added new contributor

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Byron

Byron commented May 23, 2025

Copy link
Copy Markdown
Member

Thanks for contributing a fix!

Indeed, I don't know why we are in the current place, but @EliahKagan probably has more information and I hope he can chime in.

Besides that, my apologies, I did click the "copilot" review button out of curiosity, please feel free to completely ignore it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gcmarx added 3 commits May 27, 2025 07:55
@gcmarx
add self to AUTHORS, add Emacs tempfiles to .gitignore
36a893b
@gcmarx
use strings instead of uname to detect cygwin
c441316
@gcmarx
debug printing
0df0818
@gcmarx

gcmarx commented May 27, 2025

Copy link
Copy Markdown
Contributor Author

...incidentally, is there a way for me to run the test pipeline locally without pushing my changes up first?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gcmarx gcmarx mentioned this pull request May 27, 2025
safe mode to disable executing any external programs except git #2029
Closed
EliahKagan
EliahKagan requested changes May 28, 2025
View reviewed changes

@EliahKagan EliahKagan left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

As argued in #2027 (comment), I think we should actually merge cffa264 -- that is, this PR as it was before the change to using strings -- before proceeding with further changes. I think that could be done at any time. I suggest rewinding this PR to that point (you can preserve the extra commits on their own separate branch of course).

There are some minor refinements that could be included with that, but they can just as easily be done afterwards (for example, I can make a small PR later that includes them), so they're not blocking. I've included review comments below showing them as suggested-change diffs.

In addition to the reasons given in #2027 (comment) for starting that way, I also think it matches the scope you may have intended for this PR originally, based on the PR title.

This is not to say that the attempt to examine the contents of the git executable file to discern if it is a Cygwin build should be discarded entirely -- only that I recommend integrating the working changes from before that, and then continuing with that subsequently. To that end, I've also included some review comments pertaining to those subsequent commits. To avoid confusion, I have refrained from including any suggested-change diffs in those.


...incidentally, is there a way for me to run the test pipeline locally without pushing my changes up first?

Yes, certainly. There are instructions in the readme, there is tox.ini if you want to use the tox runner, and the commands in the CI workflows in .github/workflows can sometimes be useful. I'm also happy to help with any questions about setting that up or problems that arise with it (and please feel free to ping me about it). There is also software to attempt to run GitHub Actions workflows locally, such as act, though I have not tried that on this repository and I don't know how well it would work.

However, in order to run the Cygwin tests on your local machine--using any of those techniques or others--I think you would need to have a Windows system (or other system capable of running Windows programs) with Cygwin installed on it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test_util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@gcmarx
gcmarx marked this pull request as draft May 28, 2025 15:13
gcmarx added 3 commits May 28, 2025 11:15
@gcmarx
Revert "debug printing"
58f7710
This reverts commit 0df0818.
@gcmarx
Revert "use strings instead of uname to detect cygwin"
1731c1e
This reverts commit c441316.
@gcmarx
incorporate review feedback from @EliahKagan
f3ab5d3
EliahKagan
EliahKagan approved these changes May 28, 2025
View reviewed changes
@gcmarx
gcmarx marked this pull request as ready for review May 28, 2025 17:06
@EliahKagan

EliahKagan commented May 28, 2025

Copy link
Copy Markdown
Member

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@EliahKagan
EliahKagan merged commit 8576534 into gitpython-developers:main May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Byron Byron Byron left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@EliahKagan EliahKagan EliahKagan approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@gcmarx @Byron @EliahKagan
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.