This file is indexed.

/usr/share/perl5/Rex/Commands/SCM.pm is in rex 1.4.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
#
# (c) Jan Gehring <jan.gehring@gmail.com>
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:

=head1 NAME

Rex::Commands::SCM - Sourcecontrol for Subversion and Git.

=head1 DESCRIPTION

With this module you can checkout subversion and git repositories.

Version <= 1.0: All these functions will not be reported.

All these functions are not idempotent.

=head1 SYNOPSIS

 use Rex::Commands::SCM;
 
 set repository => "myrepo",
    url => 'git@foo.bar:myrepo.git';
 
 set repository => "myrepo2",
    url      => "https://foo.bar/myrepo",
    type     => "subversion",
    username => "myuser",
    password => "mypass";
 
 task "checkout", sub {
   checkout "myrepo";
 
   checkout "myrepo",
     path => "webapp";
 
   checkout "myrepo",
     path   => "webapp",
     branch => 1.6;    # branch only for git
 
   # For Git only, will replay any local commits on top of pulled commits
   checkout "myrepo",
     path   => "script_dir",
     rebase => TRUE;
 
   checkout "myrepo2";
 };


=head1 EXPORTED FUNCTIONS

=cut

package Rex::Commands::SCM;

use strict;
use warnings;

our $VERSION = '1.4.1'; # VERSION

use Rex::Logger;
use Rex::Config;

require Rex::Exporter;
use base qw(Rex::Exporter);
use vars qw(@EXPORT %REPOS);
@EXPORT = qw(checkout);

Rex::Config->register_set_handler(
  "repository" => sub {
    my ( $name, %option ) = @_;
    $REPOS{$name} = \%option;
  }
);

=head2 checkout($name, %data);

With this function you can checkout a repository defined with I<set repository>. See Synopsis.

=cut

sub checkout {
  my ( $name, %data ) = @_;

  my $type = $REPOS{"$name"}->{"type"} ? $REPOS{$name}->{"type"} : "git";
  my $class = "Rex::SCM::\u$type";

  my $co_to = exists $data{"path"} ? $data{"path"} : "";

  if ( $data{"path"} ) {
    $data{"path"} = undef;
    delete $data{"path"};
  }

  eval "use $class;";
  if ($@) {
    Rex::Logger::info( "Error loading SCM: $@\n", "warn" );
    die("Error loading SCM: $@");
  }

  my $scm = $class->new;

  my $repo = Rex::Config->get("repository");
  Rex::Logger::debug("Checking out $repo -> $co_to");
  $scm->checkout( $REPOS{$name}, $co_to, \%data );
}

1;