sync
authorAlan Knowles <alan@roojs.com>
Fri, 2 Nov 2018 05:02:09 +0000 (13:02 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 2 Nov 2018 05:02:09 +0000 (13:02 +0800)
GitMonitor.vala
GitMonitorQueue.vala
GitRepo.vala
NewBranch.bjs
NewBranch.vala
RooTicket.vala

index 92733e3..8776fbe 100644 (file)
@@ -13,7 +13,7 @@ public class GitMonitor : Monitor
        public static string gitlive;
        
        
-       public Array<GitMonitorQueue> queue ;
+       private Gee.ArrayList<GitMonitorQueue> queue ;
        public bool queueRunning = false;
        
        public DateTime lastAdd;
@@ -23,14 +23,14 @@ public class GitMonitor : Monitor
        public GitMonitor ()
        {
        
-               this.queue = new Array<GitMonitorQueue>();
+               this.queue = new Gee.ArrayList<GitMonitorQueue>();
                GitMonitor.gitmonitor = this;
                Timeout.add_full(Priority.LOW, 500, () => {
 
                        //GLib.debug("TIMEOUT queue length = %d, is_runing = %s\n", (int)this.queue.length , this.queueRunning ? "Y" : "N");
 
                        //stdout.printf("QL %u: QR: %d\n", this.queue.length, this.queueRunning ? 1 : 0);
-                       if (this.queue.length < 1  || this.queueRunning) {
+                       if (this.queue.size < 1  || this.queueRunning) {
                                return true;
                        }
                        
@@ -82,7 +82,7 @@ public class GitMonitor : Monitor
                this.paused = true;
                this.queueRunning = false;
                // what does this do to the old one...
-               this.queue = new Array<GitMonitorQueue> ();
+               //this.queue = new Gee.ArrayList<GitMonitorQueue> ();
                this.stop();
                StatusIconA.statusicon.pauseError();
                
@@ -103,7 +103,7 @@ public class GitMonitor : Monitor
        public new void pause() {
                this.paused = true;
                // what does this do to the old one...
-               this.queue = new Array<GitMonitorQueue> ();
+               //this.queue = new Gee.ArrayList<GitMonitorQueue> ();
                StatusIconA.statusicon.pause();
 
        }
@@ -217,13 +217,13 @@ public class GitMonitor : Monitor
 
                this.queueRunning = true;
 
-               var cmds = new Array<GitMonitorQueue>();
+               var cmds = new Gee.ArrayList<GitMonitorQueue>();
 
-               for(var i = 0; i < this.queue.length; i++) {
-                       cmds.append_val(this.queue.index(i));
+               for(var i = 0; i < this.queue.size; i++) {
+                       cmds.add(this.queue.get(i));
                }
 
-               this.queue = new Array<GitMonitorQueue>();// empty queue!
+               this.queue = new Gee.ArrayList<GitMonitorQueue>();// empty queue!
 
                
                string[] success = {};
@@ -244,9 +244,9 @@ public class GitMonitor : Monitor
                var leave_queued = new Gee.ArrayList<GitMonitorQueue>();
                GLib.debug("GitMonitor.runQueue - creating repos");
                
-               for(var i = 0; i < cmds.length; i++) {
+               for(var i = 0; i < cmds.size; i++) {
                   
-                       var cmd = cmds.index(i);
+                       var cmd = cmds.get(i);
                
                        var gitpath = cmd.gitpath; 
                        
@@ -270,9 +270,11 @@ public class GitMonitor : Monitor
                        //    repo_list[gitpath].cmds = [];
                         //   repo_list[gitpath].pull();
                        //}
-                       repo_list.index(ix).cmds.append_val(cmd);
+                       repo_list.index(ix).cmds.add(cmd);
 
                }
+               this.queue = leave_queued;
+               
                this.paused = false;
                // build add, remove and commit message list..
 
@@ -282,14 +284,14 @@ public class GitMonitor : Monitor
         
                        var repo = repo_list.index(i);
 
-                       var add_files = new Array<GitMonitorQueue>();
-                       var add_files_f = new Array<GitMonitorQueue>();
-                       var remove_files = new Array<GitMonitorQueue>();
-                       var messages = new Array<GitMonitorQueue>();
+                       var add_files = new Gee.ArrayList<GitMonitorQueue>();
+                       var add_files_f = new Gee.ArrayList<GitMonitorQueue>();
+                       var remove_files = new Gee.ArrayList<GitMonitorQueue>();
+                       var messages = new Gee.ArrayList<GitMonitorQueue>();
                        //print(JSON.stringify(repo.cmds,null,4));
                        
-                       for(var ii = 0;ii < repo.cmds.length;ii++) {
-                               var cmd = repo.cmds.index(ii);
+                       for(var ii = 0;ii < repo.cmds.size;ii++) {
+                               var cmd = repo.cmds.get(ii);
        
                                if (repo.is_ignore(cmd.vname)) {
                                        continue;
@@ -303,7 +305,7 @@ public class GitMonitor : Monitor
                                                   break;
                                                }
                                                
-                                               add_files.append_val(cmd);
+                                               add_files.add(cmd);
                                                break;
                                        
                                        case "rm":
@@ -316,14 +318,14 @@ public class GitMonitor : Monitor
                                                        break;
                                                }
                                                
-                                               remove_files.append_val(cmd);
+                                               remove_files.add(cmd);
                                                break;
                                        
                                        case "commit" :
                                                if (GitMonitorQueue.indexOfMessage(messages, cmd.message) > -1 ) {
                                                   break;
                                                }
-                                               messages.append_val(cmd);
+                                               messages.add(cmd);
                                                
                                                break;
                                        default:
@@ -353,37 +355,35 @@ public class GitMonitor : Monitor
                        */
                        
                        // if file was added, then removed, 
-                       var remove_files_f = new Array<GitMonitorQueue>();
-                       for(var ii = 0;ii < remove_files.length;ii++) {
+                       var remove_files_f = new Gee.ArrayList<GitMonitorQueue>();
+                       for(var ii = 0;ii < remove_files.size;ii++) {
                                
                                
                                
-                               if (GitMonitorQueue.indexOfAdd(add_files,  remove_files.index(ii).vname) > -1 ) {
+                               if (GitMonitorQueue.indexOfAdd(add_files,  remove_files.get(ii).vname) > -1 ) {
                                        // in add and remove - do not remvove
                                        continue;
                                }
-                               remove_files_f.append_val(remove_files.index(ii));
+                               remove_files_f.add(remove_files.get(ii));
                        };
-                       for(var ii = 0;ii < add_files.length;ii++) {
-                               if (GitMonitorQueue.indexOfAdd(remove_files,  add_files.index(ii).vname) > -1 ) {
+                       for(var ii = 0;ii < add_files.size;ii++) {
+                               if (GitMonitorQueue.indexOfAdd(remove_files,  add_files.get(ii).vname) > -1 ) {
                                        // the add file is in the remove list, and it does not exist - do not add it..
-                                       print("check exists ? %s\n",add_files.index(ii).fullpath());
+                                       print("check exists ? %s\n",add_files.get(ii).fullpath());
                                        
-                                       if (!FileUtils.test(add_files.index(ii).fullpath(), FileTest.EXISTS)) {
+                                       if (!FileUtils.test(add_files.get(ii).fullpath(), FileTest.EXISTS)) {
                                                        continue;
                                        }
                                         
-                               }
-                               
-                               
+                               } 
                                
-                               add_files_f.append_val(add_files.index(ii));
+                               add_files_f.add(add_files.get(ii));
                        };
                        
                        GLib.debug( "ADD : %s", GitMonitorQueue.queueArrayToString(add_files_f));
                        GLib.debug( "REMOVE FILES: %s", GitMonitorQueue.queueArrayToString(remove_files_f));
                    
-                   if (add_files_f.length < 1 && remove_files_f.length < 1) {
+                   if (add_files_f.size < 1 && remove_files_f.size < 1) {
                                continue;
                    }
                    
@@ -419,8 +419,7 @@ public class GitMonitor : Monitor
                                failure +=  e.message;
                                GLib.debug("Remove failed:");
                        }  
-
-
                        try { 
                                success += repo.commit(
                                        GitMonitorQueue.messageToString(messages),
@@ -428,6 +427,7 @@ public class GitMonitor : Monitor
                                );
                                success += repo.push();
 
+
                        } catch(Error e) {
                        
                                // if the error is 'nothing to commit, working tree clean'
@@ -541,12 +541,17 @@ public class GitMonitor : Monitor
                }
                */
                cmd.action = "add";
-               this.queue.append_val(cmd);
+               this.queue.add(cmd);
 
                cmd = new GitMonitorQueue(src);
                cmd.action = "commit";
                cmd.message = cmd.vname;
-               this.queue.append_val(cmd);
+               this.queue.add(cmd);
+               
+               
+                if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
+                NewBranch.singleton().show(cmd.repo);
+         }
  
                 
        }
@@ -565,14 +570,19 @@ public class GitMonitor : Monitor
                // should check if monitor needs removing..
                // it should also check if it was a directory.. - so we dont have to commit all..
                cmd.action = "rm";
-               this.queue.append_val(cmd);
+               this.queue.add(cmd);
 
                cmd = new GitMonitorQueue(src);
                cmd.action = "commit";
                cmd.message = cmd.vname;
                cmd.commit_all = true;
 
-               this.queue.append_val(cmd);
+               this.queue.add(cmd);
+               
+                if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
+                       NewBranch.singleton().show(cmd.repo);
+               }
+               
  
        }
        public override  void onCreated(MonitorNamePathDir src) {
@@ -606,7 +616,8 @@ public class GitMonitor : Monitor
 
        }
 
-       public  override void onAttributeChanged(MonitorNamePathDir src) { 
+       public  override void onAttributeChanged(MonitorNamePathDir src) 
+       { 
 
                if (this.paused) {
                        return;
@@ -622,12 +633,16 @@ public class GitMonitor : Monitor
                        return;
                }
                cmd.action = "add";
-               this.queue.append_val(cmd);
+               this.queue.add(cmd);
 
                cmd = new GitMonitorQueue(src);
                cmd.action = "commit";
                cmd.message = "Attribute changed " + cmd.vname;
-               this.queue.append_val(cmd);
+               this.queue.add(cmd);
+               
+               if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
+                       NewBranch.singleton().show(cmd.repo);
+        }
        }
  
    public  override void onMoved(MonitorNamePathDir src,MonitorNamePathDir dest)  
@@ -668,13 +683,13 @@ public class GitMonitor : Monitor
                
                GLib.debug("RM: %s", cmd_s.vname);
                cmd_s.action = "rm";
-               this.queue.append_val(cmd_s);
+               this.queue.add(cmd_s);
 
                
                
                GLib.debug("ADD: %s", cmd_d.vname);
                cmd_d.action = "add";
-               this.queue.append_val(cmd_d);
+               this.queue.add(cmd_d);
 
 
                var cmd = new GitMonitorQueue(dest);
@@ -684,9 +699,17 @@ public class GitMonitor : Monitor
                        cmd.message = cmd_d.vname;
                }
                
-               this.queue.append_val(cmd);
-
+               
+               this.queue.add(cmd);
 
+               if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
+                       NewBranch.singleton().show(cmd.repo);
+        }
+        // this is where it get's complicated...
+        // as we might be moving across repo's...
+        
+        
+        
                 
        }
           
index 6ed40e7..1fd88f7 100644 (file)
@@ -44,9 +44,7 @@ public class GitMonitorQueue : MonitorNamePathDir {
                        this.repo = GitRepo.get(this.gitpath);
                        
                        // trigger the suggestion to start a new branch
-                       if (!this.shouldIgnore() && !this.repo.is_wip_branch()) {
-                               NewBranch.singleton().show(this.repo);
-                       }
+                       
                }
 
 
@@ -102,50 +100,50 @@ public class GitMonitorQueue : MonitorNamePathDir {
                
                /** -- statics --*/
                
-               public static int indexOfAdd( Array<GitMonitorQueue> add_files, string add)
+               public static int indexOfAdd( Gee.ArrayList<GitMonitorQueue> add_files, string add)
                {
-                       for(var i =0; i < add_files.length; i++) {
-                               if (add_files.index(i).vname == add) {
+                       for(var i =0; i < add_files.size; i++) {
+                               if (add_files.get(i).vname == add) {
                                        return i;
                                }
                        }
                        return -1;
                }
-               public static  int indexOfMessage(Array<GitMonitorQueue> messages, string message)  {
-                       for(var i =0; i < messages.length; i++) {
-                               if (messages.index(i).message == message) {
+               public static  int indexOfMessage(Gee.ArrayList<GitMonitorQueue> messages, string message)  {
+                       for(var i =0; i < messages.size; i++) {
+                               if (messages.get(i).message == message) {
                                        return i;
                                }
                        }
                        return -1;
                }
-               public static string messageToString(Array<GitMonitorQueue> messages ) {
+               public static string messageToString(Gee.ArrayList<GitMonitorQueue> messages ) {
                        string[] ret = {};
-                       for(var i =0; i < messages.length; i++) {
-                               ret+= messages.index(i).message;
+                       for(var i =0; i < messages.size; i++) {
+                               ret += messages.get(i).message;
                        }
                        return string.joinv("\n",ret);
                }
-               public static string queueArrayToString(Array<GitMonitorQueue> list) {
+               public static string queueArrayToString(Gee.ArrayList<GitMonitorQueue> list) {
                        var ret = "";
-                       for(var i =0; i < list.length; i++) {
+                       for(var i =0; i < list.size; i++) {
                                
-                               ret += (ret.length > 0 ? ", " : "") + list.index(i).vname;
+                               ret += (ret.length > 0 ? ", " : "") + list.get(i).vname;
                        }
                        return ret;
                        
                }
                
-               public static bool  queueHas(Array<GitMonitorQueue> list , GitMonitorQueue cmd_s, string action) {
-                       for(var i =0; i < list.length; i++) {
-                               var test = list.index(i);
-                               if (list.index(i).gitpath != cmd_s.gitpath) {
+               public static bool  queueHas(Gee.ArrayList<GitMonitorQueue> list , GitMonitorQueue cmd_s, string action) {
+                       for(var i =0; i < list.size; i++) {
+                               var test = list.get(i);
+                               if (list.get(i).gitpath != cmd_s.gitpath) {
                                        continue;
                                }
-                               if (list.index(i).vname != cmd_s.vname) {
+                               if (list.get(i).vname != cmd_s.vname) {
                                        continue;
                                }
-                               if (list.index(i).action != action) {
+                               if (list.get(i).action != action) {
                                        continue;
                                }
                                return true;
index 2df125a..185c97d 100644 (file)
@@ -12,7 +12,7 @@ static GitRepo  _GitRepo;
 public class GitRepo : Object
 {
      
-    public Array<GitMonitorQueue> cmds;
+    public Gee.ArrayList<GitMonitorQueue> cmds;
 
     public string name;
     public string gitdir;
@@ -159,7 +159,7 @@ public class GitRepo : Object
         if (!FileUtils.test(this.gitdir , FileTest.IS_DIR)) {
             this.gitdir = path; // naked...
         }
-        this.cmds = new  Array<GitMonitorQueue> ();
+        this.cmds = new  Gee.ArrayList<GitMonitorQueue> ();
         
                var cache = GitRepo.singleton().cache;
         //Repo.superclass.constructor.call(this,cfg);
@@ -171,7 +171,7 @@ public class GitRepo : Object
     
     public bool is_wip_branch()
     {
-       return this.currentBranch.name.has_prefix("wip_")
+       return this.currentBranch.name.has_prefix("wip_");
                
     }
     
@@ -249,14 +249,14 @@ public class GitRepo : Object
      *
      * @argument {Array} files the files to add.
      */
-    public string add ( Array<GitMonitorQueue> files ) throws Error, SpawnError
+    public string add ( Gee.ArrayList<GitMonitorQueue> files ) throws Error, SpawnError
     {
         // should really find out if these are untracked files each..
         // we run multiple versions to make sure that if one failes, it does not ignore the whole lot..
         // not sure if that is how git works.. but just be certian.
         var ret = "";
-        for (var i = 0; i < files.length;i++) {
-            var f = files.index(i).vname;
+        for (var i = 0; i < files.size;i++) {
+            var f = files.get(i).vname;
             try {
                 string[] cmd = { "add",    f  };
                 this.git( cmd );
@@ -296,7 +296,7 @@ public class GitRepo : Object
      *
      * @argument {Array} files the files to add.
      */
-    public string remove  ( Array<GitMonitorQueue> files ) throws Error, SpawnError
+    public string remove  ( Gee.ArrayList<GitMonitorQueue> files ) throws Error, SpawnError
     {
         // this may fail if files do not exist..
         // should really find out if these are untracked files each..
@@ -304,8 +304,8 @@ public class GitRepo : Object
         // not sure if that is how git works.. but just be certian.
         var ret = "";
 
-        for (var i = 0; i < files.length;i++) {
-            var f = files.index(i).vname;
+        for (var i = 0; i < files.size;i++) {
+            var f = files.get(i).vname;
             try {
                 string[] cmd = { "rm",  "-f" ,  f  };
                 this.git( cmd );
@@ -333,7 +333,7 @@ public class GitRepo : Object
      * 
      */
      
-    public string commit ( string message, Array<GitMonitorQueue> files  ) throws Error, SpawnError
+    public string commit ( string message, Gee.ArrayList<GitMonitorQueue> files  ) throws Error, SpawnError
     {
         
 
@@ -357,8 +357,8 @@ public class GitRepo : Object
         */
         string[] args = { "commit", "-m" };
         args +=  (message.length > 0  ? message : "Changed" );
-        for (var i = 0; i< files.length ; i++ ) {
-            args += files.index(i).vname; // full path?
+        for (var i = 0; i< files.size ; i++ ) {
+            args += files.get(i).vname; // full path?
         }
          
         return this.git(args);
index 1656fe7..79c5020 100644 (file)
@@ -10,7 +10,7 @@
   {
    "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\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 \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\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,
@@ -31,8 +31,8 @@
      "items" : [
       {
        "bool homogeneous" : false,
-       "* pack" : "pack_start,false,false,0",
        "xtype" : "Table",
+       "* pack" : "pack_start,false,false,0",
        "uint column_spacing" : 2,
        "n_columns" : 2,
        "$ xns" : "Gtk",
          "items" : [
           {
            "id" : "dbcellrenderer",
-           "xtype" : "CellRendererText",
            "* pack" : "pack_start,true",
+           "xtype" : "CellRendererText",
            "$ xns" : "Gtk"
           },
           {
            "id" : "dbmodel",
-           "xtype" : "ListStore",
            "* pack" : "set_model",
+           "xtype" : "ListStore",
            "| void loadTickets" : "  () {\n\n    RooTicket.singleton().loadTickets();\n    \n    _this.ticketsel.loading = true;\n\n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n    el.append(out iter);\n\n    \n    el.set_value(iter, 0, \"\");\n    el.set_value(iter, 1, \"-- select a ticket --\");\n    \n    _this.ticketsel.el.set_active_iter(iter);\n    var tickets = RooTicket.singleton().tickets;\n    foreach(var ticket in tickets) {\n    \n        el.append(out iter);\n        \n        el.set_value(iter, 0, ticket.id);\n        el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n        \n        //if (data.get(i) == cur) {\n         //   _this.build_module.el.set_active_iter(iter);\n       // }\n        \n    }\n    \n    _this.ticketsel.loading = false;\n     //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
     },
     {
      "label" : "Do not create Branch",
-     "xtype" : "Button",
      "* pack" : "add_action_widget,0",
+     "xtype" : "Button",
      "Gtk.ReliefStyle relief" : "Gtk.ReliefStyle.NONE",
      "$ xns" : "Gtk"
     },
     {
      "label" : "Create Branch",
-     "xtype" : "Button",
      "* pack" : "add_action_widget,1",
+     "xtype" : "Button",
      "$ xns" : "Gtk"
     }
    ]
index 583cb0e..2992419 100644 (file)
@@ -80,11 +80,11 @@ public class NewBranch : Object
                        }
             }
         
-                           this.running = false; 
+               this.running = false; 
         
                 
-                
-                
+               _this.el.hide();        
+         
         
                 
         });
index c30925d..da7d3e1 100644 (file)
@@ -51,7 +51,6 @@ public class RooTicket : Object
        
        }
 
-
        public void addTicket(Json.Object t)
        {
                var add = new RooTicket();
@@ -83,8 +82,9 @@ public class RooTicket : Object
                
                var table = new GLib.HashTable<string, string>(str_hash, str_equal);
         
-               table.insert("query[viewtype]","active");
-               table.insert("developer_id","494");
+               table.insert("query[viewtype]","me");           
+               //table.insert("developer_id","494");
                table.insert("limit","999");
                table.insert("sort","summary");
                table.insert("dir","ASC");