Changeset 620080
- Timestamp:
- 11/01/2012 11:08:49 PM (13 years ago)
- File:
-
- 1 edited
-
repositoryzip/trunk/gitdownload.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
repositoryzip/trunk/gitdownload.php
r618589 r620080 32 32 // ========================================================================== 33 33 34 34 35 35 // create path and filenames 36 36 $lcZipName = tempnam(sys_get_temp_dir(), "gitzip_".$gitdata["hash"]); 37 $lcGit Name= sys_get_temp_dir()."/gitzip_".$gitdata["hash"];37 $lcGitWorkDir = sys_get_temp_dir()."/gitzip_".$gitdata["hash"]; 38 38 $lcGitDir = $lcGitName."/.git"; 39 39 40 41 40 42 41 // test if the directory exist, we do a git pull otherwise we do a clone … … 44 43 if (is_dir($lcGitName)) 45 44 { 45 46 46 array_push($param, "--git-dir=".$lcGitDir); 47 array_push($param, "--work-tree=".$lcGitWorkDir); 47 48 array_push($param, "pull"); 48 array_push($param, "-f"); 49 50 if (!runcmd($gitdata["gitcmd"], $param)) 51 die("error on fetching git repository"); 52 49 53 } else { 54 50 55 array_push($param, "clone"); 51 56 array_push($param, $gitdata["url"]); 52 array_push($param, $lcGit Name);57 array_push($param, $lcGitWorkDir); 53 58 54 59 // set branch / tag 55 60 if ( ($gitdata["type"] == "tag") || ($gitdata["type"] == "branch") ) 56 61 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 57 78 } 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 not63 // 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");67 79 68 80 … … 72 84 if ($zip->open($lcZipName, ZIPARCHIVE::CREATE) !== true) 73 85 die("zip file can not be created"); 74 addFiles2Zip($lcGit Name, $lcGitName, $zip);86 addFiles2Zip($lcGitWorkDir, $lcGitWorkDir, $zip); 75 87 $zip->close(); 76 88 sendBinaryFile($lcZipName, $gitdata["downloadtext"].".zip");
Note: See TracChangeset
for help on using the changeset viewer.