gh-clean-branches icon indicating copy to clipboard operation
gh-clean-branches copied to clipboard

fix: refactor to bash compatibility

Open ndom91 opened this issue 3 years ago • 5 comments

Why did you make this change

Make it bash compatible and further the reach of your great extension!

Feel free to close if you're a big zsh fan and explicitly want to keep it this way.. Otherwise I think it'd be wise to make this more widely compatible! :tada:

What have you done in this PR

  • Refactored a few high-level incompatible statements, like the array manipulation
  • Formatted with shfmt and also fixed all shellcheck linting errors (other than 2207 which is disabled file-wide)

What was left to do

Dependencies

- zsh

Checklist:

  • [x] My code follows the style of this project
  • [x] I have performed a self-review of my own code
  • [x] I have have tested my code locally to prove my fix is effective or that my feature works
  • [x] I have made corresponding changes to the README.md

ndom91 avatar May 05 '22 20:05 ndom91

Awesome work, @ndom91! :clap::clap: For the record, this was first raised in #2, and initial POSIX-ifying work was done in #3.

waldyrious avatar May 06 '22 09:05 waldyrious

Awesome work, @ndom91! :clap::clap: For the record, this was first raised in #2, and initial POSIX-ifying work was done in #3.

Ah I hadn't even seen those haha. Thanks for the initial work then!!

ndom91 avatar May 06 '22 10:05 ndom91

Thanks for the great contribution, @ndom91! I believe that relying on bash will allow more developers to enjoy this extension.

This is a significant change. It will take some time to review and test it.

I have one concern, though. This change may break the extension for a developer who only has zsh installed. Though, I assume that it is a rare case.

davidraviv avatar May 08 '22 05:05 davidraviv

Thanks for the great contribution, @ndom91! I believe that relying on bash will allow more developers to enjoy this extension.

This is a significant change. It will take some time to review and test it.

I have one concern, though. This change may break the extension for a developer who only has zsh installed. Though, I assume that it is a rare case.

Yeah I can double check and run it with Zsh as well. I have a macbook somewhere.. haha.

EDIT: Can confirm the array splitting doesn't work in zsh now.

image

See:

https://github.com/davidraviv/gh-clean-branches/blob/4b8efdc7cbc62c1f24c1813241c8f97e3a0bc710/gh-clean-branches#L43-L46

https://github.com/davidraviv/gh-clean-branches/blob/4b8efdc7cbc62c1f24c1813241c8f97e3a0bc710/gh-clean-branches#L82

Will work on this shortly

EDIT 2: Note - https://unix.stackexchange.com/a/491459

ndom91 avatar May 15 '22 09:05 ndom91

@ndom91 Sorry for the delay in testing this.

Please take a look at a test I made that compares the results of the current code (1st run) to the PR code (2nd run).

The branch add-git-ignore exists both on the remote and local. Hence the branch is not expected to be deleted.

✅ The current code doesn't list the branch for deletion - as expected. ❌ The PR code lists the branch for deletion - not as expected.

You are welcome to take a look and push a fix. I promise to test it quickly 😉

Screen Shot 2022-05-23 at 17 46 39

davidraviv avatar May 23 '22 15:05 davidraviv