Changeset 2586 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/VCS.pm
- Timestamp:
- Apr 3, 2020, 2:02:03 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/VCS.pm
r2498 r2586 371 371 my $vcscmd = pb_vcs_cmd($scheme); 372 372 373 pb_log(3,"scheme: $scheme - dir: $dir - vcscmd: $vcscmd\n"); 373 374 if ($scheme =~ /^svn/) { 374 375 open(PIPE,"LANGUAGE=C $vcscmd info $dir 2> /dev/null |") || return(""); 375 376 while (<PIPE>) { 376 ($void,$res) = split(/^URL:/) if (/^URL:/); 377 pb_log(4,"line: $_"); 378 if (/^URL[\s]*:/) { 379 ($void,$res) = split(/^URL[\s]*:/); 380 last; 381 } 377 382 } 378 383 $res =~ s/^\s*//; 379 384 close(PIPE); 380 385 chomp($res); 386 pb_log(3,"res $res\n"); 381 387 } elsif ($scheme =~ /^svk/) { 382 388 open(PIPE,"LANGUAGE=C $vcscmd info $dir 2> /dev/null |") || return(""); … … 402 408 chdir($cwd) || return(""); 403 409 while (<PIPE>) { 404 ($void,$res) = split(/^URL :/) if (/^URL:/);410 ($void,$res) = split(/^URL[\s]*:/) if (/^URL[\s]*:/); 405 411 } 406 412 $res =~ s/^\s*//; … … 614 620 sub pb_vcs_add_if_not_in { 615 621 my $scheme = shift; 616 my @f = @_;617 622 my $vcscmd = pb_vcs_cmd($scheme); 618 623 619 624 if ($scheme =~ /^((hg)|(git)|(svn)|(svk)|(cvs))/o) { 620 for my $f (@ f) {625 for my $f (@_) { 621 626 my $uri = pb_vcs_get_uri($scheme,$f); 622 pb_vcs_add($scheme,$f) if ($uri !~ /^$scheme/); 627 pb_log(3,"f: $f - scheme: $scheme - uri: $uri\n"); 628 my ($scheme2, $a, $h, $p, $n) = pb_get_uri($uri); 629 pb_vcs_add($scheme,$f) if ("$scheme2" ne "$scheme"); 623 630 } 624 631 } elsif ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)\b/o) { … … 663 670 push(@f1,dirname($f)) if (-f $f); 664 671 } 672 # Wrong we need to push instead 665 673 pb_vcs_up($scheme,@f1); 666 674 } … … 768 776 } 769 777 778 =item B<pb_vcs_mkdir> 779 780 This function makes a VCS directory 781 The first parameter is the schema of the VCS systems (svn, cvs, svn+ssh, ...) 782 The second parameter is the directory to create. 783 The third parameter is the comment to pass during the commit 784 785 =cut 786 787 sub pb_vcs_mkdir { 788 my $scheme = shift; 789 my $dir = shift; 790 my $msg = shift; 791 my $vcscmd = pb_vcs_cmd($scheme); 792 793 if ($scheme =~ /^((svn)|(cvs)|(svk))/o) { 794 pb_system("$vcscmd mkdir -m \"$msg\" $dir","Making VCS directory $dir"); 795 } elsif ($scheme =~ /^git/) { 796 #pb_system("cd $dir && git init ", "Making VCS directory $dir"); 797 ## + git remote add + git push 798 } elsif ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)\b/o) { 799 # Nothing to do. 800 } else { 801 confess "cms $scheme unknown"; 802 } 803 } 804 805 806 770 807 =item B<pb_vcs_compliant> 771 808 … … 777 814 The fifth parameter indicates whether we should inititate the context or not. 778 815 816 Only called for PBCONFDIR and PBDIR 779 817 =cut 780 818 … … 809 847 eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg }; 810 848 pb_log(2,"$envar: $ENV{$envar}\n"); 849 my $exportdir = $ENV{$envar}; 811 850 812 851 my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri); … … 816 855 pb_log(1,"pb_vcs_compliant useless\n"); 817 856 return; 818 } elsif ((defined $pbinit) || (! -d "$ENV{$envar}")) { 819 my $exportdir = $ENV{$envar}; 857 } elsif ((defined $pbinit) && (! -d "$exportdir")) { 820 858 # Either we have a version in the uri, and it should be the same 821 859 # as the one in the envar. Or we should add the version to the uri … … 824 862 $uri .= "/".basename($exportdir); 825 863 } 826 if ((defined $pbinit) && ($scheme =~ /git/)) { 827 # If initializing remove the potential pbconf part if we treat pbconfdir 828 $exportdir =~ s|pbconf[/]*||; 829 } 830 pb_log(1,"Checking out $uri\n"); 831 # Create structure and remove end dir before exporting 864 832 865 pb_mkdir_p("$exportdir"); 833 pb_rm_rf($exportdir); 866 # Should only have pbconf 867 if ((pb_path_nbfiles(dirname($exportdir)) > 1) && ($envar eq 'PBCONFDIR')) { 868 confess("Directory ".dirname($exportdir)." has content.\nPlease remove it if you want to use that directory\n"); 869 } 870 if (pb_path_nbfiles("$exportdir") > 0) { 871 confess("Directory $exportdir has content.\nPlease remove it if you want to use that directory\n"); 872 } 873 if ($envar eq 'PBCONFDIR') { 874 # Remove the potential pbconf part if we treat pbconfdir 875 $exportdir =~ s|/pbconf[/]*||; 876 $uri =~ s|/pbconf[/]*||; 877 } 878 # Don't add content here as it may conflict later on with PBROOT addition 879 # Done in Env.pm 880 pb_log(0,"Trying to check out (may fail) ".$uri."\n"); 834 881 pb_vcs_checkout($scheme,$uri,$exportdir); 835 if ((defined $pbinit) && ($scheme =~ /git/)) { 836 # And now created the potentially missing pbconf dir 837 pb_mkdir_p("$exportdir/pbconf"); 838 } 882 if (($envar eq 'PBCONFDIR') && (pb_path_nbfiles("$exportdir/pbconf") == 0)) { 883 # Export failed, because there is nothing yet in the repo 884 # we now need to clean stuff before doing mkdir to avoid conflicts 885 pb_rm_rf($exportdir); 886 pb_log(0,"Pushing first $uri\n"); 887 pb_vcs_mkdir($scheme,$uri,"Creating structure directory"); 888 pb_vcs_mkdir($scheme,"$uri/pbconf","Creating structure sub directory"); 889 pb_log(0,"Re-Trying to check out again $uri\n"); 890 pb_vcs_up($scheme,$exportdir); 891 } 892 pb_log(0,"Done\n"); 839 893 } else { 840 894 pb_log(1,"$uri found locally, checking content\n");
Note:
See TracChangeset
for help on using the changeset viewer.