if @ARGV == 0;
my $command = shift @ARGV;
+ $command =~ s{-}{_}gxms;
no strict 'refs';
if ( not defined &{"cmd_$command"} ) {
Getopt::Mixed::abortMsg("'$command' is not a valid cil command.");
}
# check that all it's comments are there and that they have this parent
- my $comments = $i->Comments;
+ my $comments = $i->CommentList;
foreach my $c ( @$comments ) {
# see if this comment exists at all
if ( exists $comment->{$c} ) {
}
# check that all it's attachments are there and that they have this parent
- my $attachments = $i->Attachments;
+ my $attachments = $i->AttachmentList;
foreach my $a ( @$attachments ) {
# see if this attachment exists at all
if ( exists $attachment->{$a} ) {
}
}
+sub cmd_depends_on {
+ my ($cil, undef, $issue_name, $depends_name) = @_;
+
+ my $issue = load_issue_fuzzy($cil, $issue_name);
+ my $depends = load_issue_fuzzy($cil, $depends_name);
+
+ $issue->add_depends_on( $depends->name );
+ $depends->add_precedes( $issue->name );
+
+ $issue->save($cil);
+ $depends->save($cil);
+}
+
+sub cmd_precedes {
+ my ($cil, undef, $issue_name, $depends_name) = @_;
+
+ # switch them round and call 'DependsOn'
+ cmd_depends_on($cil, undef, $depends_name, $issue_name);
+}
+
## ----------------------------------------------------------------------------
# helpers
my @tmp;
foreach my $issue ( @new_issues ) {
push @tmp, $issue
- if grep { $_ eq $args->{l} } @{$issue->Labels};
+ if grep { $_ eq $args->{l} } @{$issue->LabelList};
}
@new_issues = @tmp;
}
field( 'AssignedTo', $issue->AssignedTo() );
field( 'Inserted', $issue->Inserted() );
field( 'Status', $issue->Status() );
- field( 'Labels', join(' ', @{$issue->Label()}) );
+ field( 'Labels', join(' ', @{$issue->LabelList()}) );
+ field( 'DependsOn', join(' ', @{$issue->DependsOnList()}) );
+ field( 'Precedes', join(' ', @{$issue->PrecedesList()}) );
}
sub display_issue {
field( 'CreatedBy', $issue->CreatedBy() );
field( 'AssignedTo', $issue->AssignedTo() );
field( 'Label', $_ )
- foreach sort @{$issue->Label()};
+ foreach sort @{$issue->LabelList()};
field( 'Comment', $_ )
- foreach sort @{$issue->Comment()};
+ foreach sort @{$issue->CommentList()};
field( 'Attachment', $_ )
- foreach sort @{$issue->Attachment()};
+ foreach sort @{$issue->AttachmentList()};
+ field( 'DependsOn', $_ )
+ foreach sort @{$issue->DependsOnList()};
+ field( 'Precedes', $_ )
+ foreach sort @{$issue->PrecedesList()};
field( 'Inserted', $issue->Inserted() );
field( 'Updated', $issue->Inserted() );
text('Description', $issue->Description());
field( 'AssignedTo', $issue->AssignedTo() );
field( 'Label', $_ )
foreach sort @{$issue->Label()};
+ field( 'DependsOn', $_ )
+ foreach sort @{$issue->DependsOnList()};
+ field( 'Precedes', $_ )
+ foreach sort @{$issue->PrecedesList()};
field( 'Inserted', $issue->Inserted() );
field( 'Updated', $issue->Inserted() );
text('Description', $issue->Description());
Shortcut so that you can set a new status on an issue without having to edit
it.
+=item depends-on ISSUE1 ISSUE2
+
+Shortcut so that cil will add a 'DependsOn' from issue 1 to issue
+2. Conversley, issue 2 will also then contain a 'Precedes' pointer to issue 1.
+
+=item precedes ISSUE1 ISSUE2
+
+This is the exact opposite of C<depends-on> and is here for convenience and
+completeness. ie. issue 1 has to be completed before issue 2.
+
+=item status ISSUE NEW_STATUS
+
+Shortcut so that you can set a new status on an issue without having to edit
+it.
+
=item edit ISSUE
Edits the issue. If it changes, set the updates time to now.
use base qw(CIL::Base);
# fields specific to Issue
-__PACKAGE__->mk_accessors(qw(Summary Status AssignedTo Label Comment Attachment Description));
+__PACKAGE__->mk_accessors(qw(Summary Status AssignedTo DependsOn Precedes Label Comment Attachment Description));
-my @FIELDS = ( qw(Summary Status CreatedBy AssignedTo Label Comment Attachment Inserted Updated Description) );
+my @FIELDS = ( qw(Summary Status CreatedBy AssignedTo DependsOn Precedes Label Comment Attachment Inserted Updated Description) );
my $cfg = {
array => {
Label => 1,
Comment => 1,
Attachment => 1,
+ DependsOn => 1,
+ Precedes => 1,
},
};
Label => [],
Comment => [],
Attachment => [],
+ DependsOn => [],
+ Precedes => [],
Description => '',
};
$self->{Changed} = 0;
# see if we only allow certain Labels
if ( $cil->LabelStrict ) {
- my @labels = @{$self->Labels};
+ my @labels = @{$self->LabelList};
foreach my $label ( @labels ) {
unless ( exists $cil->LabelAllowed()->{$label} ) {
push @errors, "LabelStrict is turned on but this issue has an invalid label '$label'";
$self->flag_as_updated();
}
-sub Labels {
+sub add_depends_on {
+ my ($self, $depends) = @_;
+
+ croak 'provide an issue name when adding a depends'
+ unless defined $depends;
+
+ push @{$self->{data}{DependsOn}}, $depends;
+ $self->flag_as_updated();
+}
+
+sub add_precedes {
+ my ($self, $precedes) = @_;
+
+ croak 'provide an issue name when adding a precedes'
+ unless defined $precedes;
+
+ push @{$self->{data}{Precedes}}, $precedes;
+ $self->flag_as_updated();
+}
+
+sub LabelList {
my ($self) = @_;
return $self->{data}{Label};
}
-sub Comments {
+sub CommentList {
my ($self) = @_;
return $self->{data}{Comment};
}
-sub Attachments {
+sub AttachmentList {
my ($self) = @_;
return $self->{data}{Attachment};
}
+sub DependsOnList {
+ my ($self) = @_;
+ return $self->{data}{DependsOn};
+}
+
+sub PrecedesList {
+ my ($self) = @_;
+ return $self->{data}{Precedes};
+}
+
sub is_open {
my ($self, $cil) = @_;