gh-f icon indicating copy to clipboard operation
gh-f copied to clipboard

[feature] Add support for checking out from logs

Open paul-sachs opened this issue 2 years ago • 2 comments

First i'd like to say I love this thing ❤️ . It makes working with git branches so much easier.

One of the things I immediately tried was gh f -l and checkout a given entry (often to check for a bug or reset to a sane state). This would be a super useful to be able to add a command to checkout from a log entry (with ctrl+k or something... not sure yet)

That said, my bash-fu is pretty terrible. I'll try to mangle together a PR to add that but figured I'd raise this first to see if it makes sense.

paul-sachs avatar Sep 15 '22 16:09 paul-sachs

Good afternoon and thank you for your kind words!

If I understand correctly, you would like a key binding (say ctrl-k in your example) to checkout the commit of the selected log entry instead of just showing the commit patch (current behaviour). If so, this was already on my roadmap and it is pretty easy to implement: only at the moment I am on holidays and will have access to a computer next week only.

If you want to have a try yourself you can essentially mimic the code here of the function gh f tags: essentially you have to tell fzf to expect a key-binding and once so, determine the action on the selected line. There is probably some sed/awk/cut to do to make sure you are acting on the commit id rather than the whole line, but if you follow the examples in the other parts of the code it should be easy enough.

This said, in 1-2 weeks I will get to this myself, so if you can survive till then you can just wait and it will be done :)

gennaro-tedesco avatar Sep 15 '22 18:09 gennaro-tedesco

@gennaro-tedesco You are understanding correctly. I'll try to get a little time and put a PR together.

paul-sachs avatar Sep 15 '22 19:09 paul-sachs