New feature: Branch name for software products

This commit is contained in:
Steffen Lange 2020-04-01 17:25:40 +02:00
parent dd3be30e56
commit 3d037ec2b3
5 changed files with 13 additions and 6 deletions

View file

@ -45,16 +45,16 @@ class Database {
}
function find(string $id) : PatchObject {
foreach ($this->data as $obj) {
if (strcmp($obj->GetId(), $id) == 0) {
if (strcmp($obj->getId(), $id) == 0) {
return $obj;
}
}
return new PatchObject();
}
function addOrUpdate(PatchObject $patch) {
$patch->SetTimestamp($this->time);
$patch->setTimestamp($this->time);
foreach ($this->data as &$obj) {
if (strcmp($obj->GetId(), $patch->GetId()) == 0) {
if (strcmp($obj->getId(), $patch->getId()) == 0) {
$obj = $patch;
return;
}

View file

@ -34,7 +34,7 @@ abstract class PatchBase {
}
protected function parse(string $re) : bool {
if ($str = $this->regex_str($re)) {
$this->patch->SetVersion($str);
$this->patch->setVersion($str);
return true;
}
return false;
@ -42,7 +42,7 @@ abstract class PatchBase {
protected function parse_json(string $key) : bool {
$flat = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data)));
if (!empty($flat[$key])) {
$this->patch->SetVersion($flat[$key]);
$this->patch->setVersion($flat[$key]);
return true;
}
return false;

View file

@ -13,6 +13,7 @@ foreach (new \DirectoryIterator(__DIR__ . '/modules') as $file) {
}
}
}
shuffle($list);
$db = new Database(__DIR__ . '/db.json');
echo 'Time: ' . date('c', $db->time()) . PHP_EOL;

View file

@ -32,6 +32,9 @@ class PatchObject {
function getBranch() : string {
return $this->branch;
}
function setBranch(string $branch) {
$this->branch = $branch;
}
function getVersion() : string {
return $this->version;
}

View file

@ -31,7 +31,10 @@ $twitter = new Twitter($TwitterConsumerKey, $TwitterConsumerSecret, $TwitterAcce
for ($i = 0; $i < $db->count(); $i++) {
$patch = $db->get($i);
if ($last < $patch->getTimestamp()) {
$s = $patch->getVendor() . ' released #' . $patch->getProduct() . ' version ' . $patch->getVersion() . '. ' . $patch->getURL();
$s = $patch->getVendor() . ' released #' . $patch->getProduct();
if (!empty($patch->getBranch()))
$s .= ' ' . $patch->getBranch();
$s .= ' version ' . $patch->getVersion() . '. ' . $patch->getURL();
try {
$twitter->send($s);
} catch (DG\Twitter\Exception $e) {