sync
authorAlan Knowles <alan@roojs.com>
Mon, 5 Nov 2018 07:15:10 +0000 (15:15 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 5 Nov 2018 07:15:10 +0000 (15:15 +0800)
GitRepo.vala
NewBranch.bjs
NewBranch.vala

index 3f014ba..b1bb25f 100644 (file)
@@ -255,38 +255,38 @@ public class GitRepo : Object
     {
        // 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 = "";
+                  if (action == "CLOSE" || action == "LEAVE") {
+                                  
  
-                       try {
-                               var oldbranch = this.currentBranch.name;
-                               this.setActiveTicket(null, "master");
-                       string [] cmd = { "merge",   "--squash",  oldbranch };
-                       this.git( cmd );
-                        cmd = { "commit",   "--m",  commit_message };
-                       this.git( cmd );
-                       this.loadBranches(); // updates lastrev..
-                       
-                       var notification = new Notify.Notification(
-                                       "Merged branch %s to master".printf(oldbranch),
-                                       "",
-                                        "dialog-information"
-                                       
-                               );
-       
-                               notification.set_timeout(5);
-                               notification.show();   
-                       
-                       // close ticket..
-                       return true; 
-                       
-                   } catch (Error e) {
+               try {
+                       var oldbranch = this.currentBranch.name;
+                       this.setActiveTicket(null, "master");
+               string [] cmd = { "merge",   "--squash",  oldbranch };
+               this.git( cmd );
+                cmd = { "commit",   "--m",  commit_message };
+               this.git( cmd );
+               this.loadBranches(); // updates lastrev..
+               
+               var notification = new Notify.Notification(
+                               "Merged branch %s to master".printf(oldbranch),
+                               "",
+                                "dialog-information"
+                               
+                       );
 
-                       GitMonitor.gitmonitor.pauseError(e.message);
-                       return false;
-                   }
-                   // error~?? -- show the error dialog...
+                       notification.set_timeout(5);
+                       notification.show();   
+               
+               // close ticket..
+               return true; 
+               
+           } catch (Error e) {
+
+               GitMonitor.gitmonitor.pauseError(e.message);
+               return false;
+           }
+           // error~?? -- show the error dialog...
                    return false;
        }
        if (action == "MASTER") {
@@ -351,8 +351,26 @@ public class GitRepo : Object
                
                try {
                     if (this.branches.has_key(branchname)) {
-                           string[] cmd = { "checkout", branchname  };
-                           this.git(cmd);         
+                       // this is where it get's tricky...
+                       
+                       string[] cmd = { "ls-files" ,  "-m" };                   // list the modified files..
+                   var ret = this.git(cmd);
+                   var stash = ret.length> 1 ;
+                   
+                       
+                   cmd = { "stash" };                  
+                   if (stash) { this.git(cmd); }
+                   
+                   cmd = { "checkout", branchname  };
+                   this.git(cmd);
+                   
+                   cmd = { "merge", "master"  };
+                   this.git(cmd);
+                   
+                   cmd = { "stash", "pop"  };
+                   if (stash) { this.git(cmd); }
+                   
+                   
                    } else {
                            string[] cmd = { "checkout", "-b" , branchname  };
                            this.git(cmd);
index 78c314c..6af4ae2 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\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    if (success) {\n\t\tGitMonitor.gitmonitor.restoreQueue( this.queue );\n\t\tGitMonitor.gitmonitor.runQueue();    \n\t\tGitMonitor.gitmonitor.start();\n\t}\n    this.running = false; \t \n\t_this.el.hide();\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    if (success) {\n\t\tGitMonitor.gitmonitor.restoreQueue( this.queue );\n\t\tGitMonitor.gitmonitor.runQueue();    \n\t\tGitMonitor.gitmonitor.start();\n\t}\n    this.running = false; \t \n\t_this.el.hide();\n\t \n\t  \n}",
     "show" : "(self)  => {\n \n\n  //test\n}"
    },
    "default_width" : 500,
index 3ef225a..99733f4 100644 (file)
@@ -92,9 +92,7 @@ public class NewBranch : Object
             this.running = false;       
                _this.el.hide();
                 
-                
-        
-                
+                 
         });
         this.el.show.connect( (self)  => {