enforce a standard git commit format

Bug #1947772 reported by Andrea Ieri
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bootstack-charms-spec
New
Undecided
Unassigned

Bug Description

We should leverage pre-commit to enforce a git commit standard that would include the LP bug the commit is fixing. This would allow us to automate marking bugs as fix-released in launchpad, as well as generating release notes.

Open question: we may sometimes want to add trivial commits that are not tied to a bug. How do we prevent pre-commit from blocking the commit? One possibility would be to have an alternate valid format for trivial commits that includes a specific keyword, e.g. #TRIVIAL

Revision history for this message
Xav Paice (xavpaice) wrote :

Suggest having a standard format and some docs surrounding that, e.g. `Fixes bug LP: #12345`, for formatting that is also captured and automatically turned to links by some editors/terminals.

Revision history for this message
Giuseppe Petralia (peppepetra) wrote :

This can be done with:

```
  - repo: local
    hooks:
      - id: launchpad-bug
        name: Commit message should contain "Closes-Bug" or "Trivial-Change"
        language: pygrep
        entry: '\A((?!((Closes-Bug: #[0-9]+)|(Trivial-Change))).)*\Z'
        args: [--multiline]
        stages: [commit-msg]
```

Tests: https://pastebin.canonical.com/p/mymT7MgZnt/

Output is also quite explicit re why it is failing

Revision history for this message
Andrea Ieri (aieri) wrote :

Two comments:
* some (most?) bugfixes benefit from being split among multiple commits, so we have to also allow Partial-Bug
* in the above scenario, we would ideally want all commits comprising the whole bugfix to be marked as 'Partial-Bug', and the merge commit to contain the 'Closes-Bug' keyword. However, the merge commit is generated by mergebot. How do we enforce this?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.