Skip to content

Commit 11762e5

Browse files
authored
Update README.md
1 parent 8a381d3 commit 11762e5

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,63 @@
1-
# @codegenius/git-user-plugin
1+
# @codegenius/git-user-plugin
2+
3+
设置或校验 `git user` 信息是否规范, 支持命令模式和 **API** 模式;
4+
5+
使用场景: 用于校验那些不应该出现的邮箱地址会名称出现在 `git` 提交记录中, 常见的使用公司内部邮箱提交 `github` 的开源项目, 这通常是不允许的.
6+
7+
### 命令模式
8+
9+
```bash
10+
# 在默认规则下设置 email 信息
11+
codeg gituser -e [email protected]
12+
13+
# 在指定规则下设置 email 信息
14+
codeg gituser -e [email protected] --rule-email '^[a-zA-Z0-9._%+-]+@(qq)\.(com)$'
15+
```
16+
17+
```bash
18+
# 在默认规则下校验 user 和 email 信息
19+
codeg gituser
20+
21+
# 在指定规则下校验 user 和 email 信息
22+
codeg gituser --rule-email '^[a-zA-Z0-9._%+-]+@(qq)\.(com)$'
23+
```
24+
25+
| 选项 | 描述 |
26+
| ----------------------- | ------------------------------------ |
27+
| -n, --name \<name\> | 设置 user.name |
28+
| -e, --email \<email\> | 设置 user.email |
29+
| --rule-name \<regexp\> | 设置 user.name 匹配规则(转义字符串) |
30+
| --rule-email \<regexp\> | 设置 user.email 匹配规则(转义字符串) |
31+
32+
- **--rule-name 默认 :** `[\s\S]*`
33+
- **--rule-email 默认 :** `^[a-zA-Z0-9._%+-]+@(163|qq|126|139|sina|sohu|yeah|gmail)\.(com|net)$`
34+
35+
### API 模式
36+
37+
```typescript
38+
import { setGitUserName, setGitUserEmail, checkGitUserInfo } from "code-genius";
39+
40+
(async () => {
41+
await setGitUserName("OSpoon", "[\\s\\S]*");
42+
await setGitUserEmail(
43+
44+
"^[a-zA-Z0-9._%+-]+@(gmail)\\.(com)$"
45+
);
46+
await checkGitUserInfo("[\\s\\S]*", "^[a-zA-Z0-9._%+-]+@(gmail)\\.(com)$");
47+
})();
48+
```
49+
50+
### 配置文件
51+
52+
```typescript
53+
# 覆盖默认的 `gituser` 配置
54+
import { defineConfig } from "code-genius";
55+
56+
export default defineConfig({
57+
commands: {
58+
gituser: {
59+
ruleEmail: "^[a-zA-Z0-9._%+-]+@(gmail)\\.(com)$",
60+
},
61+
},
62+
});
63+
```

0 commit comments

Comments
 (0)