Allow setting owner, description, clone/push url metadata in the project array
This adds four new keys to the project array metadata:
'owner': overrides the owner of the project
'description': overrides the description of the project
'cloneurl': overrides the clone url of the project, can be an empty
string to explicitly remove the clone url
'pushurl': overrides the push url of the project, can be an empty string
to explicitly remove the push url
--- a/config/projects.conf.php.example
+++ b/config/projects.conf.php.example
@@ -23,6 +23,21 @@
* Each project itself is an array with the following keys:
* 'project': the path to the project, minus the projectroot
* 'category': the category for the project. This is optional.
+ * 'owner': the owner of the project. This is optional,
+ * and overrides the actual owner
+ * 'description': the description of the project. This is optional,
+ * and overrides the description in the project's
+ * description file
+ * 'cloneurl': the full clone url of the project. This is optional,
+ * and overrides the clone URL setting in the config for
+ * this project. This can also be an empty string to
+ * override the config clone url to say that only this
+ * project has no clone url.
+ * 'pushurl': the full push url of the project. This is optional,
+ * and overrides the push URL setting in the config for
+ * this project. This can also be an empty string to
+ * override the config push url to say that only this
+ * project has no push url.
*/
//$git_projects = array(
// array(
@@ -35,6 +50,10 @@
// array(
// 'project' => 'php/gitphp.git',
// 'category' => 'PHP',
+// 'description' => 'GitPHP, a web-based git repository browser in PHP',
+// 'owner' => 'Christopher Han',
+// 'cloneurl' => 'http://git.xiphux.com/php/gitphp.git',
+// 'pushurl' => ''
// ),
// array(
// 'project' => 'php/mdb.git',
--- a/include/git/Project.class.php
+++ b/include/git/Project.class.php
@@ -134,6 +134,24 @@
protected $readTags = false;
/**
+ * cloneUrl
+ *
+ * Stores the clone url internally
+ *
+ * @access protected
+ */
+ protected $cloneUrl = null;
+
+ /**
+ * pushUrl
+ *
+ * Stores the push url internally
+ *
+ * @access protected
+ */
+ protected $pushUrl = null;
+
+ /**
* commitCache
*
* Caches fetched commit objects in case of
@@ -321,6 +339,20 @@
}
/**
+ * SetDescription
+ *
+ * Overrides the project description
+ *
+ * @access public
+ * @param string $descr description
+ */
+ public function SetDescription($descr)
+ {
+ $this->description = $descr;
+ $this->readDescription = true;
+ }
+
+ /**
* GetDaemonEnabled
*
* Returns whether gitdaemon is allowed for this project
@@ -369,6 +401,9 @@
*/
public function GetCloneUrl()
{
+ if ($this->cloneUrl !== null)
+ return $this->cloneUrl;
+
$cloneurl = GitPHP_Config::GetInstance()->GetValue('cloneurl', '');
if (!empty($cloneurl))
$cloneurl .= $this->project;
@@ -376,6 +411,19 @@
}
/**
+ * SetCloneUrl
+ *
+ * Overrides the clone URL for this repository
+ *
+ * @access public
+ * @param string $cUrl clone url
+ */
+ public function SetCloneUrl($cUrl)
+ {
+ $this->cloneUrl = $cUrl;
+ }
+
+ /**
* GetPushUrl
*
* Gets the push URL for this repository, if specified
@@ -385,10 +433,26 @@
*/
public function GetPushUrl()
{
+ if ($this->pushUrl !== null)
+ return $this->pushUrl;
+
$pushurl = GitPHP_Config::GetInstance()->GetValue('pushurl', '');
if (!empty($pushurl))
$pushurl .= $this->project;
return $pushurl;
+ }
+
+ /**
+ * SetPushUrl
+ *
+ * Overrides the push URL for this repository
+ *
+ * @access public
+ * @param string $pUrl push url
+ */
+ public function SetPushUrl($pUrl)
+ {
+ $this->pushUrl = $pUrl;
}
/**
--- a/include/git/ProjectListArray.class.php
+++ b/include/git/ProjectListArray.class.php
@@ -60,6 +60,18 @@
if (isset($projData['category']) && is_string($projData['category'])) {
$projObj->SetCategory($projData['category']);
}
+ if (isset($projData['owner']) && is_string($projData['owner'])) {
+ $projObj->SetOwner($projData['owner']);
+ }
+ if (isset($projData['description']) && is_string($projData['description'])) {
+ $projObj->SetDescription($projData['description']);
+ }
+ if (isset($projData['cloneurl']) && is_string($projData['cloneurl'])) {
+ $projObj->SetCloneUrl($projData['cloneurl']);
+ }
+ if (isset($projData['pushurl']) && is_string($projData['pushurl'])) {
+ $projObj->SetPushUrl($projData['pushurl']);
+ }
$this->projects[] = $projObj;
} catch (Exception $e) {
}