-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample-config.toml
More file actions
230 lines (182 loc) · 6.55 KB
/
Copy pathexample-config.toml
File metadata and controls
230 lines (182 loc) · 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# auto-git-config Configuration Example
# ======================================
#
# This file demonstrates all configuration options available.
# Copy this file to ~/.config/auto-git-config/config.toml and customize.
version = "1"
# =============================================================================
# Settings
# =============================================================================
[settings]
# Enable caching of resolved configurations for faster execution
cache_enabled = true
# Cache time-to-live in seconds (default: 300 = 5 minutes)
cache_ttl_seconds = 300
# Default remote to check for remote-based rules (default: "origin")
default_remote = "origin"
# Directory for generated includeIf config files
# (default: ~/.config/auto-git-config/gitconfig.d)
includeif_dir = "~/.config/auto-git-config/gitconfig.d"
# Enable debug logging
debug = false
# =============================================================================
# Default Configuration
# =============================================================================
# Applied when no rules match, before falling back to global git config.
# This is optional - if not set, global git config is used directly.
[default.user]
name = "Default User"
email = "default@example.com"
# =============================================================================
# Rules
# =============================================================================
# Rules are evaluated in precedence order:
# 1. Explicit per-repository rules (repo_path) - highest precedence
# 2. Remote-based rules (remote_host, remote_url, remote_org)
# 3. Path-based rules (path_prefix, folder_name, etc.) - lowest precedence
#
# Within each category:
# - Higher priority values are checked first
# - If priorities are equal, rules are checked in definition order
#
# Multiple conditions in a single rule are AND-ed together.
# -----------------------------------------------------------------------------
# Example 1: Match by GitHub host
# -----------------------------------------------------------------------------
[[rule]]
name = "github-personal"
priority = 0
[rule.match]
remote_host = "github.com"
[rule.config.user]
name = "Alice Developer"
email = "alice@personal.dev"
# Disable GPG signing for personal projects
[rule.config.commit]
gpgsign = false
# -----------------------------------------------------------------------------
# Example 2: Match by GitLab host
# -----------------------------------------------------------------------------
[[rule]]
name = "gitlab-work"
priority = 0
[rule.match]
remote_host = "gitlab.com"
[rule.config.user]
name = "Alice WorkAccount"
email = "alice@company.com"
# Enable GPG signing for work
[rule.config.commit]
gpgsign = true
# -----------------------------------------------------------------------------
# Example 3: Match work projects by path (higher priority than remote)
# -----------------------------------------------------------------------------
[[rule]]
name = "work-directory"
priority = 10 # Higher than remote-based rules
[rule.match]
path_prefix = "~/work"
[rule.config.user]
name = "Alice WorkAccount"
email = "alice@company.com"
signingkey = "ABCD1234EFGH5678"
[rule.config.commit]
gpgsign = true
# -----------------------------------------------------------------------------
# Example 4: Match by organization on GitHub
# -----------------------------------------------------------------------------
[[rule]]
name = "myorg-github"
priority = 5 # Between path and remote
[rule.match]
remote_host = "github.com"
remote_org = "my-organization"
[rule.config.user]
name = "Alice OrgMember"
email = "alice@my-organization.org"
# -----------------------------------------------------------------------------
# Example 5: Match specific repository (highest priority)
# -----------------------------------------------------------------------------
[[rule]]
name = "special-project"
priority = 100 # Highest priority - always wins if matched
[rule.match]
repo_path = "~/projects/super-secret-project"
[rule.config.user]
name = "Anonymous Contributor"
email = "anon-12345@users.noreply.github.com"
signingkey = "SPECIAL-KEY-1234"
[rule.config.commit]
gpgsign = true
# -----------------------------------------------------------------------------
# Example 6: Match self-hosted GitLab with wildcard
# -----------------------------------------------------------------------------
[[rule]]
name = "company-gitlab"
priority = 0
[rule.match]
remote_host = "*.company.internal"
[rule.config.user]
name = "Alice InternalDev"
email = "alice@company.internal"
# -----------------------------------------------------------------------------
# Example 7: Match by folder name pattern (regex)
# -----------------------------------------------------------------------------
[[rule]]
name = "oss-contributions"
priority = 0
[rule.match]
folder_pattern = "^(contrib|oss|opensource)-.*"
[rule.config.user]
name = "Alice OSS"
email = "alice.oss@gmail.com"
# -----------------------------------------------------------------------------
# Example 8: Match by remote URL pattern (regex)
# -----------------------------------------------------------------------------
[[rule]]
name = "archived-repos"
priority = 0
[rule.match]
remote_url = ".*github\\.com.*/archived-.*"
[rule.config.user]
name = "Archivist"
email = "archive@example.com"
# -----------------------------------------------------------------------------
# Example 9: Combined conditions (AND logic)
# -----------------------------------------------------------------------------
[[rule]]
name = "work-github"
priority = 15
[rule.match]
# Both conditions must match
remote_host = "github.com"
path_prefix = "~/work"
[rule.config.user]
name = "Alice WorkGitHub"
email = "alice.work@company.com"
# -----------------------------------------------------------------------------
# Example 10: Using extra config for arbitrary git settings
# -----------------------------------------------------------------------------
[[rule]]
name = "custom-settings"
priority = 0
[rule.match]
folder_name = "experiment"
[rule.config.user]
email = "experiment@example.com"
# Set arbitrary git config values
[rule.config.extra]
"pull.rebase" = "true"
"push.autoSetupRemote" = "true"
"init.defaultBranch" = "main"
# -----------------------------------------------------------------------------
# Example 11: Disabled rule (for temporary disabling without deletion)
# -----------------------------------------------------------------------------
[[rule]]
name = "old-work"
enabled = false # This rule is disabled
priority = 0
[rule.match]
path_prefix = "~/old-work"
[rule.config.user]
email = "old@company.com"