Skip to content
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

Make .bat and .cmd editors work on windows #1656

Closed
wants to merge 12 commits into from
Closed

Conversation

pm100
Copy link
Contributor

@pm100 pm100 commented Apr 17, 2023

This Pull Request fixes/closes #1316.

This has several parts

  • first it adds code to enable .bat and .cmd commands to be invoked without the .bat or .cmd being given (core.editor='vim' will now run vim.bat)
  • it then adds unit tests
  • it also reorganized some code used for testing in asyncgit so that it can be used in the main, gitui, product

The actual fix is fairly straightforward.

  • if on windows and the configured editor fails to launch then retry
  • retry using cmd /C <editor> <file>
  • if that fails to start or cmd reports an error then report that to the user

The reorg needs an explanation

  • open_file_in_editor need a repo.
  • there is test plumbing in asyncgit that provides many repo utilities
  • sadly things declared 'test' are not available in other products / subcrates. But there is a solution. see make code compiled with cfg(test) visible across crates rust-lang/cargo#8379. It involves creating a test-utils feature and making that a dev dependency.
  • That now makes that test plumbing in asyncgit/sync/mod.rs no longer hidden under a test umbrella. The exhaustive cliuppy, lints, cargo-sort etc now picks up all sorts of issues there (that really dont matter) so now I had to add in a few things to stop those being picked up. Note that they are still only being compiled when doing tests, its just that clippy 'all-features' doesnt realize that

I also note that there are no other external editor test cases. I will add more once I get this in (I willl look at #1654 and put them in the fix for that). I did add one generic test, but there should be more

I followed the checklist:

  • [ x] I added unittests
  • [x ] I ran make check without errors
  • [x ] I tested the overall application
  • I added an appropriate item to the changelog

@@ -23,6 +23,7 @@
// #![deny(clippy::expect_used)]
//TODO: consider cleaning some up and allow specific places
#![allow(clippy::significant_drop_tightening)]
#![allow(clippy::multiple_crate_versions)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a red-flag. why do we want that? it bloats the binary. did you investigate what introduces the multiple versions of the same crate?

@@ -22,5 +22,6 @@ version = "1.0.3"
multiple-versions = "deny"
skip-tree = [
{ name = "windows-sys" },
{ name = "hermit-abi" }
{ name = "hermit-abi" },
{ name = "syn" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

see above

@pm100
Copy link
Contributor Author

pm100 commented Apr 22, 2023

Multiple versions do not get built into the product, they only happen on test builds

cargo clippy --workspace --all-features complains about the code that is in the test feature 'test_utils'. It does not realize that this is only for testing

Same for cargo deny

I tried real hard to untangle the multiple versions even though it only really happens with tests. I could not untangle some of them (people who version their crate 0.xx are very annoying because 0.45 is not seen as a valid replacement for 0.44 by cargo. Yes windows-sys we are looking at you)

Then I saw that you already had the ignore dups in main.rs and in deny.toml and decided OK its not just me that could not un ravel these

TL;DR - the dups only happen when running tests

@pm100
Copy link
Contributor Author

pm100 commented Apr 22, 2023

I had to do a quick commit with that allow taken out because I could not remember what actually failed, I knew it was part of the CI build

@pm100
Copy link
Contributor Author

pm100 commented Apr 24, 2023

I just discovered squash. I apologize for my messy prs. I will clean this up

@pm100 pm100 closed this Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vim is not available as external editor on windows
2 participants