Skip to content

Commit

Permalink
doc: make doc better
Browse files Browse the repository at this point in the history
  • Loading branch information
WGrape committed Feb 28, 2024
1 parent ced9668 commit 93ac252
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 72 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ cd {your_project} # notice: not cd posture project !
posture adjust
```

### <span id="311">(1) git配置
在执行完```adjust```命令时,```posture```会自动执行以下操作,确保git配置保持一致
### <span id="311">(1) git配置调整
在执行完```adjust```命令时,```posture```会自动执行以下操作,确保大家的git配置保持一致

```bash
# 忽略文件权限
git config --global --add core.fileMode false
```

### <span id="312">(2) 代码规范
### <span id="312">(2) 代码风格调整

在执行完```adjust```命令后,在您的项目根目录下,会生成一个```.editorconfig```文件,它会为您的IDE设置统一的代码规范。

Expand Down
63 changes: 0 additions & 63 deletions include/function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,66 +110,3 @@ check_config(){
exit 1
fi
}

# start to adjust
adjust(){
if ! check_config; then
print_error "adjust failed: check_config"
exit 1
fi

echo "正在调整中 (posture is adjusting)..."

# git ignore fileMode
git config --global --add core.fileMode false

# copy .editorconfig.template to your project
cp $POSTUREPATH/include/editor/.editorconfig.template ./

print_ok "> 完成 (done)"
}

# start to set the global hook
hook(){
if [ $1 == "" ]; then
print_error "缺少目录参数 (miss the directory param)"
exit 1
fi

projectDir=$1
git config --global core.hooksPath ${projectDir}/include/hooks
chmod a+x ${projectDir}/include/hooks/commit-msg
chmod a+x ${projectDir}/include/hooks/post-checkout
chmod a+x ${projectDir}/include/hooks/post-merge
chmod a+x ${projectDir}/include/hooks/pre-commit
chmod a+x ${projectDir}/include/hooks/pre-push

# 如果个别项目不需要使用全局的Hook, 可以在项目的根目录下重新配置git hooksPath: git config core.hooksPath .git/hooks
print_ok "hook successfully !"
print_warn "If your other projects don't need require the global Hooks, they can be reconfigured in the root directory of your other projects: git config core.hooksPath .git/hooks"
}

# start to cancel the global hook
unhook(){
git config --global core.hooksPath false
}

# update your posture version
update_version(){
currentDir=$(pwd)
cd $POSTUREPATH && git pull && cd $currentDir
# 判断是否拉取成功
if [ $? -ne 0 ]; then
print_error "版本更新至最新版本失败 (Failed to update the version to the latest version)"
exit 1
fi
print_ok "版本更新至最新版本成功 (update to latest version successfully)"
}

# show status
status(){
echo "The list of configuration"
echo "> lang = ${lang}"
echo "The list of states"
echo "> version = ${version}"
}
78 changes: 72 additions & 6 deletions posture
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,86 @@ if [ "${POSTUREPATH}" == "" ]; then
fi
. $POSTUREPATH/include/function.sh

# start to adjust
adjust(){
if ! check_config; then
print_error "adjust failed: check_config"
exit 1
fi

echo "正在调整中 (posture is adjusting)..."

# 1. git adjust
# git ignore fileMode
git config --global --add core.fileMode false

# 2. code style adjust
# copy .editorconfig.template to your project
cp $POSTUREPATH/include/editor/.editorconfig.template ./

print_ok "> 完成 (done)"
}

# start to set the global hook
hook(){
if [ $1 == "" ]; then
print_error "缺少目录参数 (miss the directory param)"
exit 1
fi

projectDir=$1
git config --global core.hooksPath ${projectDir}/include/hooks
chmod a+x ${projectDir}/include/hooks/commit-msg
chmod a+x ${projectDir}/include/hooks/post-checkout
chmod a+x ${projectDir}/include/hooks/post-merge
chmod a+x ${projectDir}/include/hooks/pre-commit
chmod a+x ${projectDir}/include/hooks/pre-push

# 如果个别项目不需要使用全局的Hook, 可以在项目的根目录下重新配置git hooksPath: git config core.hooksPath .git/hooks
print_ok "hook successfully !"
print_warn "If your other projects don't need require the global Hooks, they can be reconfigured in the root directory of your other projects: git config core.hooksPath .git/hooks"
}

# start to cancel the global hook
unhook(){
git config --global core.hooksPath false
}

# update your posture version
update_version(){
currentDir=$(pwd)
cd $POSTUREPATH && git pull && cd $currentDir
# 判断是否拉取成功
if [ $? -ne 0 ]; then
print_error "版本更新至最新版本失败 (Failed to update the version to the latest version)"
exit 1
fi
print_ok "版本更新至最新版本成功 (update to latest version successfully)"
}

# show status
status(){
echo "The list of configuration"
echo "> lang = ${lang}"
echo "The list of states"
echo "> version = ${version}"
}


COMMAND=$1
if [ "${COMMAND}" == "hook" ]; then
if [ "${COMMAND}" == "adjust" ]; then
# requirement: cd to your project, then run cmd: posture adjust
adjust
elif [ "${COMMAND}" == "hook" ]; then
# requirement: cd to your project, then run cmd: posture hook
hook $POSTUREPATH
elif [ "${COMMAND}" == "unhook" ]; then
# requirement: cd to your project, then run cmd: posture unhook
unhook
elif [ "${COMMAND}" == "adjust" ]; then
# requirement: cd to your project, then run cmd: posture adjust
adjust
elif [ "${COMMAND}" == "status" ]; then
status
elif [ "${COMMAND}" == "update" ]; then
update_version
elif [ "${COMMAND}" == "status" ]; then
status
elif [ "${COMMAND}" == "help" ] || [ "${COMMAND}" == "" ]; then
print_logo

Expand Down

0 comments on commit 93ac252

Please sign in to comment.