Plugin Directory

Changeset 620080


Ignore:
Timestamp:
11/01/2012 11:08:49 PM (13 years ago)
Author:
flashpixx
Message:

git download

File:
1 edited

Legend:

Unmodified
Added
Removed
  • repositoryzip/trunk/gitdownload.php

    r618589 r620080  
    3232// ==========================================================================
    3333
    34 
     34   
    3535// create path and filenames
    3636$lcZipName      = tempnam(sys_get_temp_dir(), "gitzip_".$gitdata["hash"]);
    37 $lcGitName      = sys_get_temp_dir()."/gitzip_".$gitdata["hash"];
     37$lcGitWorkDir   = sys_get_temp_dir()."/gitzip_".$gitdata["hash"];
    3838$lcGitDir       = $lcGitName."/.git";
    3939
    40    
    4140   
    4241// test if the directory exist, we do a git pull otherwise we do a clone
     
    4443if (is_dir($lcGitName))
    4544{
     45   
    4646    array_push($param, "--git-dir=".$lcGitDir);
     47    array_push($param, "--work-tree=".$lcGitWorkDir);
    4748    array_push($param, "pull");
    48     array_push($param, "-f");
     49   
     50    if (!runcmd($gitdata["gitcmd"], $param))
     51        die("error on fetching git repository"); 
     52   
    4953} else {
     54   
    5055    array_push($param, "clone");
    5156    array_push($param, $gitdata["url"]);
    52     array_push($param, $lcGitName);
     57    array_push($param, $lcGitWorkDir);
    5358     
    5459    // set branch / tag
    5560    if ( ($gitdata["type"] == "tag") || ($gitdata["type"] == "branch") )
    5661        array_push($param, "-b".$gitdata["name"]);
     62   
     63    if (!runcmd($gitdata["gitcmd"], $param))
     64        die("error on cloning git repository");
     65   
     66    if (!empty($gitdata["version"]))
     67    {
     68        $param = array();
     69        array_push($param, "--git-dir=".$lcGitDir);
     70        array_push($param, "--work-tree=".$lcGitWorkDir);
     71        array_push($param, "checkout");
     72        array_push($param, $gitdata["version"]);
     73       
     74        if (!runcmd($gitdata["gitcmd"], $param))
     75            die("commit can not be checked out");
     76    }
     77   
    5778}
    58          
    59 if (!runcmd($gitdata["gitcmd"], $param))
    60     die("error on cloning / pulling git repository");
    61    
    62 // if version not empty, check out the special version (only on cloning, after that we do not
    63 // need this again, because a version can not be modified without changes the hash)
    64 if (!empty($gitdata["version"]) && ($param[0] == "clone"))
    65     if (!runcmd($gitdata["gitcmd"], array("--git-dir=".$lcGitDir, "checkout", $gitdata["version"], "-f")))
    66         die("commit can not be checked out");
    6779   
    6880   
     
    7284if ($zip->open($lcZipName, ZIPARCHIVE::CREATE) !== true)
    7385    die("zip file can not be created");
    74 addFiles2Zip($lcGitName, $lcGitName, $zip);
     86addFiles2Zip($lcGitWorkDir, $lcGitWorkDir, $zip);
    7587$zip->close();
    7688sendBinaryFile($lcZipName, $gitdata["downloadtext"].".zip");
Note: See TracChangeset for help on using the changeset viewer.