chiark / gitweb /
tb create sort of works
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Jan 2012 18:16:31 +0000 (18:16 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Jan 2012 18:16:31 +0000 (18:16 +0000)
Topbloke.pm
tb-create.pl

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";
index 831fa101b94eed1e46143135d1cc3122c70217a4..f56764bc1a8c83678c65ab3488f09140279542aa 100755 (executable)
@@ -110,7 +110,7 @@ meta_and_stage('deps', "# not applicable\n");
 meta_and_stage('flags', '');
 
 if ($current->{Kind} eq 'foreign') {
-    meta_and_stage('included', $current->{DepSpec});
+    meta_and_stage('included', $current->{DepSpec}."\n");
     meta_and_stage('pflags', '');
 }
 
@@ -142,12 +142,7 @@ stage_meta('msg');
 meta_and_stage('deps', "$current->{DepSpec}\n");
 # we inherit empty flags from the base branch
 
-open I, '>>', ".topbloke/included" or die $!;
-print I "$newbranch\n";
-close I or die $!;
+flagsfile_add_flag('included',$newbranch);
 stage_meta('included');
 
 run_git(qw(commit -q -m), "create branch $spec->{Nick}\n$newbranch\n");
-
-
-INCLUDED IS WRONG MISSING NEWLINE