@@ -14,7 +14,7 @@ pub const DepType = enum {
1414 hg , // https://www.mercurial-scm.org/
1515 http , // https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
1616 // svn, // https://subversion.apache.org/
17- // fossil, // https://fossil-scm.org/
17+ fossil , // https://fossil-scm.org/
1818 // cvs, // https://nongnu.org/cvs/
1919 // darcs, // http://darcs.net/
2020 // //
@@ -53,6 +53,10 @@ pub const DepType = enum {
5353 u .assert ((try u .run_cmd (dpath , &.{ "tar" , "-xf" , f , "-C" , "." })) == 0 , "un-tar {s} failed" , .{f });
5454 }
5555 },
56+ .fossil = > {
57+ try std .fs .cwd ().makePath (dpath );
58+ u .assert ((try u .run_cmd (dpath , &.{ "fossil" , "open" , rpath })) == 0 , "fossil open {s} failed" , .{rpath });
59+ }
5660 }
5761 }
5862
@@ -73,6 +77,10 @@ pub const DepType = enum {
7377 .http = > {
7478 //
7579 },
80+ .fossil = > {
81+ u .assert ((try u .run_cmd (dpath , &.{ "fossil" , "pull" })) == 0 , "fossil pull failed" , .{});
82+ u .assert ((try u .run_cmd (dpath , &.{ "fossil" , "update" })) == 0 , "fossil update failed" , .{});
83+ },
7684 }
7785 }
7886
@@ -86,6 +94,7 @@ pub const DepType = enum {
8694 .git = > try std .fmt .allocPrint (gpa , "commit-{s}" , .{(try u .git_rev_HEAD (gpa , mdir ))}),
8795 .hg = > "" ,
8896 .http = > "" ,
97+ .fossil = > getFossilCheckout (mpath ),
8998 };
9099 }
91100};
@@ -103,3 +112,21 @@ pub const GitVersionType = enum {
103112 };
104113 }
105114};
115+
116+
117+ fn getFossilCheckout (mpath : []const u8 ) ! []const u8 {
118+ const result = try u .run_cmd_raw (mpath , &.{"fossil" , "status" });
119+ gpa .free (result .stderr );
120+ defer gpa .free (result .stdout );
121+
122+ var iter = std .mem .tokenize (u8 , result .stdout , " \n " );
123+ while (iter .next ()) | tk | {
124+ if (std .mem .eql (u8 , tk , "checkout:" )) {
125+ const co = iter .next () orelse return "" ;
126+ return try gpa .dupe (u8 , co );
127+ }
128+ }
129+
130+ return "" ;
131+ }
132+
0 commit comments