wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.33k stars 136 forks source link

Interactively select branch in gcp #228

Closed carlfriedrich closed 1 year ago

carlfriedrich commented 1 year ago

Check list

Description

When we want to perform a cherry pick, we had to pass the target branch as an argument to gcp. Forgit, however, aims to make git selections interactive where possible. Hence it seems natural to select the target branch interactively as well.

This change implements a new function forgit::cherry::pick::from::branch which opens an interactive branch selector and then calls the existing forgit::cherry::pick on the selected branch. Since this seems a far more intuitive way of performing a cherry pick I re-assigned the gcp alias to the new function.

The original forgit::cherry::pick had to be modified slightly in order to get a useful return code from it. Functionality stayed the same, though.

Along with this change I added a new global variable forgit_log_preview_options to reduce code duplication.

@wfxr @cjappl If this works for you and you approve this change I might re-implement #219 in the same manner. That would make me happy. 😄

Type of change

Test environment

carlfriedrich commented 1 year ago

I just realized that cherry picking multiple commits probably won't work anymore with my change. Will check and fix that later.

carlfriedrich commented 1 year ago

@wfxr @cjappl Hmmm, I fixed my issue with multiple commits, but shellcheck is not happy. It wants me to wrap my commits variable in double quotes to prevent word splitting. Word splitting is what I need here, though. What can we do now?

carlfriedrich commented 1 year ago

I tried using an array as well, gives another error: https://github.com/wfxr/forgit/runs/7706380924?check_suite_focus=true

carlfriedrich commented 1 year ago

Nevermind, following SC2086, SC2207 and SC2031 I found a way to make the linter happy while the code still works. 😄 Tested in bash and zsh.

carlfriedrich commented 1 year ago

Hey @wfxr, is there a chance that you could review this in the near future?

wfxr commented 1 year ago

@carlfriedrich 🙏 Sorry for the very late reply.

I just tested it and it works smoothly. Thanks for your contribution!

wfxr commented 1 year ago

@carlfriedrich Considering that you have made many great improvements to the project, would you like to be a co-maintainer of this project?

carlfriedrich commented 1 year ago

@wfxr Great, thanks for merging! And yes, thanks a lot for the invitation! :-)

cjappl commented 1 year ago

Woo hoo! Congrats bud :) welcome to the team. 🎉

On Tue, Sep 13, 2022 at 2:20 AM, Tim @.***> wrote:

@.***(https://github.com/wfxr) Great, thanks for merging! And yes, thanks a lot for the invitation! :-)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>