README.txt
[gitlive] / GitMonitor.js
index 9c6a48b..df3565a 100644 (file)
@@ -39,14 +39,36 @@ var GitMonitor = new Monitor({
         
     },
     
-    
+    /**
+     * Start the monitoring
+     * and run the queue every 500 milliseconds..
+     *
+     */
     start: function() {
+        imports.StatusIcon.StatusIcon.el.set_from_stock( Gtk.STOCK_REFRESH );
         var _this = this;
         this.lastAdd = new Date();
         
-        this.top.forEach(this.monitor, this);
-         
         GLib.timeout_add(GLib.PRIORITY_LOW, 500, function() {
+            _this.top.forEach(_this.monitor, _this);
+            imports.StatusIcon.StatusIcon.el.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
+            
+            try { 
+                var notification = new Notify.Notification({
+                    summary: "Git Live",
+                    body : this.gitlive + "\nMonitoring " + _this.monitors.length + " Directories",
+                    timeout : 5
+                });
+        
+                notification.set_timeout(5);
+                notification.show();
+            } catch(e) {
+                print(e.toString());
+            }
+
+        });
+        
+        GLib.timeout_add(GLib.PRIORITY_LOW, 1000, function() {
             //TIMEOUT", _this.queue.length , _this.queueRunning].join(', '));
             if (!_this.queue.length || _this.queueRunning) {
                 return 1;
@@ -55,7 +77,7 @@ var GitMonitor = new Monitor({
             
             //print("LAST RUN?" + last);
             
-            if (last < 20) { // wait 1/2 a seconnd before running.
+            if (last < 5) { // wait 1/2 a seconnd before running.
                 return 1;
             }
             //_this.lastAdd = new Date();
@@ -65,19 +87,39 @@ var GitMonitor = new Monitor({
             return 1;
         },null,null);
         
-        try { 
-            var notification = new Notify.Notification({
-                summary: "Git Live",
-                body : this.gitlive + "\nMonitoring " + this.monitors.length + " Directories",
-                timeout : 5
-            });
+      
+    },
     
-            notification.set_timeout(5);
-            notification.show();
-        } catch(e) {
-            print(e.toString());
+    
+    stop: function() {
+        imports.StatusIcon.StatusIcon.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
+        Monitor.prototype.stop.call(this);
+    },
+    
+    
+    monitor : function(path, fn, depth)
+    {
+        depth = typeof(depth) == 'number'  ? depth *1 : 0;
+        
+         
+        // if we are not at top level.. and there is a .git directory  (it's a submodule .. ignore) 
+        if (depth > 1 && GLib.file_test(path + '/.git' , GLib.FileTest.IS_DIR)) {
+            return;
         }
-
+        
+        if (depth == 1) {
+            var repo = imports.Scm.Repo.Repo.get(path);
+            if (!repo || !repo.autocommit()) {
+                return;
+            } 
+        }
+        
+        
+        // check if the repo is to be monitored.
+        //print("PATH : " + path);
+        
+        
+        Monitor.prototype.monitor.call(this, path,fn, depth);
     },
     
     /**
@@ -258,6 +300,8 @@ var GitMonitor = new Monitor({
         if (this.paused) {
             return true;
         }
+        
+        
         // vim.. what a seriously brain dead program..
         if (f.name == '4913') {
             return true;
@@ -274,6 +318,9 @@ var GitMonitor = new Monitor({
         if (f.name.match(/~$/)) {
             return true;
         }
+        if (f.name.match(/^nbproject/)) {
+            return true;
+        }
         // ignore anything in top level!!!!
         if (!f.vpath.length) {
             return true;