commitlint-jira icon indicating copy to clipboard operation
commitlint-jira copied to clipboard

Respect Angular conventions

Open ITler opened this issue 4 years ago • 7 comments
trafficstars

Hello,

I am wondering if this repository is still maintained. I hope so, because I wanted ask if you could support JIRA IDs at the end or even at second position of a commit message. I am asking because I would like to also use it together with angular commit conventions to end up with a commit like

  • feat: great thing JIRAID-1234 or
  • feat: great thing (JIRAID-1234)

this would allow subsequent tooling like semantic-release and Changelog generation based on commits to deliver even nicer results.

ITler avatar Jun 09 '21 07:06 ITler

@ITler it's still maintained))) but guys It is a package only for JIRA commit formats, not Angular formats....if you want Angular style then use https://github.com/conventional-changelog/commitlint#getting-started

gherciu avatar Aug 13 '21 18:08 gherciu

Hello @Gherciu,

I know this package is not for Angular formats, but I am asking to enable it to work alongside the Angular formats. My proposal is to make commitlint configurable to allow the JIRA ID being located at the end of a commit message. I refined the initial description and kindly ask for re-opening this isse.

Thanks @ITler

ITler avatar Aug 20 '21 11:08 ITler

@ITler were you able to find a solution? I'm trying to get a working config for the same commit format.

antodd avatar Feb 14 '22 19:02 antodd

@antodd unfortunately not

ITler avatar Mar 23 '22 14:03 ITler

At the moment that is not possible because is not implemented in this package. If someone needs that ..Pls feel free to open a PR for that and I'll review, merge and publish it to NPM.

I will not implement that because I think this functional is useless but if someone wants to spend time on that then I'll review and merge... If someone wants this format you can also use the standard config for commitlint and write the commit in this format : feat(PRJ-123): commit body which is pretty similar to your examples.

gherciu avatar Mar 24 '22 13:03 gherciu

I think this functional is useless

Just because you use a convention, doesn't make it useless. That is why the main @commitlint package is so configurable, as people have different standards for different companies

I think the Signed off by: is a weird convention, but by no means do I think it is stupid or "useless"

RHeynsZa avatar Jul 22 '22 11:07 RHeynsZa

if someone is still fighting with this, adding a custom plugin works

  parserPreset: {
    parserOpts: {
      issuePrefixes: ["JIRA-"],
    },
  },
  plugins: [
    {
      rules: {
        // Issues should be in the footer, as per Angular Commit Styling
        "issue-reference-in-footer": ({ references, footer }) => {
          // First check if there is a issue reference in the commit
          if (references.length === 0) {
            return [true, "No issue reference found"];
          }
          // Make sure the issue reference is in the footer
          if (footer === null) {
            return [false, "Issue reference must be in the footer"];
          }
          // Make sure all issue references are in the footer
          const footerReferences = footer.match(/JIRA-\d+/g);
          if (footerReferences === null) {
            return [false, "Issue reference must be in the footer"];
          }
          // Make sure all issue references are in the footer
          if (footerReferences.length !== references.length) {
            return [false, "Issue reference must be in the footer"];
          }
          return [true, "Issue reference found in footer"];
        },
      },
    },
  ],

Some documentation I used here:

  • https://commitlint.js.org/#/reference-plugins
  • https://stackoverflow.com/questions/70521236/customise-commitlint-header-format

RHeynsZa avatar Sep 09 '22 13:09 RHeynsZa