spacedentist / spr

Submit pull requests for individual, amendable, rebaseable commits to GitHub
https://getcord.github.io/spr/
MIT License
378 stars 33 forks source link

Spr diff will complain about missing Test Plan when commit message contains # Test Plan #81

Open lazybean opened 2 years ago

lazybean commented 2 years ago

I'm trying to have Test Plan appear as a markdown heading in the PR description. When my commit message contains

 # summary
 using SPR make my life easier

 # Test Plan:
 1. do not use spr: sad face
 2. use spr: happy face

Doing spr diff or spr diff --update-message will says: 💔 Commit message does not have a Test Plan!

My current work around is to duplicate Test Plan, one as heading, and one as normal text

sven-of-cord commented 2 years ago

I have just had a play with this.

So, it seems that GitHub renders Markdown in pull request descriptions, but not in the eventual commit messages. See e.g. https://github.com/getcord/spr/commit/525973cac28fcea3bac3d4d5b629bfb2621ad4f1

Is there another place in the GitHub UI maybe where commit messages are shown and where Markdown is rendered?

What would be the best way for spr to handle this?

The message parse could recognise both "Test plan:" and "# Test plan" as section starters, so you could always enter either way. When writing commit messages (both in your local repository during development, and when finally landing a commit on master) it could write "Test plan:", but when it prepares the pull request description it could write "# Test plan".

lazybean commented 2 years ago

Hey, Thanks a lot for the reply and for thinking of how to improve the situation. 👍

I'm not aware of any other places in GitHub UI where markdown is rendered for commit messages.

What you propose could work. 🎉 But the more I think about it, the more I think my request is not very reasonable; adding complexity for very little gain.

One problem is that # is the default comment character, so in order for the # Test plan to stay in the commit message I have to put a space before it. Lots of people would forget that I'm afraid and then have no test plan.

joneshf commented 2 years ago

I'll just note that there's a few different ways around the # in a commit situation: https://stackoverflow.com/questions/2788092/start-a-git-commit-message-with-a-hashmark. The one I've been using for a bit that seems to work best is using git commit --cleanup scissors.

If you're not familiar, it changes the way the editor text is interpreted. Instead of having line comments starting with #, it makes a line like:

# ------------------------ >8 ------------------------

Everything after that line is ignored. Everything before that line goes in verbatim. So you can use # at the start of a line to your heart's content.

This isn't an ideal situation, because you have to know what the workaround is in order to use it. But it does exist and it makes using # in commits very straight forward. It's also a bit easier if you set it in the config with git config commit.cleanup scissors, so it automatically works without having to remember the option each time.