App-Gitc
view release on metacpan or search on metacpan
lib/App/Gitc/Its/Eventum.pm view on Meta::CPAN
my ( $rc, $status_exception );
eval {
return $rc = $issue->close($message) if $to and $to eq 'CLOSE';
$issue->postpone_updates;
$issue->append_internal_comments($message);
$rc = eval { $issue->transition_status($from, $to) } if $to;
$status_exception = $@ if $@;
$issue->update;
$issue->live_updates;
};
die $@ if $@; # rethrow unexpected exceptions
if ( $status_exception ) {
die $status_exception
if $status_exception !~ m/('[^']+' is not a valid status name)/;
return "NOT CHANGING Eventum status: $1\n";
}
elsif ($rc) { # success
return "Changed Eventum status to '$to'\n";
}
else {
return sprintf "NOT CHANGING Eventum status: currently '%s'\n",
lib/App/Gitc/Its/Jira.pm view on Meta::CPAN
my ( $rc, $status_exception );
eval {
my $jira = $self->get_jira_object or return;
$jira->addComment( $issue, $message );
my $updated_issue = $jira->progress_workflow_action_safely( $issue, $to );
my $jira_rest = $self->get_jira_rest_object or return;
$jira_rest->unwatch_issue( $issue->{id}, $jira_user )
if $jira_user eq $default_jira_user;
$rc = ( $issue->{id} == $updated_issue->{id} );
};
die $@ if $@; # rethrow unexpected exceptions
if ($reviewer) {
eval {
my $jira = $self->get_jira_object or return;
$jira->update_issue( $issue,
{ custom_fields => { customfield_10401 => $reviewer, } } );
};
warn "Unable to set reviewer: $@" if $@;
}
lib/App/Gitc/Reversible.pm view on Meta::CPAN
my $rc = eval { $code->() };
if ( my $exception = $@ ) {
our $failure_warning;
warn $failure_warning if defined $failure_warning;
for my $undo ( reverse @undo_stack ) {
eval { $undo->() };
warn "Exception during undo: $@" if $@;
}
# rethrow the exception, with commentary
die "\nThe exception that caused rollback was: $exception";
}
}
1;
__END__
lib/App/Gitc/Reversible.pm view on Meta::CPAN
Executes a code reference (C<$code>) allowing operations with side effects to
be automatically reversed if C<$code> fails or is interrupted. For example:
reversibly {
print "hello\n";
to_undo { print "goodbye\n" };
die "uh oh\n" if $something_bad;
};
just prints "hello" if C<$something_bad> is false. If it's true, then both
"hello" and "goodbye" are printed and the exception "uh oh" is rethrown.
Upon failure, any code refs provided by calling L</to_undo> are executed in
reverse order. Conceptually, we're unwinding the stack of side effects that
C<$code> performed up to the point of failure.
If C<$code> is interrupted with SIGINT, the side effects are undone and an
exception "SIGINT\n" is thrown.
Nested calls to C<reversibly> are handled correctly.
=head1 SEE ALSO
L<Data::Transaactional>, L<Object::Transaction>.
=head1 AUTHOR
Grant Street Group <developers@grantstreet.com>
lib/App/Gitc/Util.pm view on Meta::CPAN
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>.
lib/App/Gitc/Util.pm view on Meta::CPAN
Determines 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.
=head2 environment_preceding($environment)
Given an C<$environment> name, returns the name of the environment that
precedes that one in promotion order. For instance
C<environment_preceding('stage')> produces 'test'.
If there is no such C<$environment>, an exception is thrown. If no
environment precedes the one given, returns C<undef>.
=head2 full_changeset_name($name)
Given the C<$name> of a changeset, returns a Git ref which correctly addresses
that changeset's head. It doesn't matter if the changeset is newly opened,
pending review or merged. The resulting ref points at the head of that
changeset.
See also L<short_ref_name>.
lib/App/Gitc/Util.pm view on Meta::CPAN
origin.
=head2 is_merge_commit($ref)
Returns true if the commit pointed at by C<$ref> is a merge commit. Otherwise,
it returns false.
=head2 is_suspendable
Marks the currently running gitc command as suspendable. If a command which
is marked as suspendable is currently suspended, calling this function throws
an exception.
Any command which suspends itself should call this function. It helps avoid
user error when the user tries to run the same command again instead of
resuming the suspended command.
=head2 is_valid_ref($name)
Returns a commit ID if C<$name> is a valid Git "ref". Otherwise, it returns
false.
lib/App/Gitc/Util.pm view on Meta::CPAN
=head2 parse_changeset_spec($spec)
C<$spec> is a single command line argument which is supposed to uniquely
identify a changeset and its associated project. C<undef> means "infer
everything from the repository I'm in". C<project#changeset> means to use the
specified project and changeset. C<changeset> means to use the given
changeset within the current directory's project.
Returns a list containing the project name and the changeset name. If there's
any trouble obtaining those two, an exception is thrown.
=head2 project_name
Returns the name of the project in the current working directory.
=head2 project_root
Returns an absolute path to the current repository's project root.
If called from a bare repository, it throws an exception.
=head2 remote_branch_exists($branch_name)
Returns true if origin has a branch named C<$branch_name>. Otherwise, it
returns false.
=head2 sendmail($args)
Sends an email with a standard format, allowing the user to edit the template.
C<$args> is a single hashref of named arguments. The argument C<to> specifies
lib/App/Gitc/Util.pm view on Meta::CPAN
in the list before their dependencies. In Git terms, "child commits are given
before their parents." Since demotions are not accomodated by Git's data
model, they are placed at the end of the list of unpromoted changesets.
=head1 Private Subroutines
=head2 command_name
Returns the name of the gitc command that started this whole mess.
This is mostly a helper subroutine for eventum_transition_status.
If the command name can't be determined, an exception is thrown.
=head2 _states
Used internally to calculate target for state change.
=head2 state_blocked
Given a C<command> and a specified C<state> this checks the block list in the
project configuration and returns true if the state should block the command
from proceeding.
( run in 0.478 second using v1.01-cache-2.11-cpan-496ff517765 )