Commit: 742a5efc772a25fdb19c18048780d71167a2facf Author: Stephen Zarkos <[email protected]> Wed, 21 Nov 2012 15:30:42 -0800 Parents: be31b985b0c93375abff9cc2450243d7ff671620 Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=742a5efc772a25fdb19c18048780d71167a2facf Log: Add initial Git support Changed paths: M client/data/config/repo/phpnet.ini A client/include/Git.php Diff: diff --git a/client/data/config/repo/phpnet.ini b/client/data/config/repo/phpnet.ini index ea781cd..f9d35ca 100644 --- a/client/data/config/repo/phpnet.ini +++ b/client/data/config/repo/phpnet.ini @@ -1,3 +1,3 @@ -name=phpnet -type=svn -url=http://svn.php.net/repository +name=phpnet +type=git +url=git://git.php.net \ No newline at end of file diff --git a/client/include/Git.php b/client/include/Git.php new file mode 100644 index 0000000..d585c85 --- /dev/null +++ b/client/include/Git.php @@ -0,0 +1,56 @@ +<?php +namespace rmtools; + +class Git { + public $repo_url; + public $module; + public $branch; + private $git_cmd = 'c:\apps\git\bin\git.exe'; + private $tar_cmd = 'c:\apps\git\bin\tar.exe'; + + public function __construct($repo_url) + { + $this->repo_url = $repo_url; + } + + function setModule($module) { + $this->module = $module; + } + + function setBranch($branch) { + $this->branch = $branch; + } + + public function export($dest, $revision = false) + { + $http_url = preg_replace('/git:\/\//', 'http://', $this->repo_url); + $url = $http_url . '/?p=' . $this->module . ';a=snapshot;h=' . $this->branch . ';sf=zip'; + $dest .= '.zip'; + wget($url, $dest); + return $dest; + } + + public function info() + { + } + + public function getLastCommitId() + { + $try = 3; + $cmd = $this->git_cmd . ' ls-remote ' . $this->repo_url . '/' . $this->module . ' ' . $this->branch; + while ( $try > 0 ) { + $res = exec_sep_log($cmd); + if ($res && !empty($res['log_stdout'])) { + break; + } + $try--; + } + if ($res && $res['return_value'] != 0) { + throw new \Exception('git ls-remote failed <' . $this->repo_url . '/' . $this->module . ' ' . $this->branch . '>, ' . $res['log_stderr']); + } + + $revision = preg_replace("/[\s\t]+.+/", "", $res['log_stdout']); + $revision = trim($revision); + return (string)$revision; + } +} -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
