Issue #31 resolved

No ability to append text to automatic commit messages

John Peacock
created an issue

We use precommit hooks with our repositories to ensure we can tie commits to the appropriate ticket in our bugtracking system. However, none of the "automatic" commits (starting with init) that hgflow generates will pass muster, because they are missing the correct text. Since certain hgflow commands generate multiple commits, I cannot rely on manually reissuing the commit after the fail to fix this.

From a design point of view, there seems like two ways to handle this:

1) Append/prepend user supplied --message text to whatever it was that hgflow would normally use.

2) Replace the hgflow text with the contents of --message (thus requiring the user to include relevent information in their message).

I think #1 is much better, since it would always mean the relevant merge/branch messages that hgflow emits are included in every commit message. This corresponds to how you can add the --log option to graft to get the source hash added automatically to the original commit message.

On the other hand, I suspect that #2 would be simpler to implement, but more prone to user error.

Thoughts? I'm probably going to try to get this working on my own, so you may get a pull request (against v0.95.0 I assume would be best).

Comments (8)

  1. Yujie Wu repo owner

    Hi John,

    If I understand correctly, the problem arises because:

    1. your precommit hook requires all commit messages to carry a ticket string.
    2. there is no easy way to insert a ticket string into hgflow's automatic commit messages.

    Have you considered to hack the hook to make it ignore all hgflow's automatic commits? This might be the easiest.

    As to the two design options, I prefer the first one, too.

  2. Yujie Wu repo owner

    John,

    I pushed my implementation as branch hotfix/0.9.6/add_stamp_option. The new option is called -p or --stamp and is available for all commands and actions that commit. (I prefer a different name than --message because it has used by finish with a different meaning)

    If you can try it out and let me know if it works, that will be great.

  3. John Peacock reporter

    I like your code much better! As it turns out, I probably won't wind up using this, because if the user includes a #time command (to log time spent on this change), it can get replicated in multiple commits (say, if they use it to finish a branch). That will double or triple count the time added in the ticket system. :(

    I'm going to just have the pre-commit hook ignore any line that begins with "flow: " and only whinge if there is some remaining line in the commit message that fails our minimal template.

    Thanks for the fast response, BTW...

  4. Log in to comment