chiark / gitweb /
tb create sort of works
[topbloke.git] / Topbloke.pm
index b1303e17707506748a1c3b171c207f8c097e6667..0921e9cb9c364717f88ecc89371dc9205bbdd878 100644 (file)
@@ -20,6 +20,7 @@ BEGIN {
                      git_config git_dir chdir_toplevel
                      current_branch parse_branch_spec
                      setup_config check_no_unwanted_metadata
+                     flagsfile_add_flag
                      wf_start wf wf_abort wf_done wf_contents);
     %EXPORT_TAGS = ( );
     @EXPORT_OK   = qw();
@@ -264,6 +265,22 @@ sub check_no_unwanted_metadata ($) {
                           qw(.topbloke));
 }
 
+sub flagsfile_add_flag ($$) {
+    # works on "deps" too
+    my ($flagsfile, $flag) = @_;
+    my $wf = wf_start(".topbloke/$flagsfile");
+    open FI, '<', ".topbloke/$flagsfile" or die $!;
+    while (<FI>) {
+       chomp or die;
+       die "flag $flag already set in $flagsfile ?!" if $_ eq $flag;
+       wf($wf, "$_\n");
+    }
+    FI->error and die $!;
+    close FI or die $!;
+    wf($wf, "$flag\n");
+    wf_done($wf);
+}
+
 sub wf_start ($) {
     my ($path) = @_;
     my $fh = new IO::File "$path.tmp", '>' or die "create $path.tmp: $!\n";