{"id":16256508,"url":"https://github.com/janniks/prepare-commit-msg","last_synced_at":"2025-03-19T21:31:04.414Z","repository":{"id":81410801,"uuid":"109268572","full_name":"janniks/prepare-commit-msg","owner":"janniks","description":"Automatically prefix commit messages with the current branch issue number","archived":false,"fork":false,"pushed_at":"2021-01-27T13:10:15.000Z","size":6612,"stargazers_count":39,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T23:26:16.607Z","etag":null,"topics":["atlassian","atlassian-jira","git","git-hooks","issue","issue-management","issue-mgt","issue-tracker","issue-tracking-system","issues","jira"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janniks.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":"2017-11-02T13:29:54.000Z","updated_at":"2025-01-23T23:27:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"363936a4-42bb-4556-b980-3de934d81473","html_url":"https://github.com/janniks/prepare-commit-msg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janniks%2Fprepare-commit-msg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janniks%2Fprepare-commit-msg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janniks%2Fprepare-commit-msg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janniks%2Fprepare-commit-msg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janniks","download_url":"https://codeload.github.com/janniks/prepare-commit-msg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244056428,"owners_count":20390720,"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":["atlassian","atlassian-jira","git","git-hooks","issue","issue-management","issue-mgt","issue-tracker","issue-tracking-system","issues","jira"],"created_at":"2024-10-10T15:45:25.090Z","updated_at":"2025-03-19T21:31:04.409Z","avatar_url":"https://github.com/janniks.png","language":"Shell","readme":"# Prefix Issue Number - Git Hook\nThis is a git hook for lazy people. :sleeping:\n\n## Description :books:\nThis git hook automatically prepends a parsed issue number (from the current branch) to your commit messages on every commit. _(See [Usage](#usage-wrench) for examples and details)_\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Example usage\" src=\"example.gif\"\u003e\n\u003c/p\u003e\n\nThis git hook requires `ruby`  to be installed _(already pre-installed by default on macOS)_.\n\n## Install :rocket:\n### Install Script\nTo install simply run the following command. This requires `curl` to be installed.\n\n```bash\nsh \u003c(curl -s https://raw.githubusercontent.com/janniks/prepare-commit-msg/master/scripts/install.sh)\n```\n\n\u003e If you choose the option to install globally, you will have to reinitialize all your git repositories. The following helpful command reinitializes all repositories found in sub-directories of the current directory.\n\u003e\n\u003e `find . -name .git -type d -prune -exec sh -c 'git --git-dir \"{}\" init' \\;`\n\n### Install Manually\nIf you prefer to install manually you can walk through the following steps:\n\n1. Copy the `scripts/prepare-commit-msg` script into your local git repository inside `.git/hooks`\n1. Edit the placeholders at the beginning of the script\n1. Make sure the is script executable by running `chmod +x prepare-commit-msg`\n1. Enjoy! Test it by committing anything!\n\n## Usage :wrench:\n**Simply commit as you always would!** This git hook also works with tools like [Tower](https://www.git-tower.com/) that use native git bindings.\n\nThis git hooks will look at the current branch (e.g. `type/ABC-123-branch-name`) and parse the issue number and project key (e.g. `ABC 123`) to use for prefixing commit messages. This can be useful in connection with tools like [Jira](https://confluence.atlassian.com/jirasoftwarecloud/referencing-issues-in-your-development-work-777002789.html).\n\n- If no issue number is found in the branch name, the commit message _will not be modified_.\n- If the commit message already contains an issue number, the commit message _will not be modified_.\n\n### Examples\n\n| Branch name | Entered commit message | Updated commit message |\n| ----------- | :--------------------: | :--------------------: |\n| `bugfix/ABC-012-add-initial-repo` | `Set up repo` | `[ABC-012] Set up repo` |\n| `improvement/ABC-123-great-things` | `Add files` | `[ABC-123] Add files` |\n| `feature/ABC-123-something-normal` | `[XYZ-321] Something different` | _not modified_ |\n\n### Default Regular Expressions\nThese are the default regular expressions that are used by the script on install. They can easily be changed during install using the provided script or manually tweaked.\n\n#### Parsing issue numbers from current branch name\n[`/[.]*\\/([\\-\\w]*?\\-\\d+)/`](https://regex101.com/r/gf9GMF/1)\n\n| Detects issue number | Does not detect issue number |\n| :------------------: | :--------------------------: |\n| `feature/ABC-123-test-message` | `abc-123-do-it` |\n| `Improvement/XYZ-ABC-321-Crazy-Name` | `simple-branch-name` |\n\n#### Checking commit messages for existing issue numbers\n[`/^\\s*\\[[\\-\\w]*\\d\\]/`](https://regex101.com/r/nZr8LF/1)\n\n| Detects issue number | Does not detect issue number |\n| :------------------: | :--------------------------: |\n| `[ABC-123] Test message` | `Test message` |\n| `[XYZ-312] Message test` | `[ABC] Testing stuff` |\n| ` [XYZ-ABCD-321] Awesome sauce` | ` [Add ABC-123 files]` |\n\n#### Detecting automated commits by git\n[`/(Merge\\sbranch\\s\\'|\\#\\sRebase\\s|This\\sreverts\\scommit\\s)/`](https://regex101.com/r/Cs2Qag/1)\n\n| Ignores following commits |\n| :-------------------: |\n| `Merge branch 'testing' into master` |\n| `# Rebase commit 9f3bc7b` |\n| `This reverts commit 28da9f6` |\n\nYou can use tools like [Regex101](https://regex101.com/) to tweak and test these regular expressions.\n\n## FAQ \u0026 Problems\n\n\u003cdetails\u003e\n  \u003csummary\u003eI already have a global git-template!\u003c/summary\u003e\n  Install manually and add the git hook file to your hooks directory in your existing git-template.\n\u003c/details\u003e\n\n## Uninstall :confounded:\nIf you're unhappy with this git hook:\n\n* Simply run `rm -rf .git/hooks/prepare-commit-msg` to uninstall locally\n* Or run `rm -rf ~/.git-template/hooks/prepare-commit-msg` to uninstall globally\n\nPlease let me know what you didn't like!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanniks%2Fprepare-commit-msg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanniks%2Fprepare-commit-msg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanniks%2Fprepare-commit-msg/lists"}