sync
authorAlan Knowles <alan@roojs.com>
Mon, 5 Nov 2018 06:49:08 +0000 (14:49 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 5 Nov 2018 06:49:08 +0000 (14:49 +0800)
GitRepo.vala
NewBranch.bjs
NewBranch.vala

index 823696e..c7e6070 100644 (file)
@@ -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...
     }
index 20752db..71c6385 100644 (file)
@@ -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,
index 74d09e0..b3bc91d 100644 (file)
@@ -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;