@@ -108,13 +108,13 @@ func Test_diffWorktrees(t *testing.T) {
108
108
Remote :
"[email protected] :path/to/repo1.git" ,
109
109
Root : "/root" , Interval : 10 * time .Second , GitGC : "always" ,
110
110
Worktrees : []mirror.WorktreeConfig {
111
- {Link : "link" , Ref : "master" , Pathspec : "" },
112
- {Link : "link2" , Ref : "other-branch" , Pathspec : "path" },
111
+ {Link : "link" , Ref : "master" , Pathspecs : nil },
112
+ {Link : "link2" , Ref : "other-branch" , Pathspecs : [] string { "path1" , "path2/**/*.yaml" , "*.c" } },
113
113
},
114
114
},
115
115
wantNewWTCs : []mirror.WorktreeConfig {
116
116
{Link : "link" , Ref : "master" },
117
- {Link : "link2" , Ref : "other-branch" , Pathspec : "path" },
117
+ {Link : "link2" , Ref : "other-branch" , Pathspecs : [] string { "path1" , "path2/**/*.yaml" , "*.c" } },
118
118
},
119
119
wantRemovedWTs : nil ,
120
120
},
@@ -124,44 +124,68 @@ func Test_diffWorktrees(t *testing.T) {
124
124
Remote :
"[email protected] :path/to/repo1.git" ,
125
125
Root : "/root" , Interval : 10 * time .Second , GitGC : "always" ,
126
126
Worktrees : []mirror.WorktreeConfig {
127
- {Link : "link" , Ref : "master" , Pathspec : "" },
128
- {Link : "link2" , Ref : "other-branch" , Pathspec : "path" },
127
+ {Link : "link" , Ref : "master" , Pathspecs : nil },
128
+ {Link : "link2" , Ref : "other-branch" , Pathspecs : []string {"path1" , "path2/**/*.yaml" , "*.c" }},
129
+ {Link : "link3" , Ref : "other-branch" , Pathspecs : []string {"path" }},
129
130
},
130
131
},
131
132
newRepoConf : & mirror.RepositoryConfig {
132
133
Remote :
"[email protected] :path/to/repo1.git" ,
133
134
Root : "/root" , Interval : 10 * time .Second , GitGC : "always" ,
134
135
Worktrees : []mirror.WorktreeConfig {
135
- {Link : "link" , Ref : "master" , Pathspec : "new-path" },
136
- {Link : "link2" , Ref : "new-branch" , Pathspec : "path" },
136
+ {Link : "link" , Ref : "master" , Pathspecs : []string {"new-path" }},
137
+ {Link : "link2" , Ref : "new-branch" , Pathspecs : []string {"path1" , "path2/**/*.yaml" , "*.c" }},
138
+ {Link : "link3" , Ref : "other-branch" , Pathspecs : []string {"path" , "new-path" }},
137
139
},
138
140
},
139
141
wantNewWTCs : []mirror.WorktreeConfig {
140
- {Link : "link" , Ref : "master" , Pathspec : "new-path" },
141
- {Link : "link2" , Ref : "new-branch" , Pathspec : "path" },
142
+ {Link : "link" , Ref : "master" , Pathspecs : []string {"new-path" }},
143
+ {Link : "link2" , Ref : "new-branch" , Pathspecs : []string {"path1" , "path2/**/*.yaml" , "*.c" }},
144
+ {Link : "link3" , Ref : "other-branch" , Pathspecs : []string {"path" , "new-path" }},
142
145
},
143
- wantRemovedWTs : []string {"link" , "link2" },
146
+ wantRemovedWTs : []string {"link" , "link2" , "link3" },
147
+ },
148
+ {
149
+ name : "rearrange-path" ,
150
+ initialRepoConf : & mirror.RepositoryConfig {
151
+ Remote :
"[email protected] :path/to/repo1.git" ,
152
+ Root : "/root" , Interval : 10 * time .Second , GitGC : "always" ,
153
+ Worktrees : []mirror.WorktreeConfig {
154
+ {Link : "link" , Ref : "master" , Pathspecs : []string {"a" , "b/**/c" }},
155
+ {Link : "link2" , Ref : "other-branch" , Pathspecs : []string {"path1" , "path2/**/*.yaml" , "*.c" }},
156
+ },
157
+ },
158
+ newRepoConf : & mirror.RepositoryConfig {
159
+ Remote :
"[email protected] :path/to/repo1.git" ,
160
+ Root : "/root" , Interval : 10 * time .Second , GitGC : "always" ,
161
+ Worktrees : []mirror.WorktreeConfig {
162
+ {Link : "link" , Ref : "master" , Pathspecs : []string {"b/**/c" , "a" }},
163
+ {Link : "link2" , Ref : "other-branch" , Pathspecs : []string {"path1" , "*.c" , "path2/**/*.yaml" }},
164
+ },
165
+ },
166
+ wantNewWTCs : nil ,
167
+ wantRemovedWTs : nil ,
144
168
},
145
169
{
146
170
name : "add_new_link" ,
147
171
initialRepoConf : & mirror.RepositoryConfig {
148
172
Remote :
"[email protected] :path/to/repo1.git" ,
149
173
Root : "/root" , Interval : 10 * time .Second , GitGC : "always" ,
150
174
Worktrees : []mirror.WorktreeConfig {
151
- {Link : "link" , Ref : "master" , Pathspec : "" },
152
- {Link : "link2" , Ref : "other-branch" , Pathspec : "path" },
175
+ {Link : "link" , Ref : "master" , Pathspecs : nil },
176
+ {Link : "link2" , Ref : "other-branch" , Pathspecs : [] string { "path1" , "path2/**/*.yaml" , "*.c" } },
153
177
},
154
178
},
155
179
newRepoConf : & mirror.RepositoryConfig {
156
180
Remote :
"[email protected] :path/to/repo1.git" ,
157
181
Root : "/root" , Interval : 10 * time .Second , GitGC : "always" ,
158
182
Worktrees : []mirror.WorktreeConfig {
159
- {Link : "link" , Ref : "master" , Pathspec : "" },
160
- {Link : "link3" , Ref : "other-branch" , Pathspec : "path" },
183
+ {Link : "link" , Ref : "master" , Pathspecs : nil },
184
+ {Link : "link3" , Ref : "other-branch" , Pathspecs : [] string { "path1" , "path2/**/*.yaml" , "*.c" } },
161
185
},
162
186
},
163
187
wantNewWTCs : []mirror.WorktreeConfig {
164
- {Link : "link3" , Ref : "other-branch" , Pathspec : "path" },
188
+ {Link : "link3" , Ref : "other-branch" , Pathspecs : [] string { "path1" , "path2/**/*.yaml" , "*.c" } },
165
189
},
166
190
wantRemovedWTs : []string {"link2" },
167
191
},
0 commit comments