projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #4333 from jitendrapurohit/webtestfixes
[civicrm-core.git]
/
bin
/
givi
diff --git
a/bin/givi
b/bin/givi
index da9f07da825bc39298338600fb5811f5ce87436b..2ea009ce9dd5bafe59f9eaa2fdfca7811e2ec32e 100755
(executable)
--- a/
bin/givi
+++ b/
bin/givi
@@
-10,10
+10,18
@@
class DirStack {
protected $dirs;
class DirStack {
protected $dirs;
+ /**
+ * @param array $dirs
+ */
function __construct($dirs = array()) {
$this->dirs = $dirs;
}
function __construct($dirs = array()) {
$this->dirs = $dirs;
}
+ /**
+ * @param $dir
+ *
+ * @throws Exception
+ */
function push($dir) {
$this->dirs[] = getcwd();
if (!chdir($dir)) {
function push($dir) {
$this->dirs[] = getcwd();
if (!chdir($dir)) {
@@
-43,7
+51,7
@@
class PullRequest {
*/
public static function get($url, $repos) {
foreach ($repos as $repo => $relPath) {
*/
public static function get($url, $repos) {
foreach ($repos as $repo => $relPath) {
- if (preg_match("/^https:\/\/github.com\/(.*)\/(civicrm-{$repo})\/pull\/([0-9]+)$/", $url, $matches)) {
+ if (preg_match("/^https:\/\/github.com\/(.*)\/(civicrm-{$repo})\/pull\/([0-9]+)
(|\/commits|\/files)
$/", $url, $matches)) {
list ($full, $githubUser, $githubRepo, $githubPr) = $matches;
$pr = new PullRequest();
list ($full, $githubUser, $githubRepo, $githubPr) = $matches;
$pr = new PullRequest();
@@
-66,6
+74,9
@@
class PullRequest {
protected $data;
protected $data;
+ /**
+ * @return mixed
+ */
public function getNumber() {
return $this->data->number;
}
public function getNumber() {
return $this->data->number;
}
@@
-85,6
+96,9
@@
class PullRequest {
}
}
}
}
+/**
+ * Class Givi
+ */
class Givi {
/**
class Givi {
/**
@@
-167,6
+181,9
@@
class Givi {
*/
protected $dirStack;
*/
protected $dirStack;
+ /**
+ *
+ */
function __construct() {
$this->dirStack = new DirStack();
$this->repos = array(
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");
function main($args) {
if (!$this->parseOptions($args)) {
printf("Error parsing arguments\n");
@@
-350,6
+372,11
@@
class Givi {
echo "local branches.\n";
}
echo "local branches.\n";
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ */
function doCheckoutAll($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <branch>\n");
function doCheckoutAll($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <branch>\n");
@@
-366,6
+393,9
@@
class Givi {
return TRUE;
}
return TRUE;
}
+ /**
+ * @return bool
+ */
function doStatusAll() {
foreach ($this->repos as $repo => $relPath) {
$this->run($repo, $relPath, 'git', 'status');
function doStatusAll() {
foreach ($this->repos as $repo => $relPath) {
$this->run($repo, $relPath, 'git', 'status');
@@
-373,6
+403,11
@@
class Givi {
return TRUE;
}
return TRUE;
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ */
function doBegin($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <base-branch>\n");
function doBegin($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <base-branch>\n");
@@
-400,6
+435,12
@@
class Givi {
return TRUE;
}
return TRUE;
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ * @throws Exception
+ */
function doResume($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <base-branch>\n");
function doResume($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <base-branch>\n");
@@
-426,6
+467,11
@@
class Givi {
return TRUE;
}
return TRUE;
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ */
function doReview($baseBranch = NULL) {
if (! $this->doCheckoutAll($baseBranch)) {
return FALSE;
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 <remote>\n");
function doPush($newBranchRepo, $newBranchNames) {
if (!$newBranchRepo) {
return $this->returnError("Missing <remote>\n");
@@
-534,6
+586,9
@@
class Givi {
* FIXME: only supports $refs like "foo" (implicit origin) or "myremote/foo"
*
* @param $ref
* 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') {
* @return array
*/
function parseBranchRepo($ref, $defaultRemote = 'origin') {
@@
-554,8
+609,10
@@
class Givi {
*
* Any items after $command will be escaped and added to $command
*
*
* Any items after $command will be escaped and added to $command
*
+ * @param $repoName
* @param string $runDir
* @param string $command
* @param string $runDir
* @param string $command
+ *
* @return string
*/
function run($repoName, $runDir, $command) {
* @return string
*/
function run($repoName, $runDir, $command) {
@@
-589,6
+646,8
@@
class Givi {
/**
* @param string $default branch to use by default
/**
* @param string $default branch to use by default
+ * @param $overrides
+ *
* @return array ($repoName => $gitRef)
*/
function resolveBranches($default, $overrides) {
* @return array ($repoName => $gitRef)
*/
function resolveBranches($default, $overrides) {
@@
-601,6
+660,12
@@
class Givi {
return $branches;
}
return $branches;
}
+ /**
+ * @param $repoName
+ * @param $branchName
+ *
+ * @return string
+ */
function filterBranchName($repoName, $branchName) {
if ($branchName == '') {
return '';
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)
/**
* @param string $filter e.g. "all" or "repo1,repo2"
* @param array $repos ($repoName => $repoDir)
+ *
+ * @throws Exception
* @return array ($repoName => $repoDir)
*/
function filterRepos($filter, $repos) {
* @return array ($repoName => $repoDir)
*/
function filterRepos($filter, $repos) {
@@
-636,6
+703,11
@@
class Givi {
return $repos;
}
return $repos;
}
+ /**
+ * @param $message
+ *
+ * @return bool
+ */
function returnError($message) {
echo "\nERROR: ", $message, "\n\n";
$this->doHelp();
function returnError($message) {
echo "\nERROR: ", $message, "\n\n";
$this->doHelp();
@@
-643,7
+715,16
@@
class Givi {
}
}
}
}
+/**
+ * Class HttpClient
+ */
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")) {
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;
}
return TRUE;
}
+ /**
+ * @param $url
+ *
+ * @return mixed
+ */
static function getJson($url) {
$file = tempnam(sys_get_temp_dir(), 'givi-json-');
HttpClient::download($url, $file);
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
*
*
* Any items after $command will be escaped and added to $command
*
- * @param string $runDir
* @param string $command
* @param string $command
+ *
+ * @internal param string $runDir
* @return string
*/
static function run($command) {
* @return string
*/
static function run($command) {