Changeset 1800 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/VCS.pm


Ignore:
Timestamp:
Nov 29, 2013, 7:45:03 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Start to support git-svn
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/VCS.pm

    r1678 r1800  
    1616use strict 'vars';
    1717use Carp 'confess';
     18use Cwd 'abs_path';
    1819use Data::Dumper;
    1920use English;
     
    184185    }
    185186} elsif ($scheme =~ /^git/) {
    186     if (defined $source) {
    187         if (-d $source) {
    188             $tmp = $destdir;
     187    if ($scheme =~ /svn/) {
     188        if (defined $source) {
     189            if (-d $source) {
     190                $tmp = $destdir;
     191            } else {
     192                $tmp = "$destdir/".basename($source);
     193            }
     194            $source = pb_vcs_mod_htftp($source,"git");
     195            pb_system("$vcscmd clone $source $tmp","Exporting $source from $scheme to $tmp ");
    189196        } else {
    190             $tmp = "$destdir/".basename($source);
    191         }
    192         $source = pb_vcs_mod_htftp($source,"git");
    193         pb_system("cd $source ; $vcscmd archive --format=tar HEAD | (mkdir $tmp && cd $tmp && tar xf -)","Exporting $source/HEAD from GIT to $tmp ");
    194     } else {
    195         $uri = pb_vcs_mod_htftp($uri,"git");
    196         pb_system("$vcscmd clone $uri $destdir","Exporting $uri from GIT to $destdir ");
     197            $uri = pb_vcs_mod_htftp($uri,"git");
     198            pb_system("$vcscmd clone $uri $destdir","Exporting $uri from $scheme to $destdir ");
     199        }
     200    } else {
     201        if (defined $source) {
     202            if (-d $source) {
     203                $tmp = $destdir;
     204            } else {
     205                $tmp = "$destdir/".basename($source);
     206            }
     207            $source = pb_vcs_mod_htftp($source,"git");
     208            pb_system("cd $source ; $vcscmd archive --format=tar HEAD | (mkdir $tmp && cd $tmp && tar xf -)","Exporting $source/HEAD from GIT to $tmp ");
     209        } else {
     210            $uri = pb_vcs_mod_htftp($uri,"git");
     211            pb_system("$vcscmd clone $uri $destdir","Exporting $uri from GIT to $destdir ");
     212        }
    197213    }
    198214} elsif ($scheme =~ /^cvs/) {
     
    267283    chomp($res);
    268284} elsif ($scheme =~ /^git/) {
    269     open(GIT,"git --git-dir=$dir/.git remote -v 2> /dev/null |") || return("");
    270     while (<GIT>) {
    271         next unless (/^origin\s+(\S+) \(push\)$/);
    272         return $1;
    273     }
    274     close(GIT);
    275     warn "Unable to find origin remote for $dir";
    276     return "";
     285    if ($scheme =~ /svn/) {
     286        my $cwd = abs_path();
     287        chdir($dir) || return("");;
     288        open(PIPE,"LANGUAGE=C $vcscmd info . 2> /dev/null |") || return("");
     289        chdir($cwd) || return("");
     290        while (<PIPE>) {
     291            ($void,$res) = split(/^URL:/) if (/^URL:/);
     292        }
     293        $res =~ s/^\s*//;
     294        close(PIPE);
     295        chomp($res);
     296        # We've got an SVN ref so add git in front of it for coherency
     297        $res = "git+".$res;
     298    } else {
     299        # Pure git
     300        open(GIT,"LANGUAGE=C $vcscmd --git-dir=$dir/.git remote -v 2> /dev/null |") || return("");
     301        while (<GIT>) {
     302            next unless (/^origin\s+(\S+) \(push\)$/);
     303            return $1;
     304        }
     305        close(GIT);
     306        warn "Unable to find remote origin for $dir";
     307        return "";
     308    }
    277309} elsif ($scheme =~ /^cvs/) {
    278310    # This path is always the root path of CVS, but we may be below
     
    492524=item B<pb_vcs_isdiff>
    493525
    494 This function returns a integer indicating the number f differences between the VCS content and the local directory where it's checked out.
     526This function returns a integer indicating the number of differences between the VCS content and the local directory where it's checked out.
    495527The first parameter is the schema of the VCS systems (svn, cvs, svn+ssh, ...)
    496528The second parameter is the directory to consider.
     
    559591
    560592if ($scheme =~ /hg/) {
    561     return($cmd."hg".$cmdopt)
     593    $cmd .= "hg".$cmdopt;
    562594} elsif ($scheme =~ /git/) {
    563     return($cmd."git".$cmdopt)
     595    if ($scheme =~ /svn/) {
     596        $cmd .= "git svn".$cmdopt;
     597    } else {
     598        $cmd .= "git".$cmdopt;
     599    }
    564600} elsif ($scheme =~ /svn/) {
    565     return($cmd."svn".$cmdopt)
     601    $cmd .= "svn".$cmdopt;
    566602} elsif ($scheme =~ /svk/) {
    567     return($cmd."svk".$cmdopt)
     603    $cmd .= "svk".$cmdopt;
    568604} elsif ($scheme =~ /cvs/) {
    569     return($cmd."cvs".$cmdopt)
     605    $cmd .= "cvs".$cmdopt;
    570606} elsif (($scheme =~ /http/) || ($scheme =~ /ftp/)) {
    571607    my $command = pb_check_req("wget",1);
    572608    if (-x $command) {
    573         return($cmd."$command -nv -O ");
     609        $cmd .= "$command -nv -O ";
    574610    } else {
    575611        $command = pb_check_req("curl",1);
    576612        if (-x $command) {
    577             return($cmd."$command -o ");
     613            $cmd .= "$command -o ";
    578614        } else {
    579615            confess "Unable to handle $scheme.\nNo wget/curl available, please install one of those";
     
    581617    }
    582618} else {
    583     return($cmd);
    584 }
     619    $cmd = "";
     620}
     621pb_log(3,"pb_vcs_cmd returns $cmd\n");
     622return($cmd);
    585623}
    586624
Note: See TracChangeset for help on using the changeset viewer.