App-Oozie
view release on metacpan or search on metacpan
lib/App/Oozie/Role/Git.pm view on Meta::CPAN
'--verify',
'refs/tags/' . $git_tag,
);
1;
} or do {
my $eval_error = $@ || 'Zombie error';
if ( $eval_error =~ m{ fatal: .* \Qnot a valid ref\E }xms ) {
$logger->error(
'Your repo does not seem to have the current live git-deploy tag.',
q{Be sure that your repo is up to date if you're using a local copy!},
'If you are in a branch, be sure to have the latest changes (merge/rebase).'
);
}
else {
$logger->error(
sprintf 'Unknown error returned from git: %s',
$eval_error,
);
}
$logger->logdie( 'Failed' ) if ! $gitforce;
};
$logger->info(
sprintf q{The current live tag `%s` exists in the repo (that doesn't show that the repo is up to date)},
$git_tag,
);
$logger->info(
'Probing the git status. This might take some time depending on the number of files and the state of the filesystem'
);
my(@dirty);
eval {
@dirty = $git->run('status', '--porcelain');
$logger->info( 'Collected the git status' );
1;
} or do {
my $eval_error = $@ || 'Zombie error';
if ( $eval_error =~ m{ \QNot a git repository (or any of the parent directories):\E }xms ) {
$logger->error(
sprintf(
'The repo directory %s is not a valid git repository.',
$repo_dir,
),
' Please deploy from a repo',
);
}
else {
$logger->error(
sprintf 'git returned unknown error: %s',
$eval_error,
);
}
$logger->logdie( 'Failed' ) if ! $gitforce;
};
return if not @dirty && !$gitforce;
# 'M file', '?? file'
@dirty = map {
(split m{ \s+ }xms, trim($_), 2)[1]
}
@dirty;
my $fail = 0;
foreach my $dirt ( @dirty ) {
my $test = $repo_dir . q{/} . $dirt;
if ( $test =~ m{ \A \Q$oozie_base_dir\E (.*) \z }xms) {
$test = $1;
$logger->warn(
sprintf 'The oozie workflow directory has untracked changes in %s',
$dirt,
);
$fail++;
}
else {
$logger->warn(
sprintf q{Git reported a modified/new file in the repo: %s (ignoring as it's not in the workflow directory)},
$test,
);
}
$self->dirty_deployed_files( $fail );
}
if ( $fail ) {
$logger->error(
sprintf 'Git tree is not clean and there are %s untracked changes in the workflow path. Please deploy from a clean repo',
$fail,
);
$logger->logdie( 'Failed' ) if ! $gitforce;
$logger->warn( q{Proceeding anyway, I hope you KNOW WHAT YOU'RE DOING} );
}
if ( !$fail || $fail && $gitforce ) {
$logger->info( 'The related paths are clean as far as git and this tool is concerned' );
}
return;
}
sub get_latest_git_tag {
my $self = shift;
die 'Git features are disabled!' if ! $self->gitfeatures;
my $pat = $self->git_deploy_tag_pattern;
my $latest_tag;
eval {
my $git = $self->git;
my @all_tags = $git->run(
'for-each-ref',
'--sort=taggerdate',
'--format' => q['%(refname)'],
'refs/tags'
);
for my $tag ( @all_tags ) {
chomp $tag;
( run in 1.796 second using v1.01-cache-2.11-cpan-6aa56a78535 )