This library provides common utility functions for interacting with repositories using Nuggit.
Return an array of all submodules from current (or specified) directory and below listed depth-first, queried via git submodule foreach.
NOTE: Direct usage of submodule_foreach() is preferred when possible.
Return an array listing all submodules of the current (or specified) directory. This function uses 'git config' to parse the .gitmodules file and is NOT recursive.
WARNING: This function is now deprecated in favor of $ngt->foreach and will be phased out in a future release.
Recurse into each submodule and execute the given command. This is roughly equivalent to "git submodule foreach"
Parameters:
Callback function to be called foreach submodule found. CWD will be at root of current submodule.
Callback will always be called starting from the deepest submodule.
Function will be called with
-parent Relative path from root to parent -name Name of submodule. $name/$parent is full path from root -status If modified, '+' or '-' as reported by Git -hash Commit SHA1 -label Matching Branch/Tag as reported by Git (?)
Hash containing list of user options. Currently supported options are:
The main callback function is executed after visiting all nested submodules.
If set, or undefined, recurse into any nested submodules. If set to 0, only visit submodules of the current repository.
If defined, parse each submodule in parallel using fork/wait
Path of Parent Directory. In each recursion, the submodule name will be appended.
Returns the root directory of the nuggit, or undef if not found Also navigate to the nuggit root directory
Initialize Nuggit Repository by creating a .nuggit file at current location.
Get the name of the default branch used for pushes/pulls for this repository.
NOTE: This function may serve as the basis for an improved get_selected_branch() function that retrieves additional information.
?
get the checked out branch from the list of branches The input is the output of git branch (list of branches)
Get a listing of all branches in the current repository/directory.
Supported options (passed directly to git) include: - get_branches() - Return a list of all local branches - get_branches("-a") - Return a list of all local+remote branches (ie: $branch or remotes/origin/$branch) - get_branches("-r") - Return a list of all remote branches (ie: origin/$branch) - get_branches("--merged") - get_branches("--no-merged")
Returns a hash where key is branch name and value will be a hash with any known details.
Find the top-level of this project and chdir into it. If not a nuggit project, 'die'
Returns root_dir since this is often needed by callers. (FUTURE: This should be an OOP method, in which case this return value would be deprecated in favor of class variable)
Checks if a merge operation is in progress, and dies if it is.
This function should be called with the path to the nuggit root repository or with that as the current working directory.
DEPRECATED - Use $ngt->merge_conflict_state(1) instead
The following is an initial cut at an OOP interface. The OOP interface is incomplete at this stage and serves primarily as a convenience wrapper for other commands, and Nuggit::Log
Run given command (str) in the current repository, and all nested submodules.
Note: Current repository corresponds to current working directory. To run from nuggit root, user should change directories first. This permits greater flexibility in usage.
Execute the given git command from the current directory. The command will be wrapped in IPC::Run3 in order to capture stdout, stderr, and exit status. Output and 'die' functionality are controlled by object settings.
Usage: my ($status, $stdout, $stderr) = run($cmd [,@args]);
TODO: @args to be added later, for now a single string expected TODO: Optional parameters to overrride object default for die_on_error and run_echo_always.
If no argument is specified, it returns true if a merge operation is in progress, false otherwise.
If any parameter is defined, then we will die with an appropriate error if a merge is in progress.
Recurse into each submodule and execute the given command. This is roughly equivalent to "git submodule foreach" with added functionality.
It accepts a hashref as it's sole parameter which may contain the following fields. Parameters:
Callback function to be called foreach submodule with breadth-first recursion (starting from the top level). CWD will be at root of current submodule. See below for arguments provided.
Callback function to be called foreach submodule with depth-first recursion (starting from most nested). CWDW will be at roto of current submodule. See below for arguments provided.
Callback functions will be called with a single hashref argument containing the following fields
opts - A copy of the input options parent - The name of the parent repository name - The name of this submodule
The above fields will be defined for the root repository (if run_root) and all submodules, while the following fields only apply to submodules:
status - The status for this repository. 0 for unmodified, '+' for modified, '-' for uninitialized, 'U' for pending merge conflicts.
To install Git::Nuggit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Git::Nuggit
CPAN shell
perl -MCPAN -e shell install Git::Nuggit
For more information on module installation, please visit the detailed CPAN module installation guide.