@@ -90,7 +90,7 @@ pub fn loadConfig(allocator: std.mem.Allocator, shgit_root: []const u8) !Config
9090 return parseConfig (allocator , content );
9191}
9292
93- fn parseConfig (allocator : std.mem.Allocator , content : []const u8 ) ! Config {
93+ pub fn parseConfig (allocator : std.mem.Allocator , content : []const u8 ) ! Config {
9494 // Simple ZON-like parsing for sync_patterns
9595 var cfg = Config {};
9696 var patterns : std .ArrayList (SyncPattern ) = .empty ;
@@ -238,62 +238,3 @@ pub fn initShgitStructure(allocator: std.mem.Allocator, path: []const u8) !void
238238
239239 log .info ("created shgit structure at {s}" , .{path });
240240}
241-
242- test "parseConfig new format" {
243- const content =
244- \\.{
245- \\ .sync_patterns = .{
246- \\ .{
247- \\ .pattern = ".env",
248- \\ .mode = .symlink,
249- \\ },
250- \\ .{
251- \\ .pattern = ".env.local",
252- \\ .mode = .copy,
253- \\ },
254- \\ },
255- \\ .main_repo = "myrepo",
256- \\}
257- ;
258-
259- var cfg = try parseConfig (std .testing .allocator , content );
260- defer cfg .deinit (std .testing .allocator );
261-
262- try std .testing .expectEqual (@as (usize , 2 ), cfg .sync_patterns .len );
263- try std .testing .expectEqualStrings (".env" , cfg .sync_patterns [0 ].pattern );
264- try std .testing .expectEqual (SyncMode .symlink , cfg .sync_patterns [0 ].mode );
265- try std .testing .expectEqualStrings (".env.local" , cfg .sync_patterns [1 ].pattern );
266- try std .testing .expectEqual (SyncMode .copy , cfg .sync_patterns [1 ].mode );
267- try std .testing .expectEqualStrings ("myrepo" , cfg .main_repo .? );
268- }
269-
270- test "parseConfig legacy format" {
271- const content =
272- \\.{
273- \\ .sync_patterns = .{
274- \\ ".env",
275- \\ ".env.local",
276- \\ },
277- \\ .main_repo = "myrepo",
278- \\}
279- ;
280-
281- var cfg = try parseConfig (std .testing .allocator , content );
282- defer cfg .deinit (std .testing .allocator );
283-
284- try std .testing .expectEqual (@as (usize , 2 ), cfg .sync_patterns .len );
285- try std .testing .expectEqualStrings (".env" , cfg .sync_patterns [0 ].pattern );
286- try std .testing .expectEqual (SyncMode .symlink , cfg .sync_patterns [0 ].mode );
287- try std .testing .expectEqualStrings (".env.local" , cfg .sync_patterns [1 ].pattern );
288- try std .testing .expectEqual (SyncMode .symlink , cfg .sync_patterns [1 ].mode );
289- try std .testing .expectEqualStrings ("myrepo" , cfg .main_repo .? );
290- }
291-
292- test "parseConfig empty" {
293- const content = ".{\n }\n " ;
294- var cfg = try parseConfig (std .testing .allocator , content );
295- defer cfg .deinit (std .testing .allocator );
296-
297- try std .testing .expectEqual (@as (usize , 0 ), cfg .sync_patterns .len );
298- try std .testing .expect (cfg .main_repo == null );
299- }
0 commit comments