From 5c0a38cb0c01bc54849ca5f9990bfcc43c8dafc5 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 5 Nov 2018 14:49:08 +0800 Subject: [PATCH] sync --- GitRepo.vala | 37 ++++++++++++++++++++++++++++--------- NewBranch.bjs | 2 +- NewBranch.vala | 7 ++++--- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/GitRepo.vala b/GitRepo.vala index 823696ec..c7e60701 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -336,22 +336,41 @@ public class GitRepo : Object } - public void setActiveTicket(RooTicket ticket, string branchname) + public bool setActiveTicket(RooTicket ticket, string branchname) { - this.createBranchNamed(branchname); + if (!this.createBranchNamed(branchname)) { + return false; + } FileUtils.set_contents(this.gitdir + "/.gitlive-active-ticket" , ticket.id); this.activeTicket = ticket; } public void createBranchNamed(string branchname) { - if (this.branches.has_key(branchname)) { - string[] cmd = { "checkout", branchname }; - this.git(cmd); - } else { - string[] cmd = { "checkout", "-b" , branchname }; - this.git(cmd); - } + + try { + if (this.branches.has_key(branchname)) { + string[] cmd = { "checkout", branchname }; + this.git(cmd); + } else { + string[] cmd = { "checkout", "-b" , branchname }; + this.git(cmd); + } + var notification = new Notify.Notification( + "Changed to branch %s".printf(branchname), + "", + "dialog-information" + + ); + + notification.set_timeout(5); + notification.show(); + + + } catch(e) { + GitMonitor.gitmonitor.pauseError(e.message); + + } this.loadBranches(); // update branch list... GitMonitor.gitmonitor.runQueue(); // commit any outstanding... } diff --git a/NewBranch.bjs b/NewBranch.bjs index 20752db5..71c63851 100644 --- a/NewBranch.bjs +++ b/NewBranch.bjs @@ -10,7 +10,7 @@ { "listeners" : { "delete_event" : "(self, event) => {\n this.el.hide();\n this.running = false;\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\tGitMonitor.gitmonitor.start();\t \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\tGitMonitor.gitmonitor.start();\n\t\t this.running = false; \n\n\t \n\t \n\t \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\tGitMonitor.gitmonitor.start();\t \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\tvar success = true;\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tsuccess = this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tsuccess = this.repo.createBranchNamed(bn);\n\t\t}\n }\n\tGitMonitor.gitmonitor.start();\n this.running = false; \n\n\t \n\t \n\t \n\n\t \n}", "show" : "(self) => {\n \n\n //test\n}" }, "default_width" : 500, diff --git a/NewBranch.vala b/NewBranch.vala index 74d09e05..b3bc91d9 100644 --- a/NewBranch.vala +++ b/NewBranch.vala @@ -73,16 +73,17 @@ public class NewBranch : Object // -- initial load can check the contents of the ticket files on first scan. var ticket_id = _this.ticketsel.selectedTicketId(); + var success = true; if (this.repo != null) { var bn = _this.name.el.get_text(); if (ticket_id != "" ) { - this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn); + success = this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn); } else { - this.repo.createBranchNamed(bn); + success = this.repo.createBranchNamed(bn); } } GitMonitor.gitmonitor.start(); - this.running = false; + this.running = false; -- 2.39.2