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)) {
protected $data;
+ /**
+ * @return mixed
+ */
public function getNumber() {
return $this->data->number;
}
}
}
+/**
+ * Class Givi
+ */
class Givi {
/**
*/
protected $dirStack;
+ /**
+ *
+ */
function __construct() {
$this->dirStack = new DirStack();
$this->repos = array(
);
}
+ /**
+ * @param $args
+ *
+ * @throws Exception
+ */
function main($args) {
if (!$this->parseOptions($args)) {
printf("Error parsing arguments\n");
echo "local branches.\n";
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ */
function doCheckoutAll($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <branch>\n");
return TRUE;
}
+ /**
+ * @return bool
+ */
function doStatusAll() {
foreach ($this->repos as $repo => $relPath) {
$this->run($repo, $relPath, 'git', 'status');
return TRUE;
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ */
function doBegin($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <base-branch>\n");
return TRUE;
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ * @throws Exception
+ */
function doResume($baseBranch = NULL) {
if (!$baseBranch) {
return $this->returnError("Missing <base-branch>\n");
return TRUE;
}
+ /**
+ * @param null $baseBranch
+ *
+ * @return bool
+ */
function doReview($baseBranch = NULL) {
if (! $this->doCheckoutAll($baseBranch)) {
return FALSE;
}
*/
+ /**
+ * @param $newBranchRepo
+ * @param $newBranchNames
+ *
+ * @return bool
+ */
function doPush($newBranchRepo, $newBranchNames) {
if (!$newBranchRepo) {
return $this->returnError("Missing <remote>\n");
return $branches;
}
+ /**
+ * @param $repoName
+ * @param $branchName
+ *
+ * @return string
+ */
function filterBranchName($repoName, $branchName) {
if ($branchName == '') {
return '';
return $repos;
}
+ /**
+ * @param $message
+ *
+ * @return bool
+ */
function returnError($message) {
echo "\nERROR: ", $message, "\n\n";
$this->doHelp();
}
}
+/**
+ * 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")) {
return TRUE;
}
+ /**
+ * @param $url
+ *
+ * @return mixed
+ */
static function getJson($url) {
$file = tempnam(sys_get_temp_dir(), 'givi-json-');
HttpClient::download($url, $file);