All checks were successful
Build and Release / build-and-test (arm64, alpine) (push) Successful in 30s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 42s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 41s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 54s
Build and Release / release (push) Has been skipped
- 重构配置方式:使用 params.conf 替代命令行参数 - postinst 自动创建配置文件,升级时保护用户配置 - 初始化 llmdoc 文档系统(概述、架构、指南、参考) - 创建 README.md 和配置指南 - 提供完整的配置模板示例 配置文件优势:升级安全、集中管理、易于维护
1.2 KiB
1.2 KiB
编码规范
Shell 脚本规范
基本原则
- 使用
#!/bin/sh作为脚本头 - 遵循 POSIX shell 标准
- 避免使用 Bash 特定语法
缩进与格式
- 使用 4 个空格缩进
- 每个代码块使用一致的缩进
- 长行使用
\换行
变量使用
- 使用双引号包裹变量:
"$VARIABLE" - 避免未定义变量
- 使用
${VARIABLE:-default}设置默认值
示例
#!/bin/sh
set -eu
# 变量定义
P2POOL_VERSION="${1:-v4.9.1}"
OUTPUT_DIR="${2:-./output}"
# 函数定义
build_p2pool() {
local arch="$1"
local distro="$2"
docker buildx build --pull \
--platform "linux/${arch}" \
--build-arg "P2POOL_VERSION=${P2POOL_VERSION}" \
--output "type=local,dest=${OUTPUT_DIR}" \
-f "docker/Dockerfile.${distro}" .
}
# 主逻辑
main() {
build_p2pool "amd64" "alpine"
}
main "$@"
Docker 文件规范
- 遵循多阶段构建
- 尽量减少镜像层数
- 使用多架构构建
- 避免在构建过程中下载可变内容
Git 提交规范
- 使用清晰、简洁的提交信息
- 提交信息应描述为什么做这个改动
- 使用动词开头:添加(Add)、修复(Fix)、优化(Improve)等