forgit icon indicating copy to clipboard operation
forgit copied to clipboard

Interactively select branch in gcp

Open carlfriedrich opened this issue 3 years ago • 4 comments

Check list

  • [x] I have performed a self-review of my code
  • [x] I have commented my code in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation

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

  • [ ] Bug fix
  • [x] New feature
  • [ ] Refactor
  • [ ] Breaking change
  • [ ] Documentation change

Test environment

  • Shell
    • [x] bash
    • [x] zsh
    • [x] fish
  • OS
    • [x] Linux
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] Others:

carlfriedrich avatar Aug 03 '22 16:08 carlfriedrich

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

carlfriedrich avatar Aug 06 '22 08:08 carlfriedrich

@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 avatar Aug 06 '22 17:08 carlfriedrich

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

carlfriedrich avatar Aug 06 '22 17:08 carlfriedrich

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 avatar Aug 06 '22 17:08 carlfriedrich

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

carlfriedrich avatar Sep 12 '22 15:09 carlfriedrich

@carlfriedrich 🙏 Sorry for the very late reply.

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

wfxr avatar Sep 13 '22 02:09 wfxr

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

wfxr avatar Sep 13 '22 02:09 wfxr

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

carlfriedrich avatar Sep 13 '22 09:09 carlfriedrich

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: @.***>

cjappl avatar Sep 13 '22 11:09 cjappl