Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# -- Project information -----------------------------------------------------

project = 'OnlineNote'
copyright = '2022-2023, Hui Zhou'
copyright = '2022-2025, Hui Zhou'
author = 'Hui Zhou'

# The full version, including alpha/beta/rc tags
Expand Down
38 changes: 34 additions & 4 deletions docs/source/development/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ git fetch origin --tags
2. 对于每一个冲突文件,使用 --theirs 选项来检出 main 的版本。
:::{note}

- 在合并操作中,--theirs 代表要合并进来的分支(即 dev/matmaster)的版本。
- 在合并操作中,--theirs 代表要合并进来的分支(即 main)的版本。
- --ours 代表当前所在的分支(即 test)的版本。

:::
Expand Down Expand Up @@ -333,7 +333,7 @@ git cz
COMMIT_MSG_FILE=$1

# 允许的前缀列表
PREFIXES="feat|fix|docs|style|refactor|chore|perf|test|ci|revert"
PREFIXES="feat|fix|docs|style|refactor|build|chore|perf|test|ci|revert"

# 读取提交消息的第一行
COMMIT_MSG=$(head -n 1 "$COMMIT_MSG_FILE")
Expand All @@ -353,7 +353,7 @@ chmod +x .git/hooks/commit-msg

### Commit 前操作

1. 创建 `.git/hooks/commit-msg` 文件:
1. 创建 `.git/hooks/pre-commit` 文件:

```bash
#!/bin/bash
Expand Down Expand Up @@ -384,6 +384,30 @@ exit 0
chmod +x .git/hooks/pre-commit
```

### 本地保护 main 或 master 分支

1. 创建 `.git/hooks/pre-push`

```bash
#!/bin/bash

protected_branches=("main" "master")
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')

if [[ " ${protected_branches[@]} " =~ " ${current_branch} " ]]; then
echo "ERROR: You are not allowed to push directly to the $current_branch branch. Use a feature branch and create a Pull Request."
exit 1
fi

exit 0
```

2. 将这个钩子脚本设置为可执行:

```bash
chmod +x .git/hooks/pre-push
```

## 使用 Git 模版来初始化 hook 钩子

1. **创建一个模板目录:**
Expand Down Expand Up @@ -531,7 +555,13 @@ oco config set OCO_AI_PROVIDER='azure' OCO_MODEL='gpt-4o'
oco config set OCO_API_KEY=xxx
```

3. 使用 oco 命令生成 commit
3. 【可选】关闭自动 push

```bash
oco config set OCO_GITPUSH=false
```

4. 使用 oco 命令生成 commit

```bash
git add .
Expand Down
Loading