App-Multigit

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


        use curry;
        my $future = App::Multigit::each(sub {
            my $repo = shift;
            $repo
                ->run([qw{git rebase origin/master}])
                ->else(sub {
                    my ($message, $error, %data) = @_;
                    ...
                })
                ->then($repo->curry::report)
            ;
        });

    In the case that you don't care whether the command succeeds or fails,
    you can use finally to catch the failure and pretend it wasn't actually
    a failure.

        use curry;
        my $future = App::Multigit::each(sub {
            my $repo = shift;
            $repo
                ->run([qw{git rebase origin/master}])
                ->finally($repo->curry::report)
            ;
        });

    Despite the name, finally does not have to be the final thing. Think
    "finally" as in "try/catch/finally". In the following code, finally
    simply returns the %data hash, because finally transforms a failure
    into a success and discards the error information.

        use curry;
        my $future = App::Multigit::each(sub {
            my $repo = shift;
            $repo
                ->run([qw{git rebase origin/master}])
                ->finally(sub { @_ })
                ->then(\&carry_on_camping)
                ->then($repo->curry::report)
            ;
        });

   Arrayref form

    In the arrayref form, the $command is passed directly to run in
    App::Multigit::Repo. The Futures returned thus are collated and the
    list of return values is thus collated.

    Because run completes a Future with a hash-shaped list, the convergent
    Future that each returns will be a useless list of all flattened
    hashes. For this reason it is not actually very much use to do this -
    but it is not completely useless, because all hashes are the same size:

        my $future = App::Multigit::each([qw/git reset --hard HEAD/]);
        my @result = $future->get;
    
        my $natatime = List::MoreUtils::natatime(10, @result);
    
        while (my %data = $natatime->()) {
            say $data{stdout};
        }

    However, the %data hashes do not contain repository information; just
    the output. It is expected that if repository information is required,
    the closure form is used.

 mg_each

    This is the exported name of each

        use App::Multigit qw/mg_each/;

 mkconfig($workdir)

    Scans $workdir for git directories and registers each in .mgconfig. If
    the config file already exists it will be appended to; existing config
    will be preserved where possible.

 write_config

    Write a .mgconfig configuration file.

 clean_config

    Checks the .mgconfig for directories that don't exist and removes the
    associated repo section.

 base_branch

    Returns the branch that the base repository is on -the repository that
    contains the .mgconfig or equivalent.

    The purpose of this is to switch the entire project onto a feature
    branch; scripts can use this as the cue to work against a branch other
    than master.

    This will die if the base repository is not on a branch, because if
    you've asked for it, giving you a default will more likely be a
    hindrance than a help.

 set_base_branch($branch)

    Checks out the provided branch name on the parent repository. Beware of
    using a branch name that already exists, because this will switch to
    that branch if it does.

AUTHOR

    Alastair McGowan-Douglas, <altreus at perl.org>

ACKNOWLEDGEMENTS

    This module could have been a lot simpler but I wanted it to be a foray
    into the world of Futures. Shout outs go to those cats in
    irc.freenode.net#perl who basically architectured this for me.

    tm604 (TEAM) - for actually understanding Future architecture, and not
    being mad at me.

    LeoNerd (PEVANS) - also for not being irritated by my inane questions



( run in 0.410 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )