# posture **Repository Path**: WGrape/posture ## Basic Information - **Project Name**: posture - **Description**: A powerful and efficient tool for developing and managing your project / 一个强大且高效的项目开发管理工具 - **Primary Language**: Shell - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-09-15 - **Last Updated**: 2022-09-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

image

A lightweight and extensible tool for supervising and correcting of development posture

一个轻量可扩展的开发姿势监督与矫正工具

目录 - [一、项目介绍](#1) - [二、快速安装](#2) - [三、如何使用](#3) -       [1、调整代码格式](#31) -       [2、设置全局钩子](#32) -            [(1) checkout钩子](#321) -            [(2) pull钩子](#322) -            [(3) commit钩子](#323) -            [(4) push钩子](#324) - [四、卸载更新](#4) -       [1、卸载应用](#41) -       [2、版本更新](#42) - [五、项目贡献](#5)
# 一、项目介绍 posture是一个轻量可扩展的开发姿势监督与矫正工具,让您快速开始以正确的规范编写和管理代码,解决团队开发时代码百花齐放、Git误操作等一系列开发中的"姿势不正确"问题。 > 关于更多背景细节请阅读文章[《以正确的姿势编写和管理代码》](https://github.com/WGrape/Blog/issues/260) # 二、快速安装 您可以先通过以下命令完成下载安装操作,如果出现```install successfully```提示,则说明安装成功。 ```bash git clone https://github.com/WGrape/posture.git && cd posture && bash ./install.sh ``` ![image](https://user-images.githubusercontent.com/35942268/190054375-4280aead-411a-404c-b068-c71da4241528.png) 在安装成功后,会在您的```~/.bash_profile```文件中写入如下内容,自动创建```$POSTUREPATH```变量并添加到```$PATH```变量中,以确保您可以开始使用posture工具。 ```bash # Here is the configurations of posture export POSTUREPATH={{the path of posture installation}} export PATH=$PATH:${POSTUREPATH} ``` # 三、如何使用 ## 1、调整代码格式 在团队开发前,需要先统一调整代码规范。工具支持```go/php/java```三种语言的代码规范设置,在```config/config.sh```文件中配置```lang```项目语言,然后切至您的项目目录下,再使用如下命令即可。 ```bash posture adjust ``` ## 2、设置全局钩子 通过如下命令即可设置全局钩子,这样无论在哪个项目下,在使用```git checkout/git commit/git push```等命令时,这些钩子都会自动工作,帮您解决git误操作等问题。 ```bash posture sethook ``` ### (1) checkout钩子 当使用```git checkout```时,会自动执行checkout钩子,如下图所示。 image ### (2) pull钩子 在使用```git pull```时,会自动执行pull钩子(由post-merge钩子实现),如下图所示。 ### (3) commit钩子 当使用```git commit```时,会自动执行commit钩子,如下图所示。 image 如果在主分支(main/master)直接编辑提交代码,会出现如下报错。 image 提交成功后会触发```post-commit```钩子,自动在```$POSTUREPATH/storage/```目录下生成一条以天为单位的```commit.${day}.log```commit日志文件,以实现每日工作统计等功能。 ```text # 日志内容如下 2021-08-17/10:51:44 posture wgrape test 3exxxxx feat:新增钉钉WebHook 2021-08-17/10:56:44 posture wgrape test 3exxxxx feat:新增commit日志记录功能 # 每行由6部分组成 ------------------------------------------------------------- | date | project | user | branch | commitId | commitMessage | ------------------------------------------------------------- ``` ### (4) push钩子 当使用```git push```时,会自动执行push钩子,如下图所示。 image 如果提交了与本地不一致的分支,会出现如下报错。 image # 四、卸载更新 ## 1、卸载应用 如果需要卸载,在执行完以下命令后,手动删除```$POSTUREPATH```目录即可。 ```bash cd $POSTUREPATH && bash ./uninstall.sh ``` ![image](https://user-images.githubusercontent.com/35942268/190053831-7310bffb-3fb2-4232-adbc-2e3871f08a4f.png) ## 2、版本更新 为保证您的良好使用体验,建议使用最新版的posture工具,执行以下命令即可完成更新。 ```bash posture update ``` ![image](https://user-images.githubusercontent.com/35942268/190094229-4617b499-458c-4ced-a1b8-20dd0ffc345d.png) # 五、项目贡献