{"id":21893307,"url":"https://github.com/ncm-org/ncm","last_synced_at":"2026-04-28T13:36:41.254Z","repository":{"id":64302419,"uuid":"282453930","full_name":"ncm-org/ncm","owner":"ncm-org","description":"Generation and verification of git commit message","archived":false,"fork":false,"pushed_at":"2020-08-21T15:25:25.000Z","size":3803,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-25T05:04:20.598Z","etag":null,"topics":["commit","git","ncm"],"latest_commit_sha":null,"homepage":"https://ncm.ink","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ncm-org.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}},"created_at":"2020-07-25T13:54:27.000Z","updated_at":"2020-11-05T07:58:39.000Z","dependencies_parsed_at":"2023-01-15T09:45:23.874Z","dependency_job_id":null,"html_url":"https://github.com/ncm-org/ncm","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/ncm-org/ncm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncm-org%2Fncm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncm-org%2Fncm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncm-org%2Fncm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncm-org%2Fncm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncm-org","download_url":"https://codeload.github.com/ncm-org/ncm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncm-org%2Fncm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32383653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T11:25:28.583Z","status":"ssl_error","status_checked_at":"2026-04-28T11:25:05.435Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["commit","git","ncm"],"created_at":"2024-11-28T13:13:21.869Z","updated_at":"2026-04-28T13:36:41.238Z","avatar_url":"https://github.com/ncm-org.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"assets/asciinema-player.css\" /\u003e--\u003e\n\u003c!--\u003cscript src=\"assets/asciinema-player.js\"\u003e\u003c/script\u003e--\u003e\n\n![GitHub](https://img.shields.io/github/license/ncm-org/ncm)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/ncm-org/ncm)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/ncm-org/ncm)\n![GitHub All Releases](https://img.shields.io/github/downloads/ncm-org/ncm/total)\n\n#### NCM是什么？\n- **N**ice **C**ommit **M**essage\n- 用于校验 `git commit message` 是否合符[`约定式提交`](https://www.conventionalcommits.org/zh-hans/v1.0.0-beta.4/)规范。\n- 生成符合[`约定式提交`](https://www.conventionalcommits.org/zh-hans/v1.0.0-beta.4/)规范的`git commit message`。\n\n#### 什么是约定式提交\n\n\u003e 一种用于给提交信息增加人机可读含义的规范！\n\n约定式提交规范是一种基于提交消息的轻量级约定。 它提供了一组用于创建清晰的提交历史的简单规则； 这使得编写基于规范的自动化工具变得更容易。 这个约定与 [`SemVer`](https://semver.org/lang/zh-CN/) 相吻合， 在提交信息中描述新特性、bug 修复和破坏性变更。\n\n提交说明的结构如下所示：\n```\n\u003c类型\u003e[可选的作用域]: \u003c描述\u003e\n\n[可选的正文]\n\n[可选的脚注]\n```\n约定式提交规范受到了[`angular.js`](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) 提交准则的启发，并在很大程度上以其为依据。关于类型、作用域、描述、正文、脚注的详细规范信息可参考[`这里`](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)。\n\n#### 为什么要使用[`约定式提交`](https://www.conventionalcommits.org/zh-hans/v1.0.0-beta.4/)\n\u003e 在多人协作项目中，代码风格统一、代码提交信息的说明等重要性不言而喻。规范的 `LOG` 不仅有助于他人 `REVIEW` ，还可以有效的输出 `CHANGELOG` ，甚至对于项目的研发质量都有很大的提升。\n- 基于提交的类型，自动决定语义化的版本变更。\n- 向同事、公众与其他利益关系者传达变化的性质。\n- 触发构建和部署流程。\n- 让人们探索一个更加结构化的提交历史，以便降低对你的项目做出贡献的难度。\n\n#### 现有的开源工具\n- [**commitizen/cz-cli**](https://github.com/commitizen/cz-cli)：**`star: 9.4K`**，提供 `git cz` 命令替代 `git commit` 命令, 帮助开发者生成符合规范的 `commit message`。\n- [**conventional-changelog/commitlint**](https://github.com/conventional-changelog/commitlint)：**`star: 6.1K`**，检查输入的 `commit message` 是否满足固定格式的工具。\n- [**typicode/husky**](https://github.com/typicode/husky)：**`star: 19.7K`**，为了可以在每次 `commit` 时执行 `commitlint` 检查输入的 message，还需要用到一个工具 [`husky`]((https://github.com/typicode/husky))。[`husky`]((https://github.com/typicode/husky)) 是一个增强的 `git hook` 工具。可以在 `git hook` 的各个阶段执行 `package.json` 中配置好的 `npm script`。例如：\u003cbr\u003e\u003cbr\u003e\n    ```\n    {\n      \"scripts\": {\n        \"commitmsg\": \"commitlint -E GIT_PARAMS\"\n      }\n    }\n    ```\n\n#### 现有开源工具的缺点\n- 安装、配置繁琐，要实现一整套规范流程，首先需要安装 [`nodejs`](https://nodejs.org/)、[`npm`](https://www.npmjs.com/) 环境。然后依次安装上述的3种工具，再进行配置，以实现工具在提交过程中的衔接。\n- `git cz` 命令在运行前没有对暂存区进行审查。导致输入完提交信息后却被告知 `changes not staged for commit`。\n- 配置可选项过于繁多，容易造成团队内不同项目之间规范存在差异。\n\n#### NCM特点\n- 跨平台，Go语言天然优势。支持Window、MacOS、Linux。\n- 安装方便，只需要将可执行文件配置在环境变量即可。\n- 在线升级，方便及时升级到最新版本。\n- 功能强大，一个程序即可实现提交、校验的功能。\n- 兼容性好，兼容 `git cz`，兼容 [`jetbrains`](https://www.jetbrains.com/) 的 [`Git Commit Template`](https://plugins.jetbrains.com/plugin/9861-git-commit-template) 插件。\n\n#### NCM安装\n- `MacOS` `Linux` 系统运行以下命令，等待执行完成后运行 `ncm info` 验证是否安装成功。\n\n    \u003e 安装命令的运行依赖于 `curl` 、 `sha256sum` 以及 `unzip`  , 请先确认系统是否安装了依赖工具。\n\n    ```shell\n    # MacOS\n    source /dev/stdin \u003c\u003c\u003c\"$(curl -LSs sh.ncm.ink)\"\n    ```\n\n    ```shell\n    # Linux\n    source \u003c(curl -LSs sh.ncm.ink)\n    ```\n\n    ![ncm install](assets/ncm_install.gif)\n    \u003c!--\u003casciinema-player width=100% poster=\"npt:0:20\" src=\"assets/ncm_install.json\" /\u003e--\u003e\n\n- `Windows` 系统参考如下步骤安装\n\n   1. 进入项目的发布页面，选择合适的zip文件进行下载，并解压到合适的目录。\n\n   2. 将解压目录配置到环境变量中，以便于可以不带路径运行 `ncm` 。\n\n   3. 运行 `ncm info` 验证是否安装成功。\n\n#### NCM使用\n1. ##### NCM支持的所有命令\n\n   ![ncm help](assets/ncm_help.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:4\" src=\"assets/ncm_help.json\" /\u003e--\u003e\n\n2. ##### 使用NCM校验commit message\n   在git项目中运行 `ncm init` 命令。此命令会在项目中的 `.git/hooks` 文件夹中生成内容为`ncm check`的`commit-msg` hook文件。有关`git commit-msg hook`的详细信息可点击[这里](https://git-scm.com/docs/githooks#_commit_msg)查阅。\n\n   \u003e 注意：如果项目中已经通过其他方式添加了 `commit-msg` 文件。则在运行命令后会提示是否覆盖文件，输入 `y/N` 进行选择。回车默认选择`N`，则在 `commit message` 时不会触发 `ncm` 的校验。\n\n   ![ncm init](assets/ncm_init.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:26\" src=\"assets/ncm_init.json\" /\u003e--\u003e\n\n   之后，每次进行 `git commit` 时都会触发 `commit-msg` hook，执行 `ncm check` 命令。如果提交信息不符合[`约定式提交`](https://www.conventionalcommits.org/zh-hans/v1.0.0-beta.4/)规范，则会中断提交，并输出帮助提示。\n\n   ![ncm check](assets/ncm_check.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:19\" src=\"assets/ncm_check.json\" /\u003e--\u003e\n\n   \u003e 如果之后不想使用此功能，可运行 `ncm uninit` 命令对 `commit-msg` hook进行移除。\n\n3. ##### 生成commit message信息并提交\n   在需要 `commit` 时，请先使用 `git add` 命令，将需要提交的文件添加到暂存区，然后运行 `ncm` 命令 。此时会进入交互式模式。根据实际情况以及输出的提示，依次选择或填写相关信息。\n\n   ![ncm](assets/ncm.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:34\" src=\"assets/ncm.json\" /\u003e--\u003e\n\n   如果只想提交指定的文件，可以运行 `ncm add file ...`\n\n   ![ncm add file ...](assets/ncm_add.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:21\" src=\"assets/ncm_add.json\" /\u003e--\u003e\n\n   如果想提交所有文件，可以运行 `ncm add .`\n\n   ![ncm add .](assets/ncm_add_all.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:28\" src=\"assets/ncm_add_all.json\" /\u003e--\u003e\n\n4. ##### 版本升级\n   运行 `ncm upgrade`\n\n   ![ncm upgrade](assets/ncm_upgrade.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:7\" src=\"assets/ncm_upgrade.json\" /\u003e--\u003e\n\n5. ##### 意见反馈\n\n   运行 `ncm info` 命令，复制输出的信息，粘贴到群里，并描述具体的问题。\n\n   ![ncm info](assets/ncm_info.gif)\n   \u003c!--\u003casciinema-player width=100% poster=\"npt:0:3\" src=\"assets/ncm_info.json\" /\u003e--\u003e\n\n   |  \u003cimg src=\"./assets/qr_popo_group.png\" width=\"180\" height=\"180\" alt=\"qr_popo_group\"/\u003e  | \u003cimg src=\"./assets/qr_wechat_group.png\" width=\"180\" height=\"180\" alt=\"qr_wechat_group\"/\u003e |\n   |  :--:  | :--:  |\n   |**POPO**|**WeChat**|\n   \n\n#### 小提示\n- 对于已经在合理合法使用可视化工具生成符合[`约定式提交`](https://www.conventionalcommits.org/zh-hans/v1.0.0-beta.4/)规范的个人、团队或者项目仍可继续使用该工具。为了进一步确保提交信息符合规范，可在项目中运行 `ncm init` 命令注入hook即可。\n- 运行 `ncm -h` 可查看支持的所有命令。\n- 运行 `ncm -v` 可查看当前版本。\n- 运行 `ncm info` 可查看当前版本的详细信息。\n- 除非特殊情况，否则尽量不要运行 `ncm uninit`。\n\n#### 感谢\n- [**go**](https://go.dev)\n- [**git**](https://git-scm.com)\n- [**coding**](https://coding.net)\n- [**GoLand**](https://www.jetbrains.com/go)\n- [**SemVer**](https://semver.org)\n- [**asciinema**](https://asciinema.org/)\n- [**spf13/cobra**](https://github.com/spf13/cobra)\n- [**gookit/color**](https://github.com/gookit/color)\n- [**typicode/husky**](https://github.com/typicode/husky)\n- [**commitizen/cz-cli**](https://github.com/commitizen/cz-cli)\n- [**angular/angular.js**](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)\n- [**AlecAivazis/survey**](https://github.com/AlecAivazis/survey)\n- [**schollz/progressbar**](https://github.com/schollz/progressbar)\n- [**conventionalcommits**](https://www.conventionalcommits.org)\n- [**goreleaser/goreleaser**](https://github.com/goreleaser/goreleaser)\n- [**conventional-changelog/commitlint**](https://github.com/conventional-changelog/commitlint)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncm-org%2Fncm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncm-org%2Fncm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncm-org%2Fncm/lists"}