Set title/body from commit-message if given #3576
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there-
I'd like to set just one input to customize the commit-message, title, and body
without having to duplicate things. So here is a PR that I think does that with
a pretty simple implementation scoped to inputs parsing.
Apologies if I've missed conventions or details anywhere, just let me know.
I also have a few tangential questions that came up while doing this:
../lib/utils
in the tests (vs just../utils
) meant I had to run abuild
any time I changed something for the tests to see the change. This seems inconvenient, am I missing something?body
andbodyPath
arestring
(notstring | null
), so I'm using the=== ''
condition to determine if they've not been set. However, a few lines below I see you were doingif (inputs.bodyPath)
. I would think that condition can never be false ifbodyPath
is only ever astring
-- but it seems to work? I'm not a JavaScript expert, so I may be missing something here too. Should I be doing!inputs.body
(etc) in my own conditions?And here is the commit message of my change with further details:
If
title
,body
, andbody-path
are all not given, andcommit-message
is, parse thetitle
andbody
from the'commit-message'.
A properly formatted message (title, blank line, then body) will be used
as title and body. Otherwise, the first line is used as title and the
remaining lines as body. Another valid approach could be to take all the
lines as title, or all the lines until the first blank as title, but the
former is unlikely to be the user's intention and the latter would
introduce complexity.
The parsing function was added in
utils
to facilitate testing.