For projects under version control (and they should all be under version control), tag each submission with a version. Keep track of branches, tag, remote, etc.
=head2 Attributes
=cut
=head3 version
Version of our submission. Has a corresponding git tag.
=cut
option 'version'=> (
is=> 'rw',
required=> 0,
predicate=> 'has_version',
documentation=>
'Submission version. Each version has a corresponding git tag. See the difference between tags with `git diff tag1 tag2`. Tags are always version numbers, starting with 0.01.',
);
option 'autocommit'=> (
traits=> ['Bool'],
is=> 'rw',
isa=> 'Bool',
default=> 1,
documentation=> 'Run a git add -A on dirty build',
handles=> { no_autocommit=> 'unset', },
);
has'git_dir'=> (
is=> 'rw',
isa=> 'Str',
default=> sub{ returncwd() },
predicate=> 'has_git_dir',
);
has'git'=> (
is=> 'rw',
predicate=> 'has_git',
required=> 0,
);
has'current_branch'=> (
is=> 'rw',
isa=> 'Str',
required=> 0,
predicate=> 'has_current_branch',
);
has'remote'=> (
is=> 'rw',
isa=> 'Str',
required=> 0,
predicate=> 'has_remote',
);
#TODO Create option for adding archive
=head2 Subroutines
=cut
=head3 init_git
Create a new Git::Wrapper object
=cut
subinit_git {
my$self= shift;
my$git= Git::Wrapper->new( cwd() )
or dieprint"Could not initialize Git::Wrapper $!\n";
try{
my@output= $git->rev_parse(qw(--show-toplevel));
$self->git_dir( $output[0] );
$git= Git::Wrapper->new( $self->git_dir );
$self->git($git);
}
}
subgit_info {
my$self= shift;
returnunless$self->has_git;
$self->branch_things;
$self->get_version;
}
=head3 dirty_run
Check for uncommited files
#TODO add in option for autocommiting
=cut
subdirty_run {
my$self= shift;
returnunless$self->has_git;
my$dirty_flag= $self->git->status->is_dirty;
if( $dirty_flag&& !$self->autocommit ) {
$self->app_log->warn(
"There are uncommited files in your repo!\n\tPlease commit these files."
);
}
elsif( $dirty_flag&& $self->autocommit ) {
$self->app_log->warn(
"There are uncommited files in your repo!\n\tWe will try to commit these files before running."