Skip to content

Commit

Permalink
Add perl signatures to lib::OpenQA::Git
Browse files Browse the repository at this point in the history
  • Loading branch information
FruitFly638 committed Feb 1, 2022
1 parent 8668c08 commit 555824e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions lib/OpenQA/Git.pm
Expand Up @@ -3,29 +3,25 @@

package OpenQA::Git;

use Mojo::Base -base;
use Mojo::Base -base, -signatures;
use Cwd 'abs_path';
use OpenQA::Utils qw(run_cmd_with_log_return_error);

has 'app';
has 'dir';
has 'user';

sub enabled {
my ($self) = @_;
sub enabled ($self) {
die 'no app assigned' unless my $app = $self->app;
return ($app->config->{global}->{scm} || '') eq 'git';
}

sub config {
my ($self) = @_;
sub config ($self) {
die 'no app assigned' unless my $app = $self->app;
return $app->config->{'scm git'};
}

sub _prepare_git_command {
my ($self, $args) = @_;

sub _prepare_git_command ($self, $args) {
my $dir = $args->{dir} // $self->dir;
if ($dir !~ /^\//) {
my $absolute_path = abs_path($dir);
Expand All @@ -34,25 +30,20 @@ sub _prepare_git_command {
return ('git', '-C', $dir);
}

sub _format_git_error {
my ($git_result, $error_message) = @_;

sub _format_git_error ($git_result, $error_message) {
if ($git_result->{stderr}) {
$error_message .= ': ' . $git_result->{stderr};
}
return $error_message;
}

sub _validate_attributes {
my ($self) = @_;

sub _validate_attributes ($self) {
for my $mandatory_property (qw(app dir user)) {
die "no $mandatory_property specified" unless $self->$mandatory_property();
}
}

sub set_to_latest_master {
my ($self, $args) = @_;
sub set_to_latest_master ($self, $args) {
$self->_validate_attributes;

my @git = $self->_prepare_git_command($args);
Expand All @@ -70,8 +61,7 @@ sub set_to_latest_master {
return undef;
}

sub commit {
my ($self, $args) = @_;
sub commit ($self, $args) {
$self->_validate_attributes;

my @git = $self->_prepare_git_command($args);
Expand Down

0 comments on commit 555824e

Please sign in to comment.