//RooTicket? ticket = null;
- public void doMerge(string action, string ticket_id, string commit_message)
+ public static void doMerges(string action, string ticket_id, string commit_message)
+ {
+ var commitrevs = "";
+ var sucess = true;
+ foreach(var repo in GitRepo.singleton().cache.values) {
+ if (repo.activeTicket != null && repo.activeTicket.id == ticket_id) {
+ var res = repo.doMerge(action,ticket_id, commit_message);
+ if (!res) {
+ sucess = false;
+ continue;
+ }
+ commitrevs += commitrevs.length > 0 ? " " : "";
+ commitrevs += repo.currentBranch.lastrev;
+ }
+ }
+ if (sucess && action == "CLOSE") {
+ RooTicket.singleton().getById(ticket_id).close(commitrevs);
+ }
+ }
+
+
+ public bool doMerge(string action, string ticket_id, string commit_message)
{
// in theory we should check to see if other repo's have got the same branch and merge all them at the same time.
// also need to decide which branch we will merge into?
+ var ret = "";
if (action == "CLOSE" || action == "LEAVE") {
- var ret = "";
+
try {
+ var oldbranch = this.currentBranch.name;
string[] cmd = { "checkout", "master" };
this.git( cmd );
cmd = { "merge", "--squash", this.currentBranch.name };
this.git( cmd );
this.loadBranches();
+ var notification = new Notify.Notification(
+ "Merged branch %s to master".printf(oldbranch),
+ "",
+ "dialog-information"
+
+ );
+
+ notification.set_timeout(5);
+ notification.show();
+
// close ticket..
- if (action == "CLOSE") {
- RooTicket.singleton().getById(ticket_id).close();
- }
+ return true;
} catch (Error e) {
- ret += e.message + "\n";
+
+ GitMonitor.gitmonitor.pauseError(e.message);
+ return false;
}
// error~?? -- show the error dialog...
- return;
+ return false;
}
if (action == "MASTER") {
// merge master into ours..
try {
string[] cmd = { "merge", "master" };
this.git( cmd );
+ var notification = new Notify.Notification(
+ "Merged code from master to %s".printf(this.currentBranch.name),
+ "",
+ "dialog-information"
+
+ );
+ notification.set_timeout(5);
+ notification.show();
+
+ return true;
} catch (Error e) {
- ret += e.message + "\n";
+ GitMonitor.gitmonitor.pauseError(e.message);
+ return false;
}
- return;
}
if (action == "EXIT") {
- try {
+ try {
+ var oldbranch = this.currentBranch.name;
string[] cmd = { "checkout", "master" };
this.git( cmd );
this.loadBranches();
+ var notification = new Notify.Notification(
+ "Left branch %s".printf(oldbranch),
+ "",
+ "dialog-information"
+
+ );
+ notification.set_timeout(5);
+ notification.show();
+ return true;
} catch (Error e) {
- ret += e.message + "\n";
+ GitMonitor.gitmonitor.pauseError(e.message);
+
+ return false;
}
// error~?? -- show the error dialog...
- return;
+
}
+ return false;
}
{
"listeners" : {
"delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ",
- "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t\n\t this.running = false; \n\t \treturn;\n\t}\n\t /*\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n }\n\t*/\n\t\n\trepo.doMerge(_this.actionsel.selectedAction(), \n\t\t\t\t_this.ticketsel.selectedTicketId(),\n\t\t\t\t_this.name.el.get_text()\n\t\t);\n\t\n\tthis.running = false; \n\n\t \n\t_this.el.hide();\t\n \n\n\t \n}",
+ "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t\n\t this.running = false; \n\t \treturn;\n\t}\n\t /*\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n }\n\t*/\n\t\n\tGitRepo.doMerges(\n\t\t_this.actionsel.selectedAction(), \n\t\t_this.ticketsel.selectedTicketId(),\n\t\t_this.name.el.get_text()\n\t);\n\t\n\tthis.running = false; \n\n\t \n\t_this.el.hide();\t\n \n\n\t \n}",
"show" : "(self) => {\n \n\n //test\n}"
},
"default_width" : 500,
{
"id" : "name",
"$ visible" : true,
- "| void updateText" : "() {\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n\tRooTicket ticket = null\n\tif (ticket_id.length > 0){\n\t\tticket = RooTicket.singleton().getById(ticket_id);\n\t}\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\tvar action = _this.actionsel.selectedAction();\n\tthis.el.set_editable(true); \n \tswitch (action) {\n \t\tcase \"CLOSE\": // merge changes and close..\n\t \t\tthis.el.set_text(\"Fix #%s - %s\".printf(ticket_id, ticket != null ? ticket.summary : \"\"));\n\t \t\tbreak;\n\t \tcase \"LEAVE\": // partial fix\t\n\t \t\tthis.el.set_text(\"Partial Fix #%s - %s\".printf(ticket_id, ticket != null ? ticket.summary : \"\"));\n\t \t\tbreak;\n \t\tcase \"MASTER\": // merge master\n \t\tcase \"EXIT\": // just switch back... \t\t\n \t\t\tthis.el.set_editable(false);\n\t \t\tthis.el.set_text(\"\"); // not relivant.. \t\t\t\n\t\t\tbreak;\n \t\tdefault:\n \t\t\n \t\t\tbreak; /// don't fix the text value.\n\t}\n \n}\n",
+ "| void updateText" : "() {\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n\tRooTicket ticket = null;\n\tif (ticket_id.length > 0){\n\t\tticket = RooTicket.singleton().getById(ticket_id);\n\t}\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\tvar action = _this.actionsel.selectedAction();\n\tthis.el.set_editable(true); \n \tswitch (action) {\n \t\tcase \"CLOSE\": // merge changes and close..\n\t \t\tthis.el.set_text(\"Fix #%s - %s\".printf(ticket_id, ticket != null ? ticket.summary : \"\"));\n\t \t\tbreak;\n\t \tcase \"LEAVE\": // partial fix\t\n\t \t\tthis.el.set_text(\"Partial Fix #%s - %s\".printf(ticket_id, ticket != null ? ticket.summary : \"\"));\n\t \t\tbreak;\n \t\tcase \"MASTER\": // merge master\n \t\tcase \"EXIT\": // just switch back... \t\t\n \t\t\tthis.el.set_editable(false);\n\t \t\tthis.el.set_text(\"\"); // not relivant.. \t\t\t\n\t\t\tbreak;\n \t\tdefault:\n \t\t\n \t\t\tbreak; /// don't fix the text value.\n\t}\n \n}\n",
"xtype" : "Entry",
"* pack" : "attach_defaults,1,2,2,3",
"$ xns" : "Gtk"
}
*/
- repo.doMerge(_this.actionsel.selectedAction(),
- _this.ticketsel.selectedTicketId(),
- _this.name.el.get_text()
- );
+ GitRepo.doMerges(
+ _this.actionsel.selectedAction(),
+ _this.ticketsel.selectedTicketId(),
+ _this.name.el.get_text()
+ );
this.running = false;
public void updateText () {
var ticket_id = _this.ticketsel.selectedTicketId();
- RooTicket ticket = null
+ RooTicket ticket = null;
if (ticket_id.length > 0){
ticket = RooTicket.singleton().getById(ticket_id);
}
public class RooTicket : Object
{
+ const string baseurl = "https://roojs.com/admin.php/Roo/mtrack_ticket";
public static RooTicket singleton()
{
}
}
- const string baseurl = "https://roojs.com/admin.php/Roo/mtrack_ticket";
+
public void loadTickets()
{
}
+ public void close(string commits)
+ {
+ var table = new GLib.HashTable<string, string>(str_hash, str_equal);
+ table.insert("id",id);
+ table.insert("status_name","resolved");
+ table.insert("reason","fixed by Commits: %s".printf(commits));
+ var params = Soup.Form.encode_hash(table);
+
+ GLib.debug("request POST %s / %s", baseurl, id);
+
+ var session = new Soup.Session ();
+ session.timeout = 0;
+ var message = new Soup.Message ("POST", baseurl);
+ RooTicket.setAuth(message);
+
+ message.set_request ("application/x-www-form-urlencoded", Soup.MemoryUse.STATIC, params.data);
+ session.send_message (message);
+
+
+ var data = (string) message.response_body.flatten().data;
+ GLib.debug("got %s", data);
+ try {
+ var parser = new Json.Parser ();
+ parser.load_from_data (data, -1);
+ var response = parser.get_root().get_object();
+ var status = response.get_boolean_member("success");
+
+ if(!status){
+ GLib.error(response.get_string_member("errorMsg"));
+ return ;
+ }
+
+
+
+
+ } catch (Error e) {
+ GLib.error(e.message);
+ return ;
+ }
+
+ }