- if (last < 5 * TimeSpan.SECOND) { // wait 5 seconds before running. ????
- return true;
- }
- //_this.lastAdd = new Date();
- //return 1;
-
- this.runQueue();
- return true; //
- });
-
- }
-
-
- public new void stop() {
- StatusIconA.statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );;
- base.stop();
- }
-
-
- public new void monitor (string path, int depth = 0)
- {
-
- //var 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 && FileUtils.test(path + "/.git" , FileTest.IS_DIR)) {
- return;
- }
-
- if (depth == 1) {
- // FIXME - check if repo is flagged as not autocommit..
- //var repo = imports.Scm.Repo.Repo.get(path);
- //if (!repo || !repo.autocommit()) {
- // return;
- //}
- }
-
-
- // check if the repo is to be monitored.
- //print("PATH : " + path);
-
-
- base.monitor(path, depth);
- }
-
-
-
- /**
- * run the queue.
- * - pulls the items off the queue
- * (as commands run concurrently and new items may get added while it's running)
- * - runs the queue items
- * - pushes upstream.
- *
- */
- public void runQueue()
- {
-
- if (this.paused) {
- return;
- }
- print("GitMonitor.runQueue\n");
-
- this.queueRunning = true;
-
- var cmds = new Array<GitMonitorQueue>();
-
- for(var i = 0; i < this.queue.length; i++) {
- cmds.append_val(this.queue.index(i));
- }
-
- this.queue = new Array<GitMonitorQueue>();// empty queue!
-
-
- string[] success = {};
- string[] failure = {};
- //var repos = new Array<GitRepo>(); //??
- //var done = new Array<GitMonitorQueue>();
-
- // first build a array of repo's to work with
- var repo_list = new Array<GitRepo>();
-
- // pull and group.
-
- //print(JSON.stringify(cmds));
- // make sure nothing get's added to the queue where we are doing this..
-
- this.paused = true;
-
- print("GitMonitor.runQueue - creating repos\n");
-
- for(var i = 0; i < cmds.length; i++) {
-
- var cmd = cmds.index(i);
-
- var gitpath = cmd.gitpath;
- stdout.printf("GitMonitor.runQueue - finding %s\n", cmd.gitpath);
-
- var ix = GitRepo.indexOf(repo_list, cmd.gitpath);
- if (ix < 0) {
- repo_list.append_val(new GitRepo( gitpath ));
- ix = GitRepo.indexOf(repo_list, cmd.gitpath);
- }
- stdout.printf("GitMonitor.runQueue - adding to repolist %d\n", ix);
-
- //if (typeof(repo_list[gitpath]) == 'undefined') {
- // repo_list[gitpath] = new imports.Scm.Git.Repo.Repo( { repopath : gitpath });
- // repo_list[gitpath].cmds = [];
- // repo_list[gitpath].pull();
- //}
- repo_list.index(ix).cmds.append_val(cmd);
-
- }
- this.paused = false;
- // build add, remove and commit message list..
-
- print("GitMonitor.runQueue - creating actions\n");
-
- for(var i = 0;i < repo_list.length;i++) {
-
- 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>();
- //print(JSON.stringify(repo.cmds,null,4));
-
- for(var ii = 0;ii < repo.cmds.length;ii++) {
- var cmd = repo.cmds.index(ii);
-
-
- switch(cmd.action) {
- case "add" :
-
- if (GitMonitorQueue.indexOfAdd(add_files, cmd.vname) > -1) {
- break;
- }
-
- add_files.append_val(cmd);
- break;
-
- case "rm":
- if (GitMonitorQueue.indexOfAdd(remove_files, cmd.vname) > -1 ) {
- break;
- }
-
- // if file exists, do not try and delete it.
- if (FileUtils.test(cmd.vname, FileTest.EXISTS)) {
- break;
- }
-
- remove_files.append_val(cmd);
- break;
-
- case "commit" :
- if (GitMonitorQueue.indexOfMessage(messages, cmd.message) > -1 ) {
- break;
- }
- messages.append_val(cmd);
-
- break;
- default:
- stdout.printf("Opps unmatched action %s\n", cmd.action);
- break;
- }
- }
- print( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files));
- print( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files));
- //repo.debug = 1;
- // these can fail... at present... as we wildcard stuff.
-
- // make sure added files do not get removed.. ??
- /*
- var remove_files_f = new Array<GitMonitorQueue>();
- for(var ii = 0;ii < remove_files.length;ii++) {
- if (GitMonitorQueue.indexOfAdd(add_files, remove_files.index(ii).vname) > -1 ) {
- continue;
- }
- remove_files_f.append_val(remove_files.index(ii));
- };
- stdout.printf("REMOVE : %u files\n" , remove_files_f.length);
- */
-
- // if file was added, then removed,
- var remove_files_f = new Array<GitMonitorQueue>();
- for(var ii = 0;ii < remove_files.length;ii++) {
- if (GitMonitorQueue.indexOfAdd(add_files, remove_files.index(ii).vname) > -1 ) {
- // in add and remove - do not remvove
- continue;
- }
- remove_files_f.append_val(remove_files.index(ii));
- };
- for(var ii = 0;ii < add_files.length;ii++) {
- if (GitMonitorQueue.indexOfAdd(remove_files, add_files.index(ii).vname) > -1 ) {
- // the add file is in the remove list, and it does not exist - do not add it..
- if (!FileUtils.test(add_files.index(ii).vname, FileTest.EXISTS)) {
- continue;
+ if (last < 5 * TimeSpan.SECOND) { // wait 5 seconds before running. ????
+ return true;
+ }
+ //_this.lastAdd = new Date();
+ //return 1;
+
+ this.runQueue();
+ return true; //
+ });
+
+ }
+
+
+ public new void stop() {
+ StatusIconA.statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );;
+ base.stop();
+ }
+
+
+ public new void monitor (string path, int depth = 0)
+ {
+
+ //var 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 && FileUtils.test(path + "/.git" , FileTest.IS_DIR)) {
+ return;
+ }
+
+ if (depth == 1) {
+ // FIXME - check if repo is flagged as not autocommit..
+ //var repo = imports.Scm.Repo.Repo.get(path);
+ //if (!repo || !repo.autocommit()) {
+ // return;
+ //}
+ }
+
+
+ // check if the repo is to be monitored.
+ //print("PATH : " + path);
+
+
+ base.monitor(path, depth);
+ }
+
+
+
+ /**
+ * run the queue.
+ * - pulls the items off the queue
+ * (as commands run concurrently and new items may get added while it's running)
+ * - runs the queue items
+ * - pushes upstream.
+ *
+ */
+ public void runQueue()
+ {
+
+ if (this.paused) {
+ return;
+ }
+ print("GitMonitor.runQueue\n");
+
+ this.queueRunning = true;
+
+ var cmds = new Array<GitMonitorQueue>();
+
+ for(var i = 0; i < this.queue.length; i++) {
+ cmds.append_val(this.queue.index(i));
+ }
+
+ this.queue = new Array<GitMonitorQueue>();// empty queue!
+
+
+ string[] success = {};
+ string[] failure = {};
+ //var repos = new Array<GitRepo>(); //??
+ //var done = new Array<GitMonitorQueue>();
+
+ // first build a array of repo's to work with
+ var repo_list = new Array<GitRepo>();
+
+ // pull and group.
+
+ //print(JSON.stringify(cmds));
+ // make sure nothing get's added to the queue where we are doing this..
+
+ this.paused = true;
+
+ print("GitMonitor.runQueue - creating repos\n");
+
+ for(var i = 0; i < cmds.length; i++) {
+
+ var cmd = cmds.index(i);
+
+ var gitpath = cmd.gitpath;
+ stdout.printf("GitMonitor.runQueue - finding %s\n", cmd.gitpath);
+
+ var ix = GitRepo.indexOf(repo_list, cmd.gitpath);
+ if (ix < 0) {
+ repo_list.append_val(new GitRepo( gitpath ));
+ ix = GitRepo.indexOf(repo_list, cmd.gitpath);
+ }
+ stdout.printf("GitMonitor.runQueue - adding to repolist %d\n", ix);
+
+ //if (typeof(repo_list[gitpath]) == 'undefined') {
+ // repo_list[gitpath] = new imports.Scm.Git.Repo.Repo( { repopath : gitpath });
+ // repo_list[gitpath].cmds = [];
+ // repo_list[gitpath].pull();
+ //}
+ repo_list.index(ix).cmds.append_val(cmd);
+
+ }
+ this.paused = false;
+ // build add, remove and commit message list..
+
+ print("GitMonitor.runQueue - creating actions\n");
+
+ for(var i = 0;i < repo_list.length;i++) {
+
+ 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>();
+ //print(JSON.stringify(repo.cmds,null,4));
+
+ for(var ii = 0;ii < repo.cmds.length;ii++) {
+ var cmd = repo.cmds.index(ii);
+
+
+ switch(cmd.action) {
+ case "add" :
+
+ if (GitMonitorQueue.indexOfAdd(add_files, cmd.vname) > -1) {
+ break;
+ }
+
+ add_files.append_val(cmd);
+ break;
+
+ case "rm":
+ if (GitMonitorQueue.indexOfAdd(remove_files, cmd.vname) > -1 ) {
+ break;
+ }
+
+ // if file exists, do not try and delete it.
+ if (FileUtils.test(cmd.vname, FileTest.EXISTS)) {
+ break;
+ }
+
+ remove_files.append_val(cmd);
+ break;
+
+ case "commit" :
+ if (GitMonitorQueue.indexOfMessage(messages, cmd.message) > -1 ) {
+ break;
+ }
+ messages.append_val(cmd);
+
+ break;
+ default:
+ stdout.printf("Opps unmatched action %s\n", cmd.action);
+ break;
+ }
+ }
+ print( "ADD : %s\n", GitMonitorQueue.queueArrayToString(add_files));
+ print( "REMOVE FILES: %s\n", GitMonitorQueue.queueArrayToString(remove_files));
+ //repo.debug = 1;
+ // these can fail... at present... as we wildcard stuff.
+
+ // make sure added files do not get removed.. ??
+ /*
+ var remove_files_f = new Array<GitMonitorQueue>();
+ for(var ii = 0;ii < remove_files.length;ii++) {
+ if (GitMonitorQueue.indexOfAdd(add_files, remove_files.index(ii).vname) > -1 ) {
+ continue;
+ }
+ remove_files_f.append_val(remove_files.index(ii));
+ };
+ stdout.printf("REMOVE : %u files\n" , remove_files_f.length);
+ */
+
+ // if file was added, then removed,
+ var remove_files_f = new Array<GitMonitorQueue>();
+ for(var ii = 0;ii < remove_files.length;ii++) {
+ if (GitMonitorQueue.indexOfAdd(add_files, remove_files.index(ii).vname) > -1 ) {
+ // in add and remove - do not remvove
+ continue;
+ }
+ remove_files_f.append_val(remove_files.index(ii));
+ };
+ for(var ii = 0;ii < add_files.length;ii++) {
+ if (GitMonitorQueue.indexOfAdd(remove_files, add_files.index(ii).vname) > -1 ) {
+ // the add file is in the remove list, and it does not exist - do not add it..
+ if (!FileUtils.test(add_files.index(ii).vname, FileTest.EXISTS)) {
+ continue;