This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

cil-03c93e82: Removed all the VCS stuff we do not need

  • Loading branch information...
chilts committed Jan 25, 2010
1 parent 32c16fd commit 2d248eb1de7502a83d61449f1dd474c69382598a
View
1 .cil
@@ -1,4 +1,5 @@
VCS: Git
+UseGit: 1
StatusStrict: 1
StatusOpenList: New
StatusOpenList: InProgress
View
11 bin/cil
@@ -117,7 +117,6 @@ my %BOOLEAN_ARGS = (
$cil->read_config_user();
$cil->read_config_file();
- $cil->check_args($args);
# add any hooks we want
# none yet
@@ -381,7 +380,7 @@ may be declared multiple times:
The C<.cil> file is fairly simple and an example can be seen here:
- VCS: Git
+ UseGit: 1
StatusStrict: 1
StatusOpenList: New
StatusOpenList: InProgress
@@ -395,12 +394,12 @@ The C<.cil> file is fairly simple and an example can be seen here:
=over
-=item VCS
+=item UseGit
-Default: empty, Type: Enum(Git)
+Default: 0, Type: Boolean (0/1)
-Currently this option only supports Git. This enables you to use the 'track'
-command.
+Determines whether to use Git or not. Some features require Git though Cil is
+perfectly usable without.
=item StatusStrict
View
@@ -1,10 +1,10 @@
Summary: Remove the whole VCS.pm stuff, just have a Git.pm at the top level
-Status: New
+Status: Finished
CreatedBy: Andrew Chilton <andychilton@gmail.com>
AssignedTo: Andrew Chilton <andychilton@gmail.com>
Label: Milestone-v0.07
Inserted: 2010-01-24T10:17:18
-Updated: 2010-01-24T10:39:29
+Updated: 2010-01-25T09:55:05
No-one is going to use cil with anything other than Git (well, maybe not using
Git at all) so remove all the abstract stuff that isn't needed.
View
@@ -26,7 +26,7 @@ use warnings;
use Carp qw(croak confess);
use File::Glob qw(:glob);
use File::HomeDir;
-use Git;
+use CIL::Git;
use vars qw( $VERSION );
$VERSION = '0.5.1';
@@ -36,27 +36,24 @@ use Module::Pluggable
search_path => [ 'CIL::Command' ],
require => 1;
-use CIL::VCS::Factory;
-
use base qw(Class::Accessor);
__PACKAGE__->mk_accessors(qw(
IssueDir
StatusStrict StatusAllowed StatusOpen StatusClosed
LabelStrict LabelAllowed
DefaultNewStatus
- VCS
+ UseGit
UserName UserEmail
AutoAssignSelf
- vcs hook
- vcs_revision
+ git hook
));
my $defaults = {
IssueDir => 'issues', # the dir to save the issues in
StatusStrict => 0, # whether to complain if a status is invalid
LabelStrict => 0, # whether to complain if a label is invalid
DefaultNewStatus => 'New', # What Status to use for new issues by default
- VCS => 'Null', # don't do anything for VCS hooks
+ UseGit => 0, # don't do anything with Git
};
my @config_hashes = qw(StatusOpen StatusClosed LabelAllowed);
@@ -68,9 +65,6 @@ my $defaults_user = {
};
my $allowed = {
- vcs => {
- 'Git' => 1,
- },
hook => {
'issue_post_save' => 1,
},
@@ -94,27 +88,17 @@ sub new {
return $self;
}
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
sub command_names {
return map { $_->name } $_[0]->commands;
}
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
sub list_entities {
my ($self, $prefix, $base) = @_;
$base = '' unless defined $base;
my $globpath = $self->IssueDir . "/${prefix}_${base}*.cil";
- my @filenames;
- if ( $self->vcs_revision ) {
- @filenames = $self->vcs->glob_rev($self->vcs_revision, $globpath);
- }
- else {
- @filenames = bsd_glob($globpath);
- }
+ my @filenames = bsd_glob($globpath);
my @entities;
foreach my $filename ( sort @filenames ) {
@@ -263,14 +247,13 @@ sub read_config_file {
my $cfg;
if ( -f $filename ) {
$cfg = CIL::Utils->parse_cil_file( $filename );
+ %$cfg = (%$defaults, %$cfg);
}
else {
+ # set some defaults if we don't have a .cil file
$cfg = $defaults;
}
- # set some defaults if we don't have any of these
- %$cfg = (%$defaults, %$cfg);
-
# for some things, make a hash out of them
foreach my $hash_name ( @config_hashes ) {
# if we have nothing in the cfg hash already, set it to empty and move on
@@ -293,6 +276,7 @@ sub read_config_file {
# set each config item
$self->IssueDir( $cfg->{IssueDir} );
+ $self->UseGit( $cfg->{UseGit} );
# Status info
$self->StatusStrict( $cfg->{StatusStrict} );
@@ -308,24 +292,13 @@ sub read_config_file {
$self->DefaultNewStatus( $cfg->{DefaultNewStatus} );
- # if we are allowed this VCS, create the hook instance
- $self->VCS( $cfg->{VCS} || 'Null' );
- my $vcs = CIL::VCS::Factory->new( $cfg->{VCS} );
- $self->vcs( $vcs );
-}
-
-sub check_args {
- my ($self, $args) = @_;
-
- if ( $args->{r} ) {
- $self->vcs_revision($args->{r});
- if ( !$self->VCS or $self->VCS eq "Null" ) {
- warn "No VCS set in config file!\n";
- }
+ # create the git instance if we want it
+ $self->UseGit( $cfg->{UseGit} || 0 );
+ if ( $self->UseGit ) {
+ $self->git( CIL::Git->new() );
}
}
-
sub register_hook {
my ($self, $hook_name, $code) = @_;
@@ -353,44 +326,22 @@ sub run_hook {
sub file_exists {
my ($self, $filename) = @_;
- if ( $self->vcs_revision ) {
- $self->vcs->file_exists($self->vcs_revision, $filename);
- }
- else {
- -f $filename;
- }
+ return -f $filename;
}
sub dir_exists {
my ($self, $dir) = @_;
-
- return $self->vcs_revision
- ? $self->vcs->dir_exists($self->vcs_revision, $dir)
- : -d $dir
- ;
+ return -d $dir;
}
sub parse_cil_file {
my ($self, $filename, $last_field) = @_;
-
- if ( $self->vcs_revision ) {
- my $fh = $self->vcs->get_fh($self->vcs_revision, $filename);
- CIL::Utils->parse_from_fh($fh, $last_field);
- }
- else {
- CIL::Utils->parse_cil_file($filename, $last_field);
- }
+ return CIL::Utils->parse_cil_file($filename, $last_field);
}
sub save {
my ($self, $filename, $data, @fields) = @_;
-
- if ( $self->vcs_revision ) {
- confess "tried to ->save on alternate revision";
- }
- else {
- CIL::Utils->write_cil_file( $filename, $data, @fields );
- }
+ return CIL::Utils->write_cil_file( $filename, $data, @fields );
}
## ----------------------------------------------------------------------------
View
@@ -47,14 +47,16 @@ sub run {
$issue = CIL::Utils->add_issue_loop($cil, undef, $issue);
- # if we want to add or commit this issue
- if ( $args->{add} or $args->{commit} ) {
- $cil->vcs->add( $cil, $issue );
- }
+ if ( $cil->UseGit ) {
+ # if we want to add or commit this issue
+ if ( $args->{add} or $args->{commit} ) {
+ $cil->git->add( $cil, $issue );
+ }
- # if we want to commit this issue
- if ( $args->{commit} ) {
- $cil->vcs->commit( $cil, 'New Issue', $issue );
+ # if we want to commit this issue
+ if ( $args->{commit} ) {
+ $cil->git->commit( $cil, 'New Issue', $issue );
+ }
}
}
View
@@ -45,15 +45,17 @@ sub run {
$comment = CIL::Utils->add_comment_loop($cil, undef, $issue, $comment);
- # if we want to add or commit this comment
- if ( $args->{add} or $args->{commit} ) {
- $cil->vcs->add( $cil, $issue );
- $cil->vcs->add( $cil, $comment );
- }
-
- # if we want to commit this comment
- if ( $args->{commit} ) {
- $cil->vcs->commit( $cil, 'New Comment', $issue, $comment );
+ if ( $cil->UseGit ) {
+ # if we want to add or commit this comment
+ if ( $args->{add} or $args->{commit} ) {
+ $cil->git->add( $cil, $issue );
+ $cil->git->add( $cil, $comment );
+ }
+
+ # if we want to commit this comment
+ if ( $args->{commit} ) {
+ $cil->git->commit( $cil, 'New Comment', $issue, $comment );
+ }
}
}
@@ -42,16 +42,18 @@ sub run {
$issue->save($cil);
$depends->save($cil);
- # if we want to add or commit this change
- if ( $args->{add} or $args->{commit} ) {
- $cil->vcs->add( $cil, $issue );
- $cil->vcs->add( $cil, $depends );
- }
-
- # if we want to commit this change
- if ( $args->{commit} ) {
- my $message = 'Issue ' . $issue->name . ' has a new dependent ' . $depends->name;
- $cil->vcs->commit_multiple( $cil, $message, $issue, $depends );
+ if ( $cil->UseGit ) {
+ # if we want to add or commit this change
+ if ( $args->{add} or $args->{commit} ) {
+ $cil->git->add( $cil, $issue );
+ $cil->git->add( $cil, $depends );
+ }
+
+ # if we want to commit this change
+ if ( $args->{commit} ) {
+ my $message = 'Issue ' . $issue->name . ' has a new dependent ' . $depends->name;
+ $cil->git->commit_multiple( $cil, $message, $issue, $depends );
+ }
}
}
View
@@ -65,14 +65,16 @@ sub run {
# save it
$issue->save($cil);
- # if we want to add or commit this issue
- if ( $args->{add} or $args->{commit} ) {
- $cil->vcs->add( $cil, $issue );
- }
+ if ( $cil->UseGit ) {
+ # if we want to add or commit this issue
+ if ( $args->{add} or $args->{commit} ) {
+ $cil->git->add( $cil, $issue );
+ }
- # if we want to commit this issue
- if ( $args->{commit} ) {
- $cil->vcs->commit( $cil, 'Issue Edited', $issue );
+ # if we want to commit this issue
+ if ( $args->{commit} ) {
+ $cil->git->commit( $cil, 'Issue Edited', $issue );
+ }
}
CIL::Utils->display_issue($cil, $issue);
View
@@ -59,11 +59,10 @@ sub run {
}
# are we in a Git repository?
- my $VCSconfig = '';
+ my $use_git = 0;
if ( -d '.git' ) {
- CIL::Utils->msg( 'git repository detected, setting VCS accordingly' );
- $VCSconfig = 'VCS: Git';
- my $vcs = CIL::VCS::Factory->new( 'Git' );
+ CIL::Utils->msg( 'git repository detected, setting to use it' );
+ $use_git = 1;
}
# create a .cil file here also
@@ -76,7 +75,7 @@ sub run {
else {
# write a default .cil file
write_file($config, <<"CONFIG");
-$VCSconfig
+UseGit: $use_git
StatusStrict: 1
StatusOpenList: New
StatusOpenList: InProgress
View
@@ -55,21 +55,25 @@ sub run {
# save
$issue->save($cil);
- # if we want to add or commit this issue
- if ( $args->{add} or $args->{commit} ) {
- $cil->vcs->add( $cil, $issue );
+ if ( $cil->UseGit ) {
+ # if we want to add or commit this issue
+ if ( $args->{add} or $args->{commit} ) {
+ $cil->git->add( $cil, $issue );
+ }
}
push @issues, $issue;
}
- # if we want to commit these issues
- if ( $args->{commit} ) {
- if ( $args->{remove} ) {
- $cil->vcs->commit_multiple( $cil, "Removed label '$label'", @issues );
- }
- else {
- $cil->vcs->commit_multiple( $cil, "Added label '$label'", @issues );
+ if ( $cil->UseGit ) {
+ # if we want to commit these issues
+ if ( $args->{commit} ) {
+ if ( $args->{remove} ) {
+ $cil->git->commit_multiple( $cil, "Removed label '$label'", @issues );
+ }
+ else {
+ $cil->git->commit_multiple( $cil, "Added label '$label'", @issues );
+ }
}
}
}
Oops, something went wrong.

0 comments on commit 2d248eb

Please sign in to comment.