jesseduffield / lazygit

simple terminal UI for git commands
MIT License
47.94k stars 1.72k forks source link

Add command to paste commit message from clipboard #3676

Closed WaterLemons2k closed 5 days ago

WaterLemons2k commented 2 weeks ago

Resolves #3672

Added an entry to the commit message menu called "Paste commit message from clipboard", which splits the clipboard into subject and description and pastes both into their respective fields.

Also found that the current SplitCommitMessageAndDescription function has a problem with lines ending in CRLF, fixed.


There should be some more tests here, but I'm not sure where to start. I'll do my best if anyone can tell me.

stefanhaller commented 6 days ago

Looks good now, except for the discussion about the tests.

It would be good to squash all changes into a single commit (except for adding the tests, which should come in a separate commit if you insist on still adding them).

For your next PR, it would be nice to keep a good commit history in mind from the beginning, this makes things easier to review. Don't just pile changes on top; prefer using fixup commits (see here for some brief description). Thanks!

stefanhaller commented 6 days ago

I added two integration tests, if you want to have a look at those.

Merging now. Thanks again for the contribution!

stefanhaller commented 6 days ago

Whoops, the tests fail on CI (they succeeded for me locally). Pushed a fixup (3ecfe2d2dc7d) to see if that fixes it...

stefanhaller commented 6 days ago

OK, that didn't help for some reason. It's also not a very desirable solution because it increases the time it takes to run a CI job.

The next idea would be to do what we did for copying in #2784: provide a user config to set a custom command for reading from the clipboard. That's probably desirable anyway for people who use lazygit over ssh. We could then use that to configure simple echo and cat commands for writing to and reading from a text file, like we did here.

@WaterLemons2k I'm out of time for today, not sure when I would get around to doing this, but if you feel like giving it a try, feel free!

stefanhaller commented 6 days ago

@WaterLemons2k OK, I did find a bit of time to do this after all. Seems to work fine now, if you want to have a look.

WaterLemons2k commented 6 days ago

LGTM, thanks for doing this. I saw this when I looked at CopyToClipboard, but didn't do it.