perlancar > Git-Bunch > Git::Bunch

Download:
Git-Bunch-0.58.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.58   Source  

NAME ^

Git::Bunch - Manage gitbunch directory (directory which contain git repos)

VERSION ^

This document describes version 0.58 of Git::Bunch (from Perl distribution Git-Bunch), released on 2016-11-29.

SYNOPSIS ^

See the included gitbunch script.

DESCRIPTION ^

A gitbunch or bunch directory is just a term I coined to refer to a directory which contains, well, a bunch of git repositories. It can also contain other stuffs like files and non-git repositories (but they must be dot-dirs). Example:

 repos/            -> a gitbunch dir
   proj1/          -> a git repo
   proj2/          -> ditto
   perl-Git-Bunch/ -> ditto
   ...
   .videos/        -> a non-git dir
   README.txt      -> file

If you organize your data as a bunch, you can easily check the status of your repositories and synchronize your data between two locations, e.g. your computer's harddisk and an external/USB harddisk.

A little bit of history: after git got popular, in 2008 I started using it for software projects, replacing Subversion and Bazaar. Soon, I moved everything*) to git repositories: notes & writings, Emacs .org agenda files, configuration, even temporary downloads/browser-saved HTML files. I put the repositories inside $HOME/repos and add symlinks to various places for conveniences. Thus, the $HOME/repos became the first bunch directory.

*) everything except large media files (e.g. recorded videos) which I put in dot-dirs inside the bunch.

See also rsybak, which I wrote to backup everything else.

FUNCTIONS ^

check_bunch(%args) -> [status, msg, result, meta]

Check status of git repositories inside gitbunch directory.

Will perform a 'git status' for each git repositories inside the bunch and report which repositories are clean/unclean.

Will die if can't chdir into bunch or git repository.

This function is not exported by default, but exportable.

This function supports dry-run operation.

Arguments ('*' denotes required arguments):

Special arguments:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

exec_bunch(%args) -> [status, msg, result, meta]

Execute a command for each repo in the bunch.

For each git repository in the bunch, will chdir to it and execute specified command.

This function is not exported by default, but exportable.

This function supports dry-run operation.

Arguments ('*' denotes required arguments):

Special arguments:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

list_bunch_contents(%args) -> [status, msg, result, meta]

List contents inside gitbunch directory.

Will list each repo or non-repo dir/file.

This function is not exported.

Arguments ('*' denotes required arguments):

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

sync_bunch(%args) -> [status, msg, result, meta]

Synchronize bunch to another bunch.

For each git repository in the bunch, will perform a 'git pull/push' for each branch. If repository in destination doesn't exist, it will be rsync-ed first from source. When 'git pull' fails, will exit to let you fix the problem manually.

For all other non-repo file/directory, will simply synchronize by one-way rsync. But, for added safety, will first check the newest mtime (mtime of the newest file or subdirectory) between source and target is checked first. If target contains the newer newest mtime, rsync-ing for that non-repo file/dir will be aborted. Note: you can use --skip-mtime-check option to skip this check.

This function is not exported by default, but exportable.

This function supports dry-run operation.

Arguments ('*' denotes required arguments):

Special arguments:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Git-Bunch.

SOURCE ^

Source repository is at https://github.com/perlancar/perl-Git-Bunch.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Git-Bunch

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO ^

rsybak.

http://joeyh.name/code/mr/. You probably want to use this instead. mr supports other control version software aside from git, doesn't restrict you to put all your repos in one directory, supports more operations, and has been developed since 2007. Had I known about mr, I probably wouldn't have started gitbunch. On the other hand, gitbunch is simpler (I think), doesn't require any config file, and can copy/sync files/directories not under source control. I mainly use gitbunch to quickly: 1) check whether there are any of my repositories which have uncommitted changes; 2) synchronize (pull/push) to other locations. I put all my data in one big gitbunch directory; I find it simpler. gitbunch works for me and I use it daily.

File::RsyBak

AUTHOR ^

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2016 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: