diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-08-02 18:34:02 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-08-03 09:57:52 +0100 |
commit | 9b34c3e59ee77136f100c2514524e841c4b30eab (patch) | |
tree | c97a2972ab8a24d19af3cdc405b46499ac5f7b65 /Debian | |
parent | 15b1da549c58aed4425934594ac5fdd91222aeed (diff) |
playground refactoring: Dgit.pm: Provide ensure_a_playground
dgit wants to make a lot of temporary things in .git/dgit.
That's like a playground, but dgit doesn't want it wiped.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'Debian')
-rw-r--r-- | Debian/Dgit.pm | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index 473c01e..de37261 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -64,7 +64,8 @@ BEGIN { # 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} } ); } @@ -491,6 +492,11 @@ sub git_slurp_config_src ($) { # 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 @@ -515,12 +521,25 @@ sub record_maindir () { 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"; |