{"id":21915860,"url":"https://github.com/ljpengelen/prefix-commit-message","last_synced_at":"2025-04-18T21:53:30.549Z","repository":{"id":34250374,"uuid":"173489674","full_name":"ljpengelen/prefix-commit-message","owner":"ljpengelen","description":"Script for prepare-commit-msg hook to extract ID from branch name into commit message","archived":false,"fork":false,"pushed_at":"2024-08-09T14:00:52.000Z","size":55,"stargazers_count":5,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-09T15:33:35.327Z","etag":null,"topics":["git","git-hooks","husky"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/prefix-commit-message","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ljpengelen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-02T19:24:20.000Z","updated_at":"2024-08-09T14:00:54.000Z","dependencies_parsed_at":"2024-06-19T05:17:31.896Z","dependency_job_id":"e73789c4-c66e-4bcf-8e40-562d0c712120","html_url":"https://github.com/ljpengelen/prefix-commit-message","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljpengelen%2Fprefix-commit-message","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljpengelen%2Fprefix-commit-message/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljpengelen%2Fprefix-commit-message/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljpengelen%2Fprefix-commit-message/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ljpengelen","download_url":"https://codeload.github.com/ljpengelen/prefix-commit-message/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226971308,"owners_count":17711413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","git-hooks","husky"],"created_at":"2024-11-28T19:14:34.708Z","updated_at":"2024-11-28T19:14:35.550Z","avatar_url":"https://github.com/ljpengelen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prefix Commit Message\n\nThis script is meant to be used as a [prepare-commit-msg Git hook](https://git-scm.com/docs/githooks#_prepare_commit_msg).\nEach time you commit, it extracts the issue identifier or user-story identifier from the current branch name and prefixes your commit message with the extracted identifier.\n\nIt supports identifiers of the form `ABCD-1234` and `1234`, and will look for such identifiers right after the `/` in the name of the current branch.\nIf you're on the branch `feature/JIRA-874-cannot-log-in-on-macos`, for example, this hook will prefix each of your commit messages with `[ JIRA-874 ] `.\n\nThere are simpler shell scripts that achieve the same, but this solution works on Windows too.\n\nThis script can be used standalone or in combination with [Husky](https://github.com/typicode/husky) (version 6 and newer).\nIf you're using an older Husky, see (https://github.com/ljpengelen/prefix-commit-message/tree/v1.3.0).\n\n## Installation\n\n### Standalone usage\n\nNavigate to `.git/hooks` from the root of your Git repository and create an executable file named `prepare-commit-msg` with the following content:\n\n```\n#!/bin/sh\nnpx prefix-commit-message $1\n```\n\n### Usage with Husky\n\nFirst, install [Husky](https://github.com/typicode/husky) and this script:\n\n```\nnpm install husky --save-dev\nnpm install prefix-commit-message --save-dev\n```\n\nThen, enable Git hooks via Husky:\n\n```\nnpx husky install\n```\n\nFinally, set up the prepare-commit-msg hook:\n\n```\nnpx husky add .husky/prepare-commit-msg \"npx prefix-commit-message \\$1\"\n```\n\n## Custom prefix\n\nIf you don't like the square brackets around the identifier, you can supply a custom opening and closing symbol.\nFor example,\n\n```\n#!/bin/sh\nnpx prefix-commit-message $1 -o -c :\n```\n\nand\n\n```\nnpx husky add .husky/prepare-commit-msg \"npx prefix-commit-message \\$1 -o -c :\"\n```\n\nwill result in the prefix `JIRA-874: `.\n\nThe opening symbol is specified via the '-o' flag, and the closing symbol is specified via the '-c' flag.\nAs the example shows, the empty string is used when no value is specified after a flag.\n\n## Including and excluding branches\n\nIf you want to apply the hook to specific branches only, you can supply a regex pattern for branches to include and exclude.\nFor example,\n\n```\n#!/bin/sh\nnpx prefix-commit-message $1 -bi ^feature -be release\n```\n\nand\n\n```\nnpx husky add .husky/prepare-commit-msg \"npx prefix-commit-message \\$1 -bi ^feature -be release\"\n```\n\nwill only extract the identifier from branches that start with the string \"feature\" and do not contain the string \"release\".\n\nThe pattern for branches to include is specified via the '-bi' flag,\nand the pattern for branches to exclude is specified via the '-be' flag.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljpengelen%2Fprefix-commit-message","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fljpengelen%2Fprefix-commit-message","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljpengelen%2Fprefix-commit-message/lists"}