LabelStrict LabelAllowed
DefaultNewStatus
UseGit
+ MungeEmail
UserName UserEmail
AutoAssignSelf
git hook
LabelStrict => 0, # whether to complain if a label is invalid
DefaultNewStatus => 'New', # What Status to use for new issues by default
UseGit => 0, # don't do anything with Git
+ MungeEmail => 0, # don't munge email by default
};
my @config_hashes = qw(StatusOpen StatusClosed LabelAllowed);
# set each config item
$self->IssueDir( $self->BaseDir() . q{/} . $cfg->{IssueDir} );
$self->UseGit( $cfg->{UseGit} );
+ $self->MungeEmail( $cfg->{MungeEmail} );
# Status info
$self->StatusStrict( $cfg->{StatusStrict} );
## ----------------------------------------------------------------------------
sub new {
- my ($proto, $name) = @_;
+ my ($proto, $cil, $name) = @_;
croak 'please provide an attachment name'
unless defined $name;
$self->set_inserted_now;
+ # save the reference to cil itself
+ $self->cil( $cil );
+
return $self;
}
use CIL::Utils;
use base qw(Class::Accessor);
-__PACKAGE__->mk_accessors(qw(CreatedBy Inserted Updated));
+__PACKAGE__->mk_accessors(qw(cil Inserted Updated));
+
+sub CreatedBy {
+ my ($self, $value) = @_;
+
+ if ( defined $value ) {
+ $self->{data}{CreatedBy} = $self->cil->MungeEmail ? CIL::Utils->munge_email($value) : $value;
+ }
+ return $self->{data}{CreatedBy};
+}
## ----------------------------------------------------------------------------
unless $cil->file_exists($filename);
my $data = $cil->parse_cil_file($filename, $class->last_field);
- my $issue = $class->new_from_data( $name, $data );
+ my $issue = $class->new_from_data( $cil, $name, $data );
return $issue;
}
sub new_from_data {
- my ($class, $name, $data) = @_;
+ my ($class, $cil, $name, $data) = @_;
croak 'please provide an issue name'
unless defined $name;
# ToDo: check we have all the other correct fields
# create the issue
- my $self = $class->new( $name );
+ my $self = $class->new( $cil, $name );
my $fields = $class->fields();
my $array_fields = $class->array_fields();
}
sub new_from_fh {
- my ($class, $name, $fh) = @_;
+ my ($class, $cil, $name, $fh) = @_;
croak 'please provide name'
unless defined $name;
my $data = CIL::Utils->parse_from_fh( $fh, $class->last_field );
- return $class->new_from_data( $name, $data );
+ return $class->new_from_data( $cil, $name, $data );
}
sub set_data {
my $user = CIL::Utils->user($cil);
- my $issue = CIL::Issue->new('tmpname');
+ # set up a default issue for now
+ my $issue = CIL::Issue->new( $cil, 'tmpname' );
$issue->Summary( join ' ', @argv );
$issue->Status($cil->DefaultNewStatus);
$issue->CreatedBy( $user );
if ( $args->{mine} or $cil->AutoAssignSelf );
$issue->Description("Description ...");
+ # now read in the file until the issue is valid
$issue = CIL::Utils->add_issue_loop($cil, undef, $issue);
if ( $cil->UseGit ) {
CIL::Utils->ensure_interactive();
my $fh = CIL::Utils->solicit( $add_attachment_text );
- my $attachment = CIL::Attachment->new_from_fh( 'tmp', $fh );
+ my $attachment = CIL::Attachment->new_from_fh( $cil, 'tmp', $fh );
unless ( defined $attachment ) {
$cil->fatal("could not create new attachment");
}
CIL::Utils->ensure_interactive();
# create the new comment
- my $comment = CIL::Comment->new('tmpname');
+ my $comment = CIL::Comment->new( $cil, 'tmpname' );
$comment->Issue( $issue->name );
$comment->CreatedBy( CIL::Utils->user($cil) );
$comment->Description("Description ...");
- $comment = CIL::Utils->add_comment_loop($cil, undef, $issue, $comment);
+ $comment = CIL::Utils->add_comment_loop( $cil, undef, $issue, $comment );
if ( $cil->UseGit ) {
# if we want to add or commit this comment
while ( $edit eq $y ) {
# read in the new issue text
my $fh = CIL::Utils->solicit( $issue->as_output );
- $issue = CIL::Issue->new_from_fh( $issue->name, $fh );
+ $issue = CIL::Issue->new_from_fh( $cil, $issue->name, $fh );
# check if the issue is valid
if ( $issue->is_valid($cil) ) {
## ----------------------------------------------------------------------------
sub new {
- my ($proto, $name) = @_;
+ my ($proto, $cil, $name) = @_;
croak 'please provide a comment name'
unless defined $name;
$self->set_inserted_now;
+ # save the reference to cil itself
+ $self->cil( $cil );
+
return $self;
}
use base qw(CIL::Base);
# fields specific to Issue
-__PACKAGE__->mk_accessors(qw(Summary Status AssignedTo DueDate DependsOn Precedes Label Comment Attachment Description));
+__PACKAGE__->mk_accessors(qw(Summary Status DueDate DependsOn Precedes Label Comment Attachment Description));
my @FIELDS = ( qw(Summary Status CreatedBy AssignedTo DueDate DependsOn Precedes Label Comment Attachment Inserted Updated Description) );
my $cfg = {
},
};
+sub AssignedTo {
+ my ($self, $value) = @_;
+
+ if ( defined $value ) {
+ $self->{data}{AssignedTo} = $self->cil->MungeEmail ? CIL::Utils->munge_email($value) : $value;
+ }
+
+ return $self->{data}{AssignedTo};
+}
+
## ----------------------------------------------------------------------------
sub new {
- my ($proto, $name) = @_;
+ my ($proto, $cil, $name) = @_;
croak 'please provide an issue name'
unless defined $name;
$self->set_inserted_now;
+ # save the reference to cil itself
+ $self->cil( $cil );
+
return $self;
}
while ( $edit eq $y ) {
# read in the new issue text
my $fh = $class->solicit( $issue->as_output );
- $issue = CIL::Issue->new_from_fh( 'tmp', $fh );
+ $issue = CIL::Issue->new_from_fh( $cil, 'tmp', $fh );
# check if the issue is valid
if ( $issue->is_valid($cil) ) {
# we've got the issue, so let's name it
my $unique_str = time . $issue->Inserted . $issue->Summary . $issue->Description;
$issue->set_name( substr(md5_hex($unique_str), 0, 8) );
+
+ # set these so that munging takes place
+ $issue->CreatedBy( $issue->CreatedBy() );
+ $issue->AssignedTo( $issue->AssignedTo() );
+
+ # save out to disk
$issue->save($cil);
# should probably be run from with $cil
while ( $edit eq $y ) {
# read in the new comment text
my $fh = CIL::Utils->solicit( $comment->as_output );
- $comment = CIL::Comment->new_from_fh( 'tmp', $fh );
+ $comment = CIL::Comment->new_from_fh( $cil, 'tmp', $fh );
# check if the comment is valid
if ( $comment->is_valid($cil) ) {
my $unique_str = time . $comment->Inserted . $issue->Description;
$comment->set_name( substr(md5_hex($unique_str), 0, 8) );
+ # set these so that munging takes place
+ $comment->CreatedBy( $issue->CreatedBy() );
+
# finally, save it
$comment->save($cil);
}
my $issue_name = $issues->[0]->{name};
- my $issue = CIL::Issue->new_from_name($cil, $issue_name);
+ my $issue = CIL::Issue->new_from_name( $cil, $issue_name );
unless ( defined $issue ) {
$class->fatal("Couldn't load issue '$issue_name'");
}
}
my $comment_name = $comments->[0]->{name};
- my $comment = CIL::comment->new_from_name($cil, $comment_name);
+ my $comment = CIL::comment->new_from_name( $cil, $comment_name );
unless ( defined $comment ) {
$class->fatal("Couldn't load comment '$comment_name'");
}
}
my $attachment_name = $attachments->[0]->{name};
- my $attachment = CIL::Attachment->new_from_name($cil, $attachment_name);
+ my $attachment = CIL::Attachment->new_from_name( $cil, $attachment_name );
unless ( defined $attachment ) {
$class->fatal("Couldn't load attachment '$partial_name'");
}
return $issues;
}
+sub munge_email {
+ my ($class, $email) = @_;
+
+ $email =~ s{@}{ at }gxms;
+ $email =~ s{\.}{ dot }gxms;
+
+ return $email;
+}
+
sub separator {
my ($class) = @_;
$class->msg('=' x 79);