npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

branch-commit-msg

v1.0.3

Published

A git commit-msg hook that automatically inserts a matched pattern from the active branch name to the commit message.

Downloads

107

Readme

branch-commit-msg

Build npm:latest npm:beta codecov semantic-release: angular

Overview

branch-commit-msg is a git commit-msg hook that extracts a configurable regex pattern from the current branch and reformats the final commit message to the configured format.

Installation

With no dependency:

$ npx branch-commit-msg install

With husky:

$ npm install -D branch-commit-msg
$ npx husky add .husky/commit-msg 'npx branch-commit-msg-hook "$1"'

Uninstall

With no dependency:

$ rm .git/hooks/commit-msg

With husky:

Remove npx branch-commit-msg-hook "$1" from .husky/commit-msg and run:

$ npm uninstall branch-commit-msg

Usage

After installation, create a .commitmsgrc.json file at the root of your project and configure how you would like to reformat your final commit message based on elements of the active branch name:

// .commitmsgrc.json

{
  /*
    Regex group pattern to extract from branch name.
      - ex: "(sc)-?[0-9]+"
  */
  "extractPattern": string,

  /*
    Whether the extractPattern is case-sensitive.
      - ex: true
  */
  "extractPatternMatchCase": boolean,

  /*
    Final output format for the commit message.

    Formatting Placeholders:
      %b0: access the entire matched pattern from the branch name
      %b1: access the first matched group pattern from the branch name
      %bn: access the 'n'th matched group pattern from the branch name
        - ex: "%b6" accesses the 6th matched group pattern
      %m: the original commit message

    Pipes:
      lower: applies lower casing to the formatting placeholder
        - ex: "$b2 | lower"
      upper: applies upper casing to the formatting placeholder
        - ex: "%m | upper"
  */
  "commitMsgFormat": string
}

After your .commitmsgrc.json is configured, start making commits!

Configuration Examples

Preface commit message with a Shortcut ticket number:

{
  "extractPattern": "sc-[0-9]+",
  "extractPatternMatchCase": false,
  "commitMsgFormat": "%b0 - %m"
}
# Current branch: SC-123456/my-new-feature
$ git commit -m "added a thing"
$ git log -1 --pretty=%B
# Output: SC-123456 - added a thing

Suffix and format a commit message with a JIRA ticket:

{
  "extractPattern": "SOMEPRJ-[0-9]+",
  "extractPatternMatchCase": false,
  "commitMsgFormat": "%m (%b0 | upper)"
}
# Current branch: feature/someprj-123456
$ git commit -m "added a thing"
$ git log -1 --pretty=%B
# Output: added a thing (SOMEPRJ-123456)

Go crazy with group matching:

{
  "extractPattern": "(some).*(complex[0-9-]+).*(branch)",
  "extractPatternMatchCase": false,
  "commitMsgFormat": "%m | upper to %b1 | upper %b2 %b3 | lower"
}
# Current branch: some/CoMpLEX-123-5/BRANCH
$ git commit -m "added a thing"
$ git log -1 --pretty=%B
# Output: ADDED A THING to SOME CoMpLEX-123-5 branch

Development

Prerequisites

  • Docker installation (for integration and end-to-end (e2e) testing)
  • Node.js (>=14.0.0) runtime
  • Yarn installation

Install Dependencies

$ yarn install

Test

$ yarn test[:unit|:integration|:e2e|:smoke]

Build

$ yarn build