提交 85ac42b6 编写于 作者: 雪洛's avatar 雪洛

feat: 禁止直接在alpha分支、master分支创建提交

上级 9391249f
npm run check-commit -- $1
const fs = require('fs')
const {
execSync
} = require('child_process')
const message = fs.readFileSync(process.argv[2]).toString('utf8').toLowerCase()
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
if (
(branch === 'master' || branch === 'alpha') &&
!message.startsWith('merge') &&
!message.startsWith('*')
) {
console.log('You are not allowed to commit directly to master or alpha branch')
process.exit(1)
}
......@@ -5,7 +5,7 @@
"version": "1.0.24",
"description": "演示 uni-app x 框架的组件、接口、模板",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"check-commit": "node ./git-hooks/check-commit.cjs"
},
"repository": "https://gitcode.net/dcloud/hello-uni-app-x",
"keywords": [
......
......@@ -13,3 +13,11 @@ uni-app x [开发文档](https://uniapp.dcloud.net.cn/uni-app-x/)
**注意**
- 添加到截图对比测试的页面列表,修改内容涉及到变更,需要在测试平台删除基准图
- 动态内容页面不适合截图对比测试,不要添加到截图对比测试的页面列表中
#### 代码提交
仅dev分支允许创建新的提交,master分支与alpha分支仅允许从其他分支cherry-pick或merge。为防止提交代码到错误的分支,可以通过如下方式创建git hook在提交代码时进行检查。
```bash
npx husky@9.0.11
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册