The sound distributed version control system

#336 add a config option for a patch message template

Closed on April 30, 2021
mpevnev on February 19, 2021

The attached patch allows prepopulating message during pijul record from an option in the global config file. Similar to git’s commit.template.

Questions:

  • Should the option contain the template inline (currently does) or point to a file with one?
  • Should I move the lazy_static from record module to the config, so other modules can use it if they want to? Is it even needed? I’ve added it pretty much out of laziness (no pun intended).
  • Keep the message: ... as-is or move message to a separate variable, like authors? It’s a bit on the cumbersome side.
mpevnev on February 19, 2021

Did I do something wrong with the patch message? pijul log shows newlines properly, but they got squashed in the Nest display.

The_Decryptor on February 20, 2021

There’s a separate description field in the change format, it’s not emitted by default unfortunately so you have to add it manually.

message = 'Add a config option for the patch message template'
description = '''Contents of field `message_skeleton` at the root of the global config file will be placed into `message` by `pijul record` for editing, if present and not overridden via `-m` switch.

Analogous to git's `commit.template`, but as an inline string rather than a filepath.

Moved the call to `Global::load` to a `lazy_static`. `header` needs the config in two places now, and parsing it twice seems like a waste. Arranging a single parse manually in a satisfying way (in both places it's a fallback, and should remain one) makes the function a mess.'''

It should look like that.

mpevnev on February 20, 2021

I see. Thank you! I will update the patch this evening to use this field instead (the code and the patch description).

mpevnev added a change on February 20, 2021
EWCZA36LQWVX3TW3YSX4UH7PT54OYWC5OSIYE6LPH473AIYR3FKQC
unidual on February 21, 2021

Should the option contain the template inline (currently does) or point to a file with one?

I vote for the file.

  • It harder to set right and update if inline.
  • Also, the same template file could be shared by git and pijul, coudn’t it?
  • Uniformity with sane choices is good.

There’s a separate description field in the change format

Wat? I was creating multi-lines message the whole time. BTW it took me some times to figure out how! (triple quotes). If it is meant to be the summary only, the field should be named so (or title) and description should be there by default (with the triple quotes).

You could even nudge people: if no template set, the default would be:

description = '''
Why is this change necessary?

How does it address the issue?

What side effects does this change have?

(or maybe as a comment rather than injected in the description, which is a bit intrusive).

See https://thoughtbot.com/blog/5-useful-tips-for-a-better-commit-message

mpevnev on February 21, 2021

Also, the same template file could be shared by git and pijul, coudn’t it?

I didn’t think about it, this would be quite nice. It might be somewhat awkward if the git template also sets the summary, not just the body of the description - pijul could either parse the single file into message and description (care needs to be taken to allow title-less templates) or dump the shared file into description only (along with the summary, if any). But I’m not sure how often people use templates (and would want to) for the summary and how much of a problem that would be. Regardless, a file does sound better.

mpevnev added a change on February 28, 2021
TFPETWTVADLG2DL7WERHJPGMJVOY4WOKCRWB3NZ3YOOQ4CVAUHBAC
main
mpevnev on March 1, 2021

Regarding

You could even nudge people: if no template set, the default would be … (or maybe as a comment rather than injected in the description, which is a bit intrusive).

I’ve tried writing this up last night, but failed. The comment needs to be inserted into the middle of the write in libpijul/src/change/text_changes.rs, otherwise it ends up attached to the [[authors]] subsection. I’m not sure if the serializer even supports this.

pmeunier on April 30, 2021

Sorry for the slow reply, I just found the time to apply this. Very cool patch, thank you very much!

pmeunier closed this discussion on April 30, 2021
pmeunier on April 30, 2021

Btw, I’m closing because there’s nothing for me to do just now, but you can keep pushing changes if you want (and possibly reopen).