Skip to content

Remove "appendix" information from commit message #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2020

Conversation

gwd
Copy link
Contributor

@gwd gwd commented Sep 17, 2020

...similar to git am.

Add a new field, BodyAppendix to PatchHeader.

Modify scanMessageBody to return both the body and the appendix.
Do this by keeping two string builders, and having it switch to the
appendix builder when it finds a --- line.

Handling the newlines at the end as expected requires moving things
around a bit.

First, we were trimming space from the line once to decide whether the
line was empty, and then trimming space again if we determined it
wasn't empty. This only needs to be done once.

Then, do all the trimming (both of whitespace and the prefix) first,
before deciding what to do about the line.

Add some tests to verify that it works as expected.

NB that this patch will separate out an "appendix" even from the
output of git log, which presumably has already been checked in. If
this is not the desired behavior, we could either:

  1. Make the --- check after trimming whitespace, but before trimming
    the indent, or

  2. Pass in a boolean to tell scanMessageBody not to separate out
    appendix material if we're calling from parseHeaderPretty.

Signed-off-by: George Dunlap george.dunlap@citrix.com

@gwd
Copy link
Contributor Author

gwd commented Sep 17, 2020

BTW I had this finished before you mentioned having removal be email-only. I'm happy to add a boolean argument to scanMessageBody, which would only be true when called from parseHeaderMail if you prefer.

@bluekeyes bluekeyes linked an issue Sep 22, 2020 that may be closed by this pull request
Copy link
Owner

@bluekeyes bluekeyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB that this patch will separate out an "appendix" even from the output of git log, which presumably has already been checked in

I think I'd like to take the conservative approach to start with and only do this separation in the email case, where we reasonably expect the input to contain an appendix. I'd rather not surprise people who happen to have this line for other purposes in non-email patches (even if it is unlikely).

I think the boolean argument is the cleanest way to implement it.

...when parsing emails, similar to `git am`.

Add a new field, `BodyAppendix` to PatchHeader.

Modify `scanMessageBody` to accept a boolean argument saying whether
to separate out the appendix or not.  Do this by keeping two string
builders, and having it switch to the appendix builder when it finds a
`---` line.

Handling the newlines at the end as expected requires moving things
around a bit.

First, we were trimming space from the line once to decide whether the
line was empty, and then trimming space again if we determined it
wasn't empty.  This only needs to be done once.

Then, do all the trimming (both of whitespace and the prefix) first,
before deciding what to do about the line.

Request BodyAppendix separately when parsing a mail, but not a commit
message.

Add some tests to verify that it works as expected.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
@gwd gwd force-pushed the working/remove-appendix branch from 179be46 to c01d938 Compare October 23, 2020 17:01
@gwd
Copy link
Contributor Author

gwd commented Oct 23, 2020

Thanks for the review; I've made the requested changes.

Copy link
Owner

@bluekeyes bluekeyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the changes look good.

@bluekeyes bluekeyes merged commit 1bd59c4 into bluekeyes:master Oct 24, 2020
@gwd gwd deleted the working/remove-appendix branch October 30, 2020 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate out "appendix" material?
2 participants