Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get Issue insertion functioning and add some stub classes for Milesto…

…nes and Users
  • Loading branch information...
commit e093d89003c1e7b73df74ff117fe45a9d64327d3 1 parent 81fc746
@danielbeardsley danielbeardsley authored
View
7 git_users.php
@@ -0,0 +1,7 @@
+<?php
+
+class GitUsers {
+ public static function fromTrac($tracUser) {
+ return "danielbeardsley";
+ }
+}
View
9 github.php
@@ -25,8 +25,13 @@ public function post($url, $json, $patch = false) {
}
$ret = curl_exec($ch);
if(!$ret) {
- trigger_error(curl_error($ch));
- }
+ trigger_error(curl_error($ch));
+ }
+
+ if (($code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) && ($code < 200 || $code > 299)) {
+ fwrite(STDERR, "Unsuccessful API Request:\n". $ret);
+ }
+
curl_close($ch);
return $ret;
}
View
7 milestones.php
@@ -0,0 +1,7 @@
+<?php
+
+class Milestones {
+ public static function gitId($tracMilestone) {
+ return null;//"danielbeardsley";
+ }
+}
View
8 ticket.php
@@ -1,4 +1,6 @@
<?php
+require("git_users.php");
+require("milestones.php");
class Ticket {
public static $github;
@@ -8,7 +10,7 @@ class Ticket {
public static function loadFromTrac($id) {
$q_select = "SELECT * FROM `ticket` WHERE `id` = $id";
- $result = Trac::query($q_select);
+ $result = Trac::queryRow($q_select);
return $result ? new self($result) : null;
}
@@ -22,7 +24,7 @@ public function toIssueJson() {
'title' => $this->attr['summary'],
'body' => $this->translateDescription(),
'assignee' => GitUsers::fromTrac($this->attr['owner']) ?: $this->attr['owner'],
- 'milestone' => GitMilestones::fromTrac($this->attr['milestone'])
+ 'milestone' => Milestones::gitId($this->attr['milestone'])
);
return $json;
@@ -30,7 +32,7 @@ public function toIssueJson() {
public function saveToGithub() {
self::$github->add_issue($this->toIssueJson());
- if ($this->$attr['status'] == 'closed') {
+ if ($this->attr['status'] == 'closed') {
self::$github->update_issue($this->id, array('state' => 'closed'));
}
}
View
6 trac.php
@@ -16,4 +16,10 @@ public static function query($statement) {
return $resultSet->fetchAll();
}
+
+ public static function queryRow($statement) {
+ $resultSet = self::$db->query($statement);
+
+ return $resultSet->fetch();
+ }
}

0 comments on commit e093d89

Please sign in to comment.
Something went wrong with that request. Please try again.