-
Notifications
You must be signed in to change notification settings - Fork 140
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
Move implementation to standalone forgit #241
Move implementation to standalone forgit #241
Conversation
Wow! Very interesting. Will check this out early next week.
Definitely something I’ve considered in the past as well, and the fish and zsh/bash were inherently moving away from each other minorly Just due to little differences in implementation.
Will dig in more soon.
…On Sat, Oct 15, 2022 at 3:46 AM, Tim ***@***.***> wrote:
***@***.***(https://github.com/carlfriedrich) requested your review on: [#241](#241) Draft: Move implementation to standalone forgit.
—
Reply to this email directly, [view it on GitHub](#241 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY5MGBARF3YF542IH7DWDKDRNANCNFSM6AAAAAARF3OXA4).
You are receiving this because your review was requested.Message ID: ***@***.***>
|
@carlfriedrich I think it would be a great improvement. Will review and test it over the next two weeks. |
@@ -0,0 +1 @@ | |||
../../bin/git-forgit |
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.
I'm curious what the addition of this new file does. @carlfriedrich, can you explain?
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.
@wren The fish plugin manager fisher only installs files in these three folders:
completions
conf.d
functions
So symlinking bin/git-forgit
to conf.d/bin/git-forgit
was the only way I found to actually install the git-forgit
script for fish.
@cjappl Maybe you know more about the fish plugin architecure than me and might have a better idea? Having a bin
subdir in your conf.d
directory surely seems a bit unorthodox. I found that it works, though, and couldn't come up with a cleaner idea.
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.
Great question...
I unfortunately have no knowledge of fisher/fish plugins. You may be able to git blame
and hunt down the original person who implemented that and ask them. I didn't contribute to the plugin-ification of forgit
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.
I worked through the fisher documentation and this was the best idea I could come up with afterwards. Since it works, I will leave it that way for now as long as nobody complains about it. :-)
@cjappl Yep, I noticed that, too. In this patchset, however, I took the zsh implementation only and completely threw away the fish implementation. So if you notice any regressions in fish compared to the former version, let's discuss them right away to get the most consistent and feature-rich version of forgit for both shells as a result! |
@carlfriedrich is this usable in it's current state? AKA if I download and use this branch, it should behave like normal with no modifications to my workflow? If so, I'll make it my default branch for a bit, and if it works as intended I'm all for this change. No need to have such duplication as long as both shells will work as we like them today :) |
@cjappl Yes, it should work just like before indeed, except that you will have the zsh implementation from now on, so you might notice those slight differences you already talked about. If you don't install forgit via a plugin manager, just make sure that you have |
Awesome! Alright, giving it a shot, will report back after giving it some soak time |
First bug report, would you like me to capture these some way? I'm also happy to go back and dig in myself, but my cycles may be slow |
@cjappl Ah, didn't think about that there's no coreutils on Mac. For now, if you have homebrew you can install it:
I will come up with a portable solution for this as soon as I get to it, though. |
Damn mac… always a pain to figure out what’s on which system.
Thanks! Just ping me if you find a cross platform solution and I can keep banging on it :)
…On Fri, Oct 21, 2022 at 9:39 AM, Tim ***@***.***> wrote:
***@***.***(https://github.com/cjappl) Ah, didn't think about that there's no coreutils on Mac. For now, if you have homebrew you can install it:
brew install coreutils
I will come up with a portable solution for this as soon as I get to it, though.
—
Reply to this email directly, [view it on GitHub](#241 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY2RM2SGTJMKG3PANHDWELBMLANCNFSM6AAAAAARF3OXA4).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@cjappl I added a patch to this PR with a cross-platform solution for the path detection of |
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.
LGTM. I noticed a slight delay when executing forgit commands after this patch. But it's not a big problem.
58f2cf4
to
33f7143
Compare
@wfxr Thanks for your review. I added a patch which implements your suggestion. I also added another patch which makes the shell plugin return an error if the installation path cannot be determined, because I realized that it's not usable without it anymore. I'm sorry about the delay this patch adds to your workflow. I guess that's the price of calling an external script instead of a pure shell function implementation. I'm surprised that you notice the difference, though. In my case it's still super fast, and I wouldn't have noticed any difference. |
@carlfriedrich NVM. This delay is acceptable. Some documents will be out of date after this pr merged. For example the following description maybe should probably be removed: Lines 57 to 65 in 2872548
|
I’ll get back to testing this today!
…On Mon, Oct 24, 2022 at 5:40 AM, Wenxuan ***@***.***> wrote:
> I'm sorry about the delay this patch adds to your workflow. I guess that's the price of calling an external script instead of a pure shell function implementation. I'm surprised that you notice the difference, though. In my case it's still super fast, and I wouldn't have noticed any difference.
***@***.***(https://github.com/carlfriedrich) NVM. This delay is acceptable.
Some documents will be out of date after this pr merged. For example the following description maybe should probably be removed:
https://github.com/wfxr/forgit/blob/2872548075e63bc83a0b960e2813b16571998563/README.md?plain=1#L57-L65
—
Reply to this email directly, [view it on GitHub](#241 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY4EDREDTHESJPEH4PDWEZ7VDANCNFSM6AAAAAARF3OXA4).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@wfxr Thanks for the hint. I will definitely go through the documentation and update it where necessary as soon as @cjappl has approved this as well. |
@cjappl No worries, that's totally fine! I am happy to push this forward and your bug reports are very welcome. I am not at a computer at the moment, but from what I can see in the screenshot your preview command seems to run fish code, which shouldn't be the case. Do you have a custom preview command defined? |
@cjappl I actually can't reproduce this on my machine in fish. Preview looks fine here: I assume you either have a custom preview command configured, or there's another forgit version cluttering your shell environment. Have you tried starting a clean shell?
|
Sorry, haven’t forgotten about this! Work has been slammed. Will circle back soon :)
…On Mon, Oct 24, 2022 at 1:44 PM, Tim ***@***.***> wrote:
***@***.***(https://github.com/cjappl) I actually can't reproduce this on my machine in fish. Preview looks fine here:
[grafik](https://user-images.githubusercontent.com/45259958/197611284-d4866777-613e-4c96-9029-6882cd13c874.png)
I assume you either have a custom preview command configured, or there's another forgit version cluttering your shell environment. Have you tried starting a clean shell?
env -i HOME="$HOME" TERM="$TERM" fish
—
Reply to this email directly, [view it on GitHub](#241 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY55NPX5YDHOPEIUN5LWE3RKVANCNFSM6AAAAAARF3OXA4).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@cjappl Thanks for your response. I could reproduce this with setting my ' $SHELL' variable to something other than bash. fzf indeed evaluates this variable to run the preview commands. Since all preview commands are implemented in bash now, we have to ensure that fzf uses bash to run these. I added a new commit which sets the I am not sure if this might have side effects. It only changes the default shell for the forgit process, though, so I can't think of anything wrong with this, because I think it is only relevant for the previews. Do I overlook anything? Anyway, in my case it works now with fish as the default shell. Can you check again? |
Sweet! This one is mostly working for me. I'm going to stick on this branch in general for the near future as I test it out. One thing I am noticing that I'm happy to submit a commit for (just want to make sure other folks are seeing it). I am seeing that
I was always getting through this conditional, trying to
However, changing all of these
to
fixed it. Is that true for anyone else?? You can replicate by putting an echo in the top of the function, and then calling
Another small, unimportant note I'm realizing on first blush is that fish users MUST export environment variables, such that bash can use them, I originally had this in my fish config
but needed to export
Fixed it right up :) |
Overall, this version is the first version really working for me, can't wait to stress test it more and hopefully give thumbs up soon!! Great work @carlfriedrich , really appreciate you putting this together. 🎉 |
@cjappl Thanks for your good testing and feedback.
I was able to reproduce this. It happened in fish only, though, so I could track it down to the fish plugin code and already pushed a fix for it to this branch. It occured because I did not know that passing
Yes, that's indeed true for all shells, I forgot to mention this in the PR description. I will update the documentation accordingly. |
Previously we had two different forgit implementations: one for zsh/bash and one for fish. In this commit we move the bash implementation of the forgit functions to the git-forgit script in order to have them in the form of an executable script. This makes using forgit possible without any shell plugin at all and furthermore removes the need to maintain a separate implementation for the fish shell. The simplest way of using forgit from now on is to put git-forgit somewhere in your PATH and call it via "git forgit", without the need for any other files. We keep the shell plugins, though, and maintain backwards compatibility by retaining the plugin functions as simple wrappers around the git-forgit script, making the plugins mainly a collection of aliases only.
70bff4c
to
00dcf2a
Compare
@wfxr Great idea, thanks for the suggestion! I updated the commit, so that a warning is displayed now if anything has to be exported.
@cjappl Thanks for the hint! I squashed this fix into the latest commit.
I will update the documentation as well, but I think a warning is indeed a useful additional way of telling the people that we're about to change something. Can you both check if the warnings are displayed correctly? |
@carlfriedrich LGTM. |
After sleeping on this last night:
I think we should merge this if everyone is OK with it! I’ve found the basic functionality works as intended in fish, and we can just file tickets / fixes as things come up.
I don’t think we should halt this one going in for much longer - seeing as it’s a big architectural change I think we should just take the plunge and we can sort out the issues as they happen?
Thoughts?
…On Tue, Nov 15, 2022 at 9:06 AM, Wenxuan ***@***.***> wrote:
> Can you both check if the warnings are displayed correctly?
***@***.***(https://github.com/carlfriedrich) LGTM.
—
Reply to this email directly, [view it on GitHub](#241 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY4BBF4FECWBMG4KPUTWING7XANCNFSM6AAAAAARF3OXA4).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@cjappl Thanks for your feedback! For me that sounds good, and I actually had similar thoughts during the last days. :-) Before merging this I will update the documentation to match the new architecture. It would be great if you both could review those as well, but I will give you a ping as soon as I pushed those changes. |
Thanks will do.
…On Wed, Nov 16, 2022 at 8:40 AM, Tim ***@***.***> wrote:
***@***.***(https://github.com/cjappl) Thanks for your feedback! For me that sounds good, and I actually had similar thoughts during the last days. :-)
Before merging this I will update the documentation to match the new architecture. It would be great if you both could review those as well, but I will give you a ping as soon as I pushed those changes.
—
Reply to this email directly, [view it on GitHub](#241 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY3TF3JPISFCCVDVHM3WISMXDANCNFSM6AAAAAARF3OXA4).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
All preview commands are written in bash now. fzf, however, uses the shell defined in $SHELL to run the preview commands. We have to force this to bash within forgit in order to not get any errors on different default shells.
Fish stores command line arguments in $argv, which is an array. Unlike in bash, when passing this array to a function, we must not enclose it in double-quotes. This made an empty argument list (i.e. no arguments passed) to an actual empty string argument (i.e. one argument passed), which is not what we want. See https://stackoverflow.com/a/42379014/3018229
Before forgit became a standalone script, users defined their FORGIT variables (e.g. FORGIT_FZF_DEFAULT_OPTS) in the shell environment before sourcing the forgit shell plugin. This worked because the forgit code was executed within the currently running shell. With forgit being an executable script, these variables are only available to forgit when being exported. This patch adds an automatism for this so that users do not have to change their configuration. A warning is issued in this case so that users get notified to update their configuration.
00dcf2a
to
da9210e
Compare
So I updated the documentation and finalized the branch for merging. As I already announced in the PR description, I removed the patches for using @wfxr @cjappl Can you verify the documentation changes, check if I overlooked anything, and do one last functional verification in your environment? Thanks a lot! |
Everything is operational on a basic pass on my end! After merging, I will file any tickets, or fix issues as I seem them! great work 👍 |
70b7832
to
785c3f9
Compare
I think lets get this submitted ASAP - more PRs are coming in (and there are a few things I want to do) but we should wait until this is merged so we don't have to duplicate the effort back to this implementation |
This is something I wanted to do for quite a while, and during the last days I finally had some time to check out how to do it right (at least that's what I hope 😁).
I labeled this a draft, because this is kind of a new direction for forgit and I would like to discuss if we can all agree on this first, or if you have any other ideas how to improve this suggestion. If we actually can agree on it, I will adapt the documentation before merging this.
What this patchset basically does is move the actual forgit functionality from the shell plugin (
forgit.plugin.zsh
/forgit.plugin.fish
) to the standalone forgit executable script (git-forgit
). This has the following advantages:The simplest way of using forgit after this change is to put
git-forgit
somewhere in your PATH and call it viagit forgit
, without the need for any other files.We keep the shell plugins, though, and maintain backwards compatibility by retaining the plugin functions as simple wrappers around the
git-forgit
script, making the plugins mainly a collection of aliases only (which is what actually most other shell plugins are, too).Here's some more detailed information on the patches contained in the patchset:
The first patch looks quite large, as it contains lots of changed lines. The only thing it does, though, is move the forgit functions over to
git-forgit
, give them a new (more shell script convention compliant) naming style and re-implement the original plugin functions (of both zsh and fish version) as simple wrappers aroundgit-forgit
. It also moves the detection ofFORGIT_INSTALL_DIR
from the bottom to the top offorgit.plugin.zsh
.The second patch refactors the detection of
FORGIT_INSTALL_DIR
to match the standardized $0 handling for zsh plugins, which I noticed wasn't the case before.The third patch just changes the order of the functions in the fish version of the plugin to match the order of the zsh version and also adds
forgit::checkout::tag
andforgit::blame
to it, which I noticed were missing until now.The fourth patch is the new implementation of glo:: use forgit::diff when entering a commit #219 and it's just here temporarily for testing. When checking out this branch you should see
forgit::diff
opening when entering a commit inforgit::log
. I will remove the patch from this branch before merging this PR and move it to glo:: use forgit::diff when entering a commit #219 instead.I tested this branch in zsh using zplug. Since I think we comply with the zsh plugin standard, I assume it should also work with other plugin managers as well.
In fish I tested it using fisher (requiring fisher version 4.4.3 because I had to add correct handling for symbolic links in order to make it work there). It should also work with oh-my-fish, but since that does not support installing plugins from a specific branch, I could not actually test it there. Installing it and then manually changing the branch did work, though.
So @wfxr, @cjappl and @wren (also adding you here since you added
git-forgit
in the first place), I am very eager to hear your opinions on this. And of course I would like to hear if the change works in your environment. I tried to not make this a breaking change, but we all know there's always something you don't consider, so I'm quite curious to hear from you. 😄Check list
Description
Type of change
Test environment