# implicitly uses $main::us
%EXPORT_TAGS = ( policyflags => [qw(NOFFCHECK FRESHREPO NOCOMMITCHECK)],
playground => [qw(record_maindir $maindir $local_git_cfg
- fresh_playground $playground)]);
+ fresh_playground $playground
+ ensure_a_playground)]);
@EXPORT_OK = ( @{ $EXPORT_TAGS{policyflags} },
@{ $EXPORT_TAGS{playground} } );
}
# createing different playgrounds; but $playground global can
# refer only to one, obv.
#
+# ensure_a_playground SUBDIR_PATH_COMPONENTS
+# like fresh_playground except:
+# merely ensures the directory exists; does not delete an existing one
+# never sets global $playground
+#
# then can use
#
# changedir $playground
our $playground;
-sub fresh_playground ($) {
+sub ensure_a_playground_parent ($) {
my ($spc) = @_;
record_maindir();
$spc = ".git/$spc";
my $parent = dirname $spc;
mkdir $parent or $!==EEXIST or fail "failed to mkdir $parent: $!";
+ return $spc;
+}
+
+sub ensure_a_playground ($) {
+ my ($spc) = @_;
+ $spc = ensure_a_playground_parent $spc;
+ mkdir $spc or $!==EEXIST or fail "failed to mkdir a playground $spc: $!";
+ return $spc;
+}
+
+sub fresh_playground ($) {
+ my ($spc) = @_;
+ $spc = ensure_a_playground_parent $spc;
rmtree $spc;
mkdir $spc or die "$spc $!";
return $playground = "$maindir/$spc";