X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=bin%2Fgivi;h=2ea009ce9dd5bafe59f9eaa2fdfca7811e2ec32e;hb=c24be2289c776d9ee74980d0db74996804bd0eff;hp=1769577571d0d7e4da8d054095b2f078c684463b;hpb=58d8ecd09ab6c09f22741af507a09fca99a2976d;p=civicrm-core.git diff --git a/bin/givi b/bin/givi index 1769577571..2ea009ce9d 100755 --- a/bin/givi +++ b/bin/givi @@ -10,10 +10,18 @@ class DirStack { protected $dirs; + /** + * @param array $dirs + */ function __construct($dirs = array()) { $this->dirs = $dirs; } + /** + * @param $dir + * + * @throws Exception + */ function push($dir) { $this->dirs[] = getcwd(); if (!chdir($dir)) { @@ -66,6 +74,9 @@ class PullRequest { protected $data; + /** + * @return mixed + */ public function getNumber() { return $this->data->number; } @@ -85,6 +96,9 @@ class PullRequest { } } +/** + * Class Givi + */ class Givi { /** @@ -167,6 +181,9 @@ class Givi { */ protected $dirStack; + /** + * + */ function __construct() { $this->dirStack = new DirStack(); $this->repos = array( @@ -178,6 +195,11 @@ class Givi { ); } + /** + * @param $args + * + * @throws Exception + */ function main($args) { if (!$this->parseOptions($args)) { printf("Error parsing arguments\n"); @@ -350,6 +372,11 @@ class Givi { echo "local branches.\n"; } + /** + * @param null $baseBranch + * + * @return bool + */ function doCheckoutAll($baseBranch = NULL) { if (!$baseBranch) { return $this->returnError("Missing \n"); @@ -366,6 +393,9 @@ class Givi { return TRUE; } + /** + * @return bool + */ function doStatusAll() { foreach ($this->repos as $repo => $relPath) { $this->run($repo, $relPath, 'git', 'status'); @@ -373,6 +403,11 @@ class Givi { return TRUE; } + /** + * @param null $baseBranch + * + * @return bool + */ function doBegin($baseBranch = NULL) { if (!$baseBranch) { return $this->returnError("Missing \n"); @@ -400,6 +435,12 @@ class Givi { return TRUE; } + /** + * @param null $baseBranch + * + * @return bool + * @throws Exception + */ function doResume($baseBranch = NULL) { if (!$baseBranch) { return $this->returnError("Missing \n"); @@ -426,6 +467,11 @@ class Givi { return TRUE; } + /** + * @param null $baseBranch + * + * @return bool + */ function doReview($baseBranch = NULL) { if (! $this->doCheckoutAll($baseBranch)) { return FALSE; @@ -491,6 +537,12 @@ class Givi { } */ + /** + * @param $newBranchRepo + * @param $newBranchNames + * + * @return bool + */ function doPush($newBranchRepo, $newBranchNames) { if (!$newBranchRepo) { return $this->returnError("Missing \n"); @@ -534,6 +586,9 @@ class Givi { * FIXME: only supports $refs like "foo" (implicit origin) or "myremote/foo" * * @param $ref + * @param string $defaultRemote + * + * @throws Exception * @return array */ function parseBranchRepo($ref, $defaultRemote = 'origin') { @@ -554,8 +609,10 @@ class Givi { * * Any items after $command will be escaped and added to $command * + * @param $repoName * @param string $runDir * @param string $command + * * @return string */ function run($repoName, $runDir, $command) { @@ -589,6 +646,8 @@ class Givi { /** * @param string $default branch to use by default + * @param $overrides + * * @return array ($repoName => $gitRef) */ function resolveBranches($default, $overrides) { @@ -601,6 +660,12 @@ class Givi { return $branches; } + /** + * @param $repoName + * @param $branchName + * + * @return string + */ function filterBranchName($repoName, $branchName) { if ($branchName == '') { return ''; @@ -617,6 +682,8 @@ class Givi { /** * @param string $filter e.g. "all" or "repo1,repo2" * @param array $repos ($repoName => $repoDir) + * + * @throws Exception * @return array ($repoName => $repoDir) */ function filterRepos($filter, $repos) { @@ -636,6 +703,11 @@ class Givi { return $repos; } + /** + * @param $message + * + * @return bool + */ function returnError($message) { echo "\nERROR: ", $message, "\n\n"; $this->doHelp(); @@ -643,7 +715,16 @@ class Givi { } } +/** + * Class HttpClient + */ class HttpClient { + /** + * @param $url + * @param $file + * + * @return bool + */ static function download($url, $file) { // PHP native client is unreliable PITA for HTTPS if (exec("which wget")) { @@ -656,6 +737,11 @@ class HttpClient { return TRUE; } + /** + * @param $url + * + * @return mixed + */ static function getJson($url) { $file = tempnam(sys_get_temp_dir(), 'givi-json-'); HttpClient::download($url, $file); @@ -669,8 +755,9 @@ class HttpClient { * * Any items after $command will be escaped and added to $command * - * @param string $runDir * @param string $command + * + * @internal param string $runDir * @return string */ static function run($command) {