{"id":15567580,"url":"https://github.com/wgrape/posture","last_synced_at":"2025-04-24T00:04:04.454Z","repository":{"id":59281642,"uuid":"527992923","full_name":"WGrape/posture","owner":"WGrape","description":"A lightweight and extensible tool for supervising and correcting of development posture / 一个轻量可扩展的开发姿势监督与矫正工具","archived":false,"fork":false,"pushed_at":"2024-03-02T15:33:24.000Z","size":204,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-24T00:03:58.989Z","etag":null,"topics":["developer-tools","development","git","linter","posture","shell","workflow"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/WGrape.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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":"2022-08-23T13:00:51.000Z","updated_at":"2023-03-10T16:52:16.000Z","dependencies_parsed_at":"2024-10-02T17:11:57.772Z","dependency_job_id":null,"html_url":"https://github.com/WGrape/posture","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WGrape%2Fposture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WGrape%2Fposture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WGrape%2Fposture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WGrape%2Fposture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WGrape","download_url":"https://codeload.github.com/WGrape/posture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535098,"owners_count":21446508,"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":["developer-tools","development","git","linter","posture","shell","workflow"],"created_at":"2024-10-02T17:11:52.523Z","updated_at":"2025-04-24T00:04:04.434Z","avatar_url":"https://github.com/WGrape.png","language":"Shell","readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=\"321\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35942268/190055195-bb9ab05a-1922-400e-b9cd-ff536351c323.png\"\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cp\u003eA lightweight and extensible tool for supervising and correcting of development posture\u003c/p\u003e\n\u003cp\u003e一个轻量可扩展的开发姿势监督与矫正工具\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.oscs1024.com/project/oscs/WGrape/posture?ref=badge_small\" alt=\"OSCS Status\"\u003e\u003cimg src=\"https://www.oscs1024.com/platform/badge/WGrape/posture.svg?size=small\"/\u003e\u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/badge/language-Shell-blue.svg\"\u003e\n    \u003cimg alt=\"GitHub release (latest by date)\" src=\"https://img.shields.io/github/v/release/wgrape/posture\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/repo-size/wgrape/posture\"\u003e\n    \u003c!--\u003cimg src=\"https://img.shields.io/github/downloads/wgrape/posture/total\"\u003e--\u003e\n    \u003cimg src=\"https://img.shields.io/badge/document-中文-orange.svg\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-green.svg\"\u003e   \n\u003c/p\u003e\n\n\u003c!-- \u003cdetails\u003e\n  \u003csummary\u003e目录\u003c/summary\u003e\n\n- [一、项目介绍](#1)\n- [二、快速安装](#2)\n- [三、如何使用](#3)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [1、矫正开发姿势](#31)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [(1) git配置](#311)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [(2) 代码规范](#312)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [2、设置全局钩子](#32)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [(1) checkout钩子](#321)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [(2) pull钩子](#322)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [(3) commit钩子](#323)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [(4) push钩子](#324)\n- [四、卸载更新](#4)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [1、卸载应用](#41)\n- \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; [2、版本更新](#42)\n- [五、项目贡献](#5)\n\n\u003c/details\u003e--\u003e\n\n# \u003cspan id=\"1\"\u003e一、项目介绍\u003c/span\u003e\nposture是一个轻量可扩展的开发姿势监督与矫正工具，让您快速开始以正确的规范编写和管理代码，解决团队开发时代码百花齐放、Git提交信息乱写、Git误操作等一系列开发中的\"姿势不正确\"问题。\n\n\u003c!-- \u003e 关于更多背景细节请阅读文章[《以正确的姿势编写和管理代码》](https://github.com/WGrape/Blog/issues/260) --\u003e\n\n# \u003cspan id=\"2\"\u003e二、快速安装\u003c/span\u003e\n\n您可以先通过以下命令完成下载安装操作，如果出现```install successfully```提示，则说明安装成功。这时使用```posture```或```posture help```命令都可以查看使用帮助。\n\n```bash\ngit clone https://github.com/WGrape/posture.git \u0026\u0026 cd posture \u0026\u0026 bash ./install.sh\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n  \u003ch4\u003e安装成功\u003c/h4\u003e\n  \u003cimg width=\"500\" alt=\"image\" src=\"https://github.com/WGrape/posture/assets/35942268/0827c1a8-ec41-4275-b324-517c6f450e86\"\u003e\n  \u003ch4\u003e查看命令帮助\u003c/h4\u003e\n  \u003cimg width=\"500\" alt=\"image\" src=\"https://github.com/WGrape/posture/assets/35942268/101cbd76-24f1-45f3-b92d-0f209458d902\"\u003e\n\u003c/details\u003e\n\n在安装成功后，会在您的posture项目安装目录下生成一个```.env```环境配置文件，用于对posture的一些行为控制。另外在```~/.bash_profile```文件中写入如下内容，自动创建```$POSTURE_PATH```变量并添加到```$PATH```变量中，以确保您可以开始使用posture工具。\n\n```bash\n# Here is the config of posture\nexport POSTURE_PATH={{the path of posture installation}}\nexport PATH=$PATH:${POSTURE_PATH}\n```\n\n这样，之后就可以通过```echo $POSTURE_PATH```命令查看posture的安装目录。\n\n# \u003cspan id=\"3\"\u003e三、如何使用\u003c/span\u003e\n\n## \u003cspan id=\"31\"\u003e1、矫正开发姿势\u003c/span\u003e\n在团队开发中的任何阶段，都可以使用如下命令快速矫正，它会自动对git配置、代码风格等几个方面进行调整，下面会详细介绍。\n\n```bash\ncd {your_project} # notice: not cd posture project !\n\nposture adjust\n```\n\n### \u003cspan id=\"311\"\u003e(1) git配置的调整\n在执行完```adjust```命令时，```posture```会自动执行以下操作，确保大家的git配置保持一致。\n\n```bash\n# 忽略文件权限\ngit config --global --add core.fileMode false\n```\n\n\u003e 使用```git config --global -l```或```git config --global -e```查看配置情况。\n\n### \u003cspan id=\"312\"\u003e(2) 代码风格的调整\n\n在执行完```adjust```命令后，在您的项目根目录下，会生成一个```.editorconfig```文件，它会为您的IDE设置统一的代码规范。\n\n## 2、扫描项目\n在开发的任何阶段，都可以使用如下命令快速扫描我们的任何项目，对一些关键字比如\"密码\"等进行扫描，防止出现安全性问题。\n\n```bash\ncd {your_project} # notice: not cd posture project !\n\nposture scan\n```\n\n在```posture```安装路径下的```.env```配置文件中有定义```scan_keywords```关键字数组，我们把需要检查的关键字输入进去，就可以实现自定义的扫描关键字需求。\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n  \u003cimg width=\"347\" alt=\"image\" src=\"https://github.com/WGrape/posture/assets/35942268/3d9fbdca-32ad-4139-921f-65dc061c7b3f\"\u003e\n  \u003cimg width=\"400\" alt=\"image\" src=\"https://github.com/WGrape/posture/assets/35942268/d6ef41a6-d061-419c-8226-fdd8a29d90d1\"\u003e\n\u003c/details\u003e\n\n## 3、设置全局钩子\n在开发前，请使用如下命令设置全局钩子。这样无论在哪个项目下，当使用git命令时，相应的钩子都会自动工作，实时监督我们在git流程中的操作，一旦出现姿势错误的情况，就会即时发出提醒并中断操作。\n\n```bash\ncd {your_project} # notice: not cd posture project !\n\nposture hook\n```\n\n当需要取消全局钩子时, 执行```unhook```命令即可\n\n```bash\ncd {your_project} # notice: not cd posture project !\n\nposture unhook\n```\n\n\u003e 使用```git config --global -l```或```git config --global -e```查看配置情况。\n\n### \u003cspan id=\"321\"\u003e(1) checkout钩子\u003c/span\u003e\n当使用```git checkout/git switch```命令时，会自动执行checkout钩子，如下图所示。\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n\u003cimg width=\"680\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35942268/190693301-44347c94-2c4f-4d8a-bfcc-2b917ae2d41f.png\"\u003e\n\u003c/details\u003e\n\n### \u003cspan id=\"322\"\u003e(2) pull钩子\u003c/span\u003e\n在使用```git pull```命令时，会自动执行pull钩子（由post-merge钩子实现），如下图所示。\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n  \u003cimg width=\"800\" src=\"https://user-images.githubusercontent.com/35942268/190868050-13348f58-5abe-4da1-b714-f1a3784a6f0c.png\"\u003e\n\u003c/details\u003e\n\n### \u003cspan id=\"323\"\u003e(3) commit钩子\u003c/span\u003e\n当使用```git commit```命令时，会自动执行commit钩子，如下图所示。\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n\u003cimg width=\"800\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35942268/189961812-86357a08-96d9-44d8-848c-557cb35cf2c9.png\"\u003e\n\u003c/details\u003e\n\n如果在主分支（main/master）直接编辑提交代码，会出现如下提醒并中断操作。\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n\u003cimg width=\"800\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35942268/190095654-565a82c1-455e-403d-8e56-adb8c7685b7c.png\"\u003e\n\u003c/details\u003e\n\n提交成功后会触发```post-commit```钩子，自动在```$POSTURE_PATH/storage/```目录下生成一条以天为单位的```commit.${day}.log```commit日志文件，以实现每日工作统计等功能。\n\n```text\n# 日志内容如下\n2021-08-17/10:51:44 posture wgrape test 3exxxxx feat:新增钉钉WebHook\n2021-08-17/10:56:44 posture wgrape test 3exxxxx feat:新增commit日志记录功能\n\n# 每行由6部分组成\n-------------------------------------------------------------\n| date | project | user | branch | commit_id | commitMessage |\n-------------------------------------------------------------\n```\n\n### \u003cspan id=\"324\"\u003e(4) push钩子\u003c/span\u003e\n当使用```git push```命令时，会自动执行push钩子，如下图所示。\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n\u003cimg width=\"800\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35942268/189962394-397e9ab5-a523-405d-9d9e-3eaea0d0d706.png\"\u003e\n\u003c/details\u003e\n\n如果提交了与本地不一致的分支，会出现如下提醒并中断操作。\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n\u003cimg width=\"800\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35942268/189963583-08a02a8d-b04e-401e-aed3-56c88e6ab619.png\"\u003e\n\u003c/details\u003e\n\n# \u003cspan id=\"4\"\u003e四、卸载更新\u003c/span\u003e\n\n## \u003cspan id=\"41\"\u003e1、卸载应用\u003c/span\u003e\n如果需要卸载，在执行完以下命令后，手动删除```$POSTURE_PATH```目录即可。\n\n```bash\ncd $POSTURE_PATH \u0026\u0026 bash ./uninstall.sh\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/35942268/190053831-7310bffb-3fb2-4232-adbc-2e3871f08a4f.png\"\u003e\n\u003c/details\u003e\n\n## \u003cspan id=\"42\"\u003e2、版本更新\u003c/span\u003e\n为保证您的良好使用体验，建议使用最新版的posture工具，执行以下命令即可完成更新。\n\n```bash\nposture update\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e查看使用示例\u003c/summary\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/35942268/190094229-4617b499-458c-4ced-a1b8-20dd0ffc345d.png\"\u003e\n\u003c/details\u003e\n\n# \u003cspan id=\"5\"\u003e五、项目贡献\u003c/span\u003e\n如果您觉得项目有用，欢迎star ！您还可以参考[如何贡献](./.github/CONTRIBUTING.md)文档来共同参与此项目，欢迎加入 ！\n\n\u003cimg src=\"https://contrib.rocks/image?repo=wgrape/cimanager\" \u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwgrape%2Fposture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwgrape%2Fposture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwgrape%2Fposture/lists"}