App-Gitc
view release on metacpan or search on metacpan
lib/App/Gitc/Util.pm view on Meta::CPAN
object if it supports it, or just the class name.
=head2 git
A wrapper for executing git commands and handling errors.
In void context, the command is executed using C<system>. In scalar context,
the command's output is captured, chomped and returned. In list context, a
list of chomped lines is returned.
=head2 git_config
Returns a nested hash data structure representing Git's configuration.
=head2 guarantee_a_clean_working_directory
Make sure that all tracked files match the index and match the commit object.
If the working directory is not clean, ask the user whether to proceed. If he
wants to proceed, this sub stashes the current changes and returns the stash's
commit ID. In this case, it's the caller's responsibility to invoke "git
stash apply" with this ID to restore the changes, when appropriate.
If the user does not want to proceed, an exception is thrown. In most cases,
this will accomplish what the user desired by halting the program.
If the directory is clean, a false value is returned which indicates that
nothing was stashed while guaranteeing cleanliness.
=head2 let_user_edit($filename)
Open's the user's preferred editor so that he can interactively edit
C<$filename>.
=head2 meta_data_add($data)
Appends the contents of the hashref C<$data> to the changeset meta data.
Returns a unique identifier which can be used by L</meta_data_rm>.
=head2 meta_data_rm({id => $id, changeset => $changeset})
Deletes the meta data entry with ID C<$id> in changeset C<$changeset>.
=head2 meta_data_rm_all($changeset)
Deletes all changeset meta data for the changeset named C<$changeset>. The
project is determined by the current working directory. Returns the number of
meta data entries that were deleted.
=head2 meta_data_rm_project($project)
Deletes all changeset meta data for the project named C<$project>. Returns
the number of meta data entries that were deleted.
=head2 new_branch_version($branch, $new_major_version)
Increments and returns the most recent version tagged for the given C<$branch>.
This only applies to projects that have the 'use_version_tags' config set to true.
If $new_major_version is truthy, increment the major version # and make minor 0
=head2 new_version_tag($branch)
Returns a tag name for an updated version of the given C<$branch>.
This only applies to projects that have the 'use_version_tags' config set to true.
=head2 project_config
Returns a hashref with configuration details about this project.
Configuration is loaded from the following sources:
* /etc/gitc/gitc.config
* $PROJECT_ROOT/gitc.config
* $HOME/.gitc/gitc.config
It will then parse all the paths in the GITC_CONFIG environment variable
(separated by :).
These configuration files are all merged together with the later files
overriding the earlier.
Finally we merge the default config with the per-project configuration
we found to generate a final fully baked configuration for the project.
=head1 Optionally Exported Subroutines
The following subroutines are only exported when they're asked for.
=head2 archived_tags
Returns an arrayref of arrayrefs representing all tags that have been archived
for the current project. The internal arrayrefs hold the tag's SHA1 and ref
name, in that order. The tags are returned in sorted order increasing by ref
name (the same order as F<.git/packed-refs>).
=head2 branch_basis($commit_id)
Determines the base branch for the given C<$commit_id>. The base branch is
the most specific branch on which this commit lies. It's typically used for
converting an earlier commit on a branch (such as tag
"test/2009-12-29T12_13_14") into the name of the branch (such as "test"). If
we can't determine the branch name, returns 'unknown'.
=head2 branch_point($ref)
Returns a commit ID indicating the commit on which the branch at C<$ref>
is based. For example, if we have a topology like this
o-----A
/
o---o---X---o---M
where A is the head of a branch and M is the head of master. The branch point
of A is commit X. If A is later merged into M, the branch point remains the
same.
See L</full_changeset_name> for a way to convert a changeset name into
a value suitable for C<$ref>.
=head2 changeset_group($changeset)
Given a C<$changeset> name, returns an arrayref of the changeset names (for
existing changesets) in this same changeset group. A changeset group is
defined as any changesets that share the same Eventum number or prefix (if the
( run in 0.845 second using v1.01-cache-2.11-cpan-e93a5daba3e )