--- /dev/null
+// <script type ="text/Javascript">
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+
+
+
+/**
+* @namespace File
+*
+* Library to wrap GLib and Gio basic File related methods
+*
+* usage:
+*
+* File = import.File.File;
+*
+* var contents = File.read("/tmp/test.txt");
+*
+*
+*
+*/
+var File = {
+
+ SEPARATOR : '/',
+
+ // fixme - this needs a bitter location..
+ // they where in a string class before, but overriding String methods is not a good normally a good idea..
+
+ rtrim : function (s,toTrim) {
+ if (s.substr(s.length - toTrim.length) == toTrim) {
+ return s.slice(0, s.length - toTrim.length);
+ }
+
+ return s;
+ },
+ trim : function (s,toTrim) {
+ var out = s.ltrim(toTrim);
+ out = out.rtrim(toTrim);
+ return out;
+ },
+
+ ltrim : function (s, toTrim) {
+ if (s.substr(0, toTrim.length) == toTrim) {
+ return s.slice(toTrim.length);
+ }
+
+ return s;
+ },
+
+ join : function () {
+ var out = "";
+ for (var i = 0; i < arguments.length; i++) {
+ if (i == 0) {
+ out += this.rtrim(arguments[i], File.SEPARATOR);
+ }
+ else if (i == arguments.length - 1) {
+ out += File.SEPARATOR + this.ltrim(arguments[i], File.SEPARATOR);
+ }
+ else {
+ out += File.SEPARATOR + this.trim(arguments[i], File.SEPARATOR);
+ }
+ }
+ return out;
+ },
+
+ read : function (path) {
+ var out = {};
+ GLib.file_get_contents(path, out, null, null);
+ return out['value'];
+ },
+
+ isFile : function (path) {
+ return GLib.file_test(path, GLib.FileTest.IS_REGULAR);
+ },
+ exists : function (path) {
+ return GLib.file_test(path, GLib.FileTest.EXISTS);
+ },
+ isDirectory : function (path) {
+ return GLib.file_test(path, GLib.FileTest.IS_DIR);
+ },
+
+ list : function (path) {
+ var listing = [];
+
+ var f = Gio.file_new_for_path(String(path));
+ var file_enum = f.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, null);
+
+ var next_file = null;
+
+ while ((next_file = file_enum.next_file(null)) != null) {
+ listing.push(next_file.get_display_name());
+ }
+
+ file_enum.close(null);
+
+ listing.sort();
+
+ return listing;
+ },
+
+ mtime : function (path) {
+ var f = Gio.file_new_for_path(String(path));
+ var mtime = new GLib.TimeVal();
+
+ var info = f.query_info(Gio.FILE_ATTRIBUTE_TIME_MODIFIED, Gio.FileQueryInfoFlags.NONE, null);
+ info.get_modification_time(mtime);
+
+ return new Date(mtime.tv_sec * 1000);
+ },
+
+ /**
+ * resolve the real path
+ * @arg path {String} Path to resolve
+ * @returns {String} the resolved path path.
+ *
+ */
+ realpath : function (path) {
+ return this.canonical(path);
+ },
+ canonical : function (path) {
+ var f = Gio.file_new_for_path(String(path));
+ var can = f.resolve_relative_path('');
+ return can.get_path();
+ },
+ /**
+ * write a string to a file
+ * @arg path {String} File to write to alwasy overwrites.
+ * @arg string {String} Contents of file.
+ *
+ */
+ write : function (path, string) {
+ var d = new Date();
+ var f = Gio.file_new_for_path(String(path));
+ var data_out = new Gio.DataOutputStream({base_stream:f.replace(null, false, Gio.FileCreateFlags.NONE, null)});
+ data_out.put_string(string, null);
+ data_out.close(null);
+ print("WRITE : " + path + " in " + ((new Date()) - d) + 'ms');
+
+ },
+ /**
+ * append
+ * @arg path {String} File to write to
+ * @arg string {String} string to append to file.
+ *
+ */
+ append : function (path, string) {
+ var f = Gio.file_new_for_path(String(path));
+ var data_out = new Gio.DataOutputStream({
+ base_stream:f.append_to(Gio.FileCreateFlags.NONE, null)
+ });
+ data_out.put_string(string, null);
+ data_out.close(null);
+ },
+ /**
+ * remove
+ * Delete a file.
+ * @arg path {String} File to remove
+ *
+ *
+ */
+ remove : function (path)
+ {
+ var f = Gio.file_new_for_path(String(path));
+ return f['delete']();
+ },
+ // copy files recursively from fromDir, silently ignore them if they already exist in toDir
+ silentRecursiveCopy : function (fromDir, toDir) {
+ var filesToCopy = File.recursiveListing(fromDir);
+ var srcPath, destPath, src, dest;
+
+ for (var index in filesToCopy) {
+ srcPath = File.join(String(fromDir), filesToCopy[index]);
+ destPath = File.join(String(toDir), filesToCopy[index]);
+
+ if (File.isFile(srcPath) && !File.isFile(destPath)) {
+ File.copyFile(srcPath, destPath);
+ }
+ else if (File.isDirectory(srcPath) && !File.isDirectory(destPath)) {
+ File.mkdir(destPath);
+ }
+
+ }
+ },
+ /**
+ * Make a symbolic link
+ * @arg new_link {String} The new link
+ * @arg target {String} Where it links to.
+ */
+ link : function (new_link, target) {
+ var dest = Gio.file_new_for_path(String(new_link));
+ return dest.make_symbolic_link(target, null);
+ },
+ /**
+ * Make a directory
+ * FIXME - needs perms setting..
+ *
+ * @arg directory {String} Directory to make
+ */
+
+ mkdir : function (destPath) {
+ var dest = Gio.file_new_for_path(String(destPath));
+ return dest.make_directory(null);
+ },
+
+ /**
+ * Copy a file or (directory maybe?)
+ * @arg srcPath {String} source file
+ * @arg destPath {String} destination file
+ * @arg flags {Gio.FileCopyFlags} to overwrite etc... Gio.FileCopyFlags.OVERWRITE
+ */
+ copy : function (srcPath, destPath, flags) {
+ return this.copyFile(srcPath, destPath, flags);
+ },
+ copyFile : function (srcPath, destPath, flags) {
+
+ flags = typeof(flags) == 'undefined' ? Gio.FileCopyFlags.NONE : flags;
+ var dest = Gio.file_new_for_path(String(destPath));
+ var src = Gio.file_new_for_path(String(srcPath));
+
+ // a bit of a hack for the fact that Gio.File.copy arguments
+ // can be nulled, but not according to the GIR file
+ return src.copy(dest, flags);
+ },
+
+
+
+
+ recursiveListing : function (dir) {
+
+ function recursiveListingInternal(prefix, listing, dir) {
+ var entries = File.list(dir);
+ var next, fullPath;
+
+ for (var index in entries) {
+ next = entries[index];
+ fullPath = File.join(prefix, dir, next);
+
+ if (File.isDirectory(fullPath)) {
+ listing.push(next);
+ listing = listing.concat(recursiveListingInternal(next, [], fullPath));
+ }
+ else {
+ if (prefix) {
+ next = File.join(prefix, next);
+ }
+ listing.push(next);
+ }
+ }
+
+ return listing;
+ }
+
+ return recursiveListingInternal('', [], dir);
+ }
+
+};
--- /dev/null
+{
+ "id": "file-gtk-1",
+ "name": "FixBug",
+ "parent": "",
+ "title": false,
+ "path": "/home/alan/gitlive/gitlive/FixBug.bjs",
+ "items": [
+ {
+ "listeners": {
+ "destroy_event": "function (self, event) {\n this.el.hide();\n return false;\n}",
+ "response": "function (self, id) {\n // hide\n if (id < 1) {\n this.el.hide();\n return;\n }\n if (typeof(this.get('bug').getValue()) != 'object') {\n print(\"ERROR\");\n return;\n }\n \n this.el.hide();\n \n //var val = this.get('bug').getValue();\n // Seed.print(val);\n}"
+ },
+ "border_width": 3,
+ "default_height": 400,
+ "default_width": 600,
+ "title": "Select Active Bug",
+ "xtype": "Dialog",
+ "|deletable": true,
+ "|modal": true,
+ "|show": "function(c) {\n \n if (!this.el) {\n this.init();\n }\n var _this = this;\n /*[ 'xtype' ].forEach(function(k) {\n _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);\n });\n\t// shouild set path..\n */\n\n \n this.el.show_all();\n this.get('/ok_button').el.set_sensitive(false);\n \n // block until we return.\n var run_ret = this.el.run();\n if (run_ret < 1 ) {\n return false;\n }\n print(\"RUN RETURN : \" + run_ret);\n \n //print(JSON.stringify(this.get('bug').getValue()));\n return this.get('bug').getValue();\n //this.success = c.success;\n}\n",
+ "|xns": "Gtk",
+ "items": [
+ {
+ "|xns": "Gtk",
+ "xtype": "VBox",
+ "|pack": " function(p,e) {\n p.el.get_content_area().add(e.el)\n }\n",
+ "items": [
+ {
+ "|xns": "Gtk",
+ "xtype": "HBox",
+ "pack": "pack_start,false,true,3",
+ "items": [
+ {
+ "label": "Select Active Bug:",
+ "pack": "pack_start,false,true,3",
+ "xtype": "Label",
+ "|xns": "Gtk"
+ },
+ {
+ "listeners": {
+ "changed": "function (self) {\n var d = this.getValue();\n this.get('/view').load(d.description);\n this.get('/ok_button').el.set_sensitive(true);\n}"
+ },
+ "id": "bug",
+ "pack": "pack_end,true,true,3",
+ "xtype": "ComboBox",
+ "|getValue": "function() {\n var ix = this.el.get_active();\n if (ix < 0 ) {\n return '';\n }\n return this.get('model').data[ix];\n}\n",
+ "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 1 ); \n}\n",
+ "|setValue": "function(v)\n {\n var el = this.el;\n el.set_active(-1);\n this.get('model').data.forEach(function(n, ix) {\n if (v == n.xtype) {\n el.set_active(ix);\n return false;\n }\n });\n }",
+ "|xns": "Gtk",
+ "items": [
+ {
+ "|xns": "Gtk",
+ "xtype": "CellRendererText",
+ "pack": "pack_start"
+ },
+ {
+ "id": "model",
+ "pack": "set_model",
+ "xtype": "ListStore",
+ "|init": "function() {\n XObject.prototype.init.call(this);\n\n this.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // real key\n GObject.TYPE_STRING // real type\n \n \n ] );\n var Tickets = imports.Tickets.Tickets;\n \n this.data = Tickets.fetchBugs(\"http://www.roojs.com/mtrack/index.php/Gitlive/web.hex\");\n/* this.data = [\n { xtype: 'Roo', desc : \"Roo Project\" },\n { xtype: 'Gtk', desc : \"Gtk Project\" }, \n //{ xtype: 'JS', desc : \"Javascript Class\" }\n ]\n */ \n this.loadData(this.data);\n \n}\n",
+ "|loadData": "function (data) {\n \n var iter = new Gtk.TreeIter();\n var el = this.el;\n data.forEach(function(p) {\n \n el.append(iter);\n \n \n el.set_value(iter, 0, p.id);\n el.set_value(iter, 1, '#' + p.id + ' - ' + p.summary );\n \n });\n \n \n}\n",
+ "|xns": "Gtk"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "|xns": "Gtk",
+ "xtype": "ScrolledWindow",
+ "pack": "add",
+ "id": "RightEditor",
+ "items": [
+ {
+ "editable": false,
+ "id": "view",
+ "indent_width": 4,
+ "pack": "add",
+ "xtype": "TextView",
+ "|auto_indent": true,
+ "|init": "function() {\n XObject.prototype.init.call(this);\n var description = Pango.Font.description_from_string(\"monospace\")\n description.set_size(8000);\n this.el.modify_font(description);\n\n}\n",
+ "|load": "function(str) {\n\n// show the help page for the active node..\n \n\n\n \n this.el.get_buffer().set_text(str, str.length);\n \n \n var buf = this.el.get_buffer();\n \n \n \n}",
+ "|show_line_numbers": true,
+ "|xns": "Gtk",
+ "items": [
+ {
+ "listeners": {
+ "changed": "function (self) {\n /*\n var s = new Gtk.TextIter();\n var e = new Gtk.TextIter();\n this.el.get_start_iter(s);\n this.el.get_end_iter(e);\n var str = this.el.get_text(s,e,true);\n try {\n Seed.check_syntax('var e = ' + str);\n } catch (e) {\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n }));\n //print(\"SYNTAX ERROR IN EDITOR\"); \n //print(e);\n //console.dump(e);\n return;\n }\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n }));\n \n this.get('/LeftPanel.model').changed( str , false);\n */\n}"
+ },
+ "pack": "set_buffer",
+ "xtype": "Buffer",
+ "|xns": "GtkSource"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "label": "Cancel",
+ "pack": "add_action_widget,0",
+ "xtype": "Button",
+ "|xns": "Gtk",
+ "listeners": {}
+ },
+ {
+ "id": "ok_button",
+ "label": "OK",
+ "pack": "add_action_widget,1",
+ "xtype": "Button",
+ "|xns": "Gtk"
+ }
+ ]
+ }
+ ],
+ "permname": "",
+ "modOrder": ""
+}
\ No newline at end of file
--- /dev/null
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+GtkClutter = imports.gi.GtkClutter;
+Gdl = imports.gi.Gdl;
+console = imports.console;
+XObject = imports.XObject.XObject;
+FixBug=new XObject({
+ xtype: Gtk.Dialog,
+ listeners : {
+ destroy_event : function (self, event) {
+ this.el.hide();
+ return false;
+ },
+ response : function (self, id) {
+ // hide
+ if (id < 1) {
+ this.el.hide();
+ return;
+ }
+ if (typeof(this.get('bug').getValue()) != 'object') {
+ print("ERROR");
+ return;
+ }
+
+ this.el.hide();
+
+ //var val = this.get('bug').getValue();
+ // Seed.print(val);
+ }
+ },
+ border_width : 3,
+ default_height : 400,
+ default_width : 600,
+ title : "Select Active Bug",
+ deletable : true,
+ modal : true,
+ show : function(c) {
+
+ if (!this.el) {
+ this.init();
+ }
+ var _this = this;
+ /*[ 'xtype' ].forEach(function(k) {
+ _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
+ });
+ // shouild set path..
+ */
+
+
+ this.el.show_all();
+ this.get('/ok_button').el.set_sensitive(false);
+
+ // block until we return.
+ var run_ret = this.el.run();
+ if (run_ret < 1 ) {
+ return false;
+ }
+ print("RUN RETURN : " + run_ret);
+
+ //print(JSON.stringify(this.get('bug').getValue()));
+ return this.get('bug').getValue();
+ //this.success = c.success;
+ },
+ items : [
+ {
+ xtype: Gtk.VBox,
+ pack : function(p,e) {
+ p.el.get_content_area().add(e.el)
+ },
+ items : [
+ {
+ xtype: Gtk.HBox,
+ pack : "pack_start,false,true,3",
+ items : [
+ {
+ xtype: Gtk.Label,
+ label : "Select Active Bug:",
+ pack : "pack_start,false,true,3"
+ },
+ {
+ xtype: Gtk.ComboBox,
+ listeners : {
+ changed : function (self) {
+ var d = this.getValue();
+ this.get('/view').load(d.description);
+ this.get('/ok_button').el.set_sensitive(true);
+ }
+ },
+ id : "bug",
+ pack : "pack_end,true,true,3",
+ getValue : function() {
+ var ix = this.el.get_active();
+ if (ix < 0 ) {
+ return '';
+ }
+ return this.get('model').data[ix];
+ },
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.add_attribute(this.items[0].el , 'markup', 1 );
+ },
+ setValue : function(v)
+ {
+ var el = this.el;
+ el.set_active(-1);
+ this.get('model').data.forEach(function(n, ix) {
+ if (v == n.xtype) {
+ el.set_active(ix);
+ return false;
+ }
+ });
+ },
+ items : [
+ {
+ xtype: Gtk.CellRendererText,
+ pack : "pack_start"
+ },
+ {
+ xtype: Gtk.ListStore,
+ id : "model",
+ pack : "set_model",
+ init : function() {
+ XObject.prototype.init.call(this);
+
+ this.el.set_column_types ( 2, [
+ GObject.TYPE_STRING, // real key
+ GObject.TYPE_STRING // real type
+
+
+ ] );
+ var Tickets = imports.Tickets.Tickets;
+
+ this.data = Tickets.fetchBugs("http://www.roojs.com/mtrack/index.php/Gitlive/web.hex");
+ /* this.data = [
+ { xtype: 'Roo', desc : "Roo Project" },
+ { xtype: 'Gtk', desc : "Gtk Project" },
+ //{ xtype: 'JS', desc : "Javascript Class" }
+ ]
+ */
+ this.loadData(this.data);
+
+ },
+ loadData : function (data) {
+
+ var iter = new Gtk.TreeIter();
+ var el = this.el;
+ data.forEach(function(p) {
+
+ el.append(iter);
+
+
+ el.set_value(iter, 0, p.id);
+ el.set_value(iter, 1, '#' + p.id + ' - ' + p.summary );
+
+ });
+
+
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ xtype: Gtk.ScrolledWindow,
+ pack : "add",
+ id : "RightEditor",
+ items : [
+ {
+ xtype: Gtk.TextView,
+ editable : false,
+ id : "view",
+ indent_width : 4,
+ pack : "add",
+ auto_indent : true,
+ init : function() {
+ XObject.prototype.init.call(this);
+ var description = Pango.Font.description_from_string("monospace")
+ description.set_size(8000);
+ this.el.modify_font(description);
+
+ },
+ load : function(str) {
+
+ // show the help page for the active node..
+
+
+
+
+ this.el.get_buffer().set_text(str, str.length);
+
+
+ var buf = this.el.get_buffer();
+
+
+
+ },
+ show_line_numbers : true,
+ items : [
+ {
+ xtype: GtkSource.Buffer,
+ listeners : {
+ changed : function (self) {
+ /*
+ var s = new Gtk.TextIter();
+ var e = new Gtk.TextIter();
+ this.el.get_start_iter(s);
+ this.el.get_end_iter(e);
+ var str = this.el.get_text(s,e,true);
+ try {
+ Seed.check_syntax('var e = ' + str);
+ } catch (e) {
+ this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
+ red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
+ }));
+ //print("SYNTAX ERROR IN EDITOR");
+ //print(e);
+ //console.dump(e);
+ return;
+ }
+ this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
+ red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
+ }));
+
+ this.get('/LeftPanel.model').changed( str , false);
+ */
+ }
+ },
+ pack : "set_buffer"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ xtype: Gtk.Button,
+ label : "Cancel",
+ pack : "add_action_widget,0"
+ },
+ {
+ xtype: Gtk.Button,
+ id : "ok_button",
+ label : "OK",
+ pack : "add_action_widget,1"
+ }
+ ]
+});
+FixBug.init();
+XObject.cache['/FixBug'] = FixBug;
+++ /dev/null
-///<script type="text/javascript">
-
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-
-var Spawn = imports.Spawn.Spawn;
-/**
- * @namespace Git
- *
- * Class to handle git operations..???
- *
- * usage:
- *
- * Git = import.Git.Git;
- *
- * var g = new Git( '/home/me/git' );
- *
- * g.run('commit', { all : true , message : 'test' }, 'filename',)
- *
- * or
- * print(Git.run('/home/me/git', 'log'))
- *
- *
- *
- */
-
-
-/**
- * @class Git
- * @param repo {String} directory that the repo is in, either bare or not.
- *
- *
- */
-//var prototypeInit = false;
-function Git( repo) {
-
- if (!GLib.file_test(repo, GLib.FileTest.IS_DIR)) {
- throw "Repo does not exist";
- }
- this.repo = repo;
- /*
- if (!prototypeInit) {
- // proto type on set up yet..
- // we could list this to generate methods.. /usr/lib/git-core/
- var props = Gil.prototypeInit();
- for (var i in props) {
- this[i]= props[i];
- }
- }
- */
-
-}
-Git.prototype = {
- repo : '',
- /**
- * @method run
- *
- * @arg command {String} command to run
- * @arg arguments.... {String|Object} arguments to send to command
- *
- *
- */
- run : function() {
- var args = ['git'];
-
- for (var i=0;i< arguments.length;i++) {
- if (typeof(arguments[i]) == 'string') {
- args.push(arguments[i]);
- continue;
- }
- if (typeof(arguments[i]) == 'object') {
- for(var k in arguments[i]) {
- var v = arguments[i][k];
- args.push('--' + k);
- if (v === true) {
- continue;
- }
- args.push(v);
- }
- }
-
- }
-
- var sp = new Spawn({
- env : [ "GITPATH=" + this.repo , "HOME=" + GLib.get_home_dir() ],
- cwd : this.repo,
- args: args,
- debug: true,
- exceptions : false,
- async : false
- });
- var out = sp.run();
- // parse output for some commands ?
- return out;
- }
-}
-
-
-/**
- * @function run
- * @arg command {String} command to run
- * @arg arguments.... {String|Object} arguments to send to command
- *
- *
- */
-
-function run() {
- var args = Array.prototype.slice.call(arguments);
-
- var repo = args.shift(args);
- var x = new Git(repo);
-
- return x.run.apply(x, args);
-
-}
-
-
-// test.
-
-//print(run('/home/alan/gitlive/gitlive', 'log'));
-
-
-
\ No newline at end of file
},
/**
* monitor a file or directory (privatish)
+ *
+ * initially called with ~/gitlive null 0 (effectvely)
*
*
*/
monitor : function(path, fn, depth)
{
var _this = this;
- depth = depth ? depth *1 : 0;
+
+
+ depth = typeof(depth) == 'number' ? depth *1 : 0;
+
+
fn = fn || function (fm, f, of, event_type, uh) {
_this.onEvent(fm, f, of, event_type, uh);
}
- if (depth > 0 && GLib.file_test(path + '/.git' , GLib.FileTest.IS_DIR)) {
+ // 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;
}
-
+
var f = Gio.file_new_for_path(path);
- //var cancel = new Gio.Cancellable ();
- var fm = f.monitor(2,null); //Gio.FileMonitorFlags.SEND_MOVED
- fm.signal.changed.connect(fn);
- this.monitors.push(fm);
+ //var cancel = new Gio.Cancellable ();
+ if (depth > 0) {
+ var fm = f.monitor(2,null); //Gio.FileMonitorFlags.SEND_MOVED
+ fm.signal.changed.connect(fn);
+ this.monitors.push(fm);
+ // print("ADD path " + depth + ' ' + path);
+ }
// iterate children?
+ if (GLib.file_test(path + '/.git' , GLib.FileTest.IS_DIR) && this.initRepo) {
+
+ this.initRepo(path);
+ }
+
+
var file_enum = f.enumerate_children(
Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME + ','+
Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
Gio.FileQueryInfoFlags.NONE,
null);
- //print("ADD path " + depth + ' ' + path);
+
while ((next_file = file_enum.next_file(null)) != null) {
},
/** override these to do stuff.. */
-
+ initRepo : function(src) { }, // called on startup at the top level repo dir.
onChanged : function(src) { },
onChangesDoneHint : function(src) { },
onDeleted : function(src) { },
paused : false, // on!
xtype : Gtk.StatusIcon,
+ title : 'gitlive',
stock : Gtk.STOCK_MEDIA_PLAY,
tooltip_text : 'GitLive',
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.set_name('gitlive');
+ },
listeners : {
//'popup-menu' : function( w, event, event_time) {
'activate' : function( w, event, event_time) {
--- /dev/null
+/**
+ *
+ * let's see if we can pull a list of tickets from the tracker..
+ *
+ */
+
+GI = imports.gi.GIRepository
+GLib = imports.gi.GLib;
+
+
+Soup = imports.gi.Soup ;
+
+
+var File = imports.File.File;
+
+Tickets = {
+
+ parseNetrc : function()
+ {
+ this.machines = {};
+ // very basic parsing - only support single line version..
+ var lines = File.read(GLib.get_home_dir() + '/.netrc').split(/\n/);
+ var t = this;
+ lines.forEach(function(l) {
+ if (!l.match(/^machine/)) {
+ return;
+ }
+ var ar = l.split(/\s+/);
+ // assume machine XXX login XXX password XXXX
+ t.machines[ar[1]] = { login : ar[3], password: ar[5]}
+ });
+
+
+ },
+
+ fetchBugs : function(url)
+ {
+ Tickets.parseNetrc();
+ var ar = url.split('/');
+ print(JSON.stringify(ar, null, 4));
+ var auth = new Soup.Auth()
+ var session = new Soup.SessionSync();
+ session.signal.authenticate.connect(function(sess, msg, auth, rt) {
+ //print("authenticate?");
+ auth.authenticate(
+ Tickets.machines[ar[2]].login,
+ Tickets.machines[ar[2]].password
+ );
+ });
+ var request = new Soup.Message({
+ method:"GET",
+ uri:new Soup.URI.c_new(url)
+ });
+ var status = session.send_message(request);
+
+ var data = request.response_body.data;
+
+ print(data);
+ return JSON.parse(data).data;
+
+ }
+
+
+
+}
+
+
+//print ( JSON.stringify(Tickets.machines) );
+
+
+
+
+//Tickets.fetchBugs("http://www.roojs.com/mtrack/index.php/Gitlive/web.hex");
+
\ No newline at end of file
--- /dev/null
+<?php
+
+$ar = explode("\n",
+"app.Builder.js
+app.MailArchiver
+app.Mailer
+app.MailfortTools
+etc.FlexySpam
+etc.Texon
+gitlive
+netsuite.bloomgrow
+pear
+Pman.Admin
+Pman.Base
+Pman.Builder
+Pman.Cash
+Pman.Cms
+Pman.Core
+Pman.Dav
+Pman.Documents
+Pman.Fax
+Pman.Ftp
+Pman.Git
+Pman.Mail
+Pman.MTrack
+Pman.Signup
+Pman.Timesheet
+roojs1
+txt.MailfortNotes
+web.annerley
+web.aspencart
+web.aspengbic
+web.Aviation
+web.bloomandgrowasia.com
+web.Builder
+web.Dealflow
+web.facebook1
+web.FlexyShop
+web.FlexyShop2
+web.FlexySpam
+web.greenpeace.skype
+web.hex
+web.hex.new
+web.hhyc_membership_system
+web.Iconstruction
+web.intimateplay.com
+web.iris
+web.MediaOutreach
+web.mtrack
+web.Netsuite
+web.oxfam_translators
+web.Pman
+web.Ris
+web.roojsolutions
+web.seedling
+web.storkboxes
+web.Texon
+");
+
+
+
+
+$dir = '/home/alan/gitlive';
+foreach($ar as $a) {
+ $a = trim($a);
+ if (!file_exists($dir.'/'. $a)) {
+
+ $cmd = 'git clone http://git.roojs.com:8081/'. $a;
+echo $cmd ."\n";
+ `$cmd`;
+ }
+ if (file_exists($dir. '/'. $a.'.komodoproject')) {
+ continue;
+ }
+ $m = md5(rand());
+ $mm = array();
+ $b = array(8,4,4,4,12);
+ $bl = 0;
+ foreach($b as $bb) {
+ $mm[] = substr($m, $bl,$bb);
+ $bl+=$bb;
+ }
+ $mm = implode('-', $mm);
+
+file_put_contents($dir. '/'. $a.'.komodoproject',
+'<?xml version="1.0" encoding="UTF-8"?>
+<!-- Komodo Project File - DO NOT EDIT -->
+<project id="'.$mm.'" kpf_version="5" name="'.$a.'.komodoproject">
+<preference-set idref="'.$mm.'">
+ <string relative="path" id="import_dirname">'.$a.'</string>
+ <string id="import_exclude_matches">*.*~;*.bak;*.tmp;CVS;.#*;*.pyo;*.pyc;.svn;.git;.hg;.bzr;*%*;tmp*.html;.DS_Store;*.swp;*.kpf;*.komodoproject;*.komodoto
+ols</string>
+ <string id="import_include_matches"></string>
+ <string relative="path" id="last_local_directory">'.$a.'</string>
+</preference-set>
+</project>');
+
+}
+
+++ /dev/null
-#!/usr/bin/seed
-///<script type="text/javascript">
-/**
-* Git Live
-*
-* inotify hooks for ~/gitlive
-* that commit and push any changes made.
-* Bit like a revision controled backed up file system!?
-*
-*
-*/
-
-
-
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-
-
-// we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
-GI.Repository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.2');
-
-
-var Gio = imports.gi.Gio;
-var Gtk = imports.gi.Gtk;
-var Notify = imports.gi.Notify;
-
-var Spawn = imports.Spawn;
-var Git = imports.Git;
-var StatusIcon = imports.StatusIcon.StatusIcon;
-var Monitor = imports.Monitor.Monitor;
-
-
-//File = imports[__script_path__+'/../introspection-doc-generator/File.js'].File
-Gtk.init (null, null);
-
-var gitlive = GLib.get_home_dir() + "/gitlive";
-
-if (!GLib.file_test(gitlive, GLib.FileTest.IS_DIR)) {
- var msg = new Gtk.MessageDialog({message_type:
- Gtk.MessageType.INFO, buttons : Gtk.ButtonsType.OK, text: "GIT Live - ~/gitlive does not exist."});
- msg.run();
- msg.destroy();
-
- Seed.quit();
-}
-
-
-var monitor = new Monitor({
-
- queue : [],
- queueRunning : false,
-
- start: function() {
- var _this = this;
- this.lastAdd = new Date();
-
- GLib.timeout_add(GLib.PRIORITY_LOW, 500, function() {
- //TIMEOUT", _this.queue.length , _this.queueRunning].join(', '));
- if (!_this.queue.length || _this.queueRunning) {
- return 1;
- }
- var last = Math.floor(((new Date()) - this.lastAdd) / 100);
- if (last < 4) { // wait 1/2 a seconnd before running.
- return 1;
- }
- _this.runQueue();
- return 1;
- },null,null);
-
- Monitor.prototype.start.call(this);
- var notification = new Notify.Notification({
- summary: "Git Live",
- body : gitlive + "\nMonitoring " + this.monitors.length + " Directories"
- });
-
- notification.set_timeout(2000);
- notification.show();
- },
- /**
- * 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.
- *
- */
- runQueue: function()
- {
- this.queueRunning = true;
- var cmds = [];
- this.queue.forEach(function (q) {
- cmds.push(q);
- });
- this.queue = []; // empty queue!
-
- var success = [];
- var failure = [];
- var repos = [];
- var done = [];
- cmds.forEach(function(cmd) {
- // prevent duplicate calls..
- if (done.indexOf(cmd.join(',')) > -1) {
- return;
- }
- done.push(cmd.join(','));
-
- if (repos.indexOf(cmd[0]) < 0) {
- repos.push(cmd[0]);
- Git.run(cmd[0] , 'pull'); // pull before we push!
- }
- var sp = Git.run.apply(Git,cmd);
-
- switch (sp.result * 1) {
- case 0: // success:
- success.push(sp.args.join(' '));
- if (sp.output.length) success.push(sp.output + '');
- // if (sp.stderr.length) success.push(sp.stderr + '');
- break;
- default:
- failure.push(sp.args.join(' '));
- if (sp.output.length) failure.push(sp.output);
- if (sp.stderr.length) failure.push(sp.stderr);
- break;
- }
-
- });
-
- // push upstream.
- repos.forEach(function(r) {
- var sp = Git.run(r , 'push', { all: true } );
- if (sp.length) {
- success.push(sp);
- }
-
- });
-
- if (success.length) {
- print(success.join("\n"));
- var notification = new Notify.Notification({
- summary: "Git Live Commited",
- body : success.join("\n")
-
- });
-
- notification.set_timeout(2000);
- notification.show();
- }
- if (failure.length) {
-
- var notification = new Notify.Notification({
- summary: "Git Live ERROR!!",
- body : failure.join("\n")
-
- });
-
- notification.set_timeout(5000); // show errros for longer
- notification.show();
- }
- this.queueRunning = false;
- },
-
- shouldIgnore: function(f)
- {
- if (f.name[0] == '.') {
- // except!
- if (f.name == '.htaccess') {
- return false;
- }
-
- return true;
- }
- if (f.name.match(/~$/)) {
- return true;
- }
- // ignore anything in top level!!!!
- if (!f.vpath.length) {
- return true;
- }
-
- return false;
-
- },
-
- parsePath: function(f) {
-
- var vpath_ar = f.path.substring(gitlive.length +1).split('/');
-
- f.gitpath = gitlive + '/' + vpath_ar.shift();
- f.vpath = vpath_ar.join('/');
-
-
- },
-
- just_created : {},
-
- onChanged : function(src)
- {
- return; // always ignore this..?
- //this.parsePath(src);
- },
- onChangesDoneHint : function(src)
- {
- this.parsePath(src);
- if (this.shouldIgnore(src)) {
- return;
- }
-
- var add_it = false;
- if (typeof(this.just_created[src.path]) !='undefined') {
- delete this.just_created[src.path];
- this.lastAdd = new Date();
- this.queue.push(
- [ src.gitpath, 'add', src.vpath ],
- [ src.gitpath, 'commit', src.vpath, { message: src.vpath} ]
-
- );
-
- return;
- }
- this.lastAdd = new Date();
- this.queue.push(
- [ src.gitpath, 'add', src.vpath ],
- [ src.gitpath, 'commit', src.vpath, { message: src.vpath} ]
-
-
- );
-
-
- },
- onDeleted : function(src)
- {
- this.parsePath(src);
- if (this.shouldIgnore(src)) {
- return;
- }
- // should check if monitor needs removing..
- // it should also check if it was a directory.. - so we dont have to commit all..
-
- this.lastAdd = new Date();
- this.queue.push(
- [ src.gitpath, 'rm' , src.vpath ],
- [ src.gitpath, 'commit', { all: true, message: src.vpath} ]
-
- );
-
-
- },
- onCreated : function(src)
- {
- this.parsePath(src);
- if (this.shouldIgnore(src)) {
- return;
- }
-
- if (!GLib.file_test(src.path, GLib.FileTest.IS_DIR)) {
- this.just_created[src.path] = true;
- return; // we do not handle file create flags... - use done hint.
- }
- // director has bee created
- this.monitor(src.path);
- this.lastAdd = new Date();
- this.queue.push(
- [ src.gitpath, 'add' , src.vpath, { all: true } ],
- [ src.gitpath, 'commit' , { all: true, message: src.vpath} ]
-
- );
-
-
- },
- onAttributeChanged : function(src) {
- this.parsePath(src);
- if (this.shouldIgnore(src)) {
- return;
- }
- this.lastAdd = new Date();
- this.queue.push(
- [ src.gitpath, 'commit' , src.vpath, { message: src.vpath} ]
- );
-
-
- },
-
- onMoved : function(src,dest)
- {
- this.parsePath(src);
- this.parsePath(dest);
-
- if (src.gitpath != dest.gitpath) {
- this.onDeleted(src);
- this.onCreated(dest);
- this.onChangedDoneHint(dest);
- return;
- }
- // needs to handle move to/from unsupported types..
-
- if (this.shouldIgnore(src)) {
- return;
- }
- if (this.shouldIgnore(dest)) {
- return;
- }
- this.lastAdd = new Date();
- this.queue.push(
- [ src.gitpath, 'mv', '-k', src.vpath, dest.vpath ],
- [ src.gitpath, 'commit' , src.vpath, dest.vpath ,
- { message: 'MOVED ' + src.vpath +' to ' + dest.vpath} ]
- );
-
- }
-
-
-});
-
-
-
-
-function errorDialog(data) {
- var msg = new Gtk.MessageDialog({
- message_type: Gtk.MessageType.ERROR,
- buttons : Gtk.ButtonsType.OK,
- text: data
- });
- msg.run();
- msg.destroy();
-}
-
-
-
-
-
-//
-// need a better icon...
-
-
-StatusIcon.init();
-
-
-Notify.init("gitlive");
-
-monitor.add(GLib.get_home_dir() + "/gitlive");
-monitor.start();
-Gtk.main();
-//icon.signal["activate"].connect(on_left_click);
-
--- /dev/null
+#!/usr/bin/seed
+///<script type="text/javascript">
+/**
+* Git Live
+*
+* inotify hooks for ~/gitlive
+* that commit and push any changes made.
+* Bit like a revision controled backed up file system!?
+*
+*
+* The aims of this
+* A) have a gitlive branch - where all our commits go.. - so they can be replicated on the server
+* B) HEAD branch - where things get merged to..
+* -- eventually on closing issues..
+* -- currently when we switch from one feature to another..
+*
+* CURRENT HEAD?
+* git log -n 1 --pretty=format:%H BRANCHNAME
+*
+*
+*
+* Notes on feature branch implementation
+* We need to add a gitlive branch on the remote server..
+* git push origin origin:refs/heads/gitlive
+* git checkout --track -b gitlive origin/gitlive << means pull will use both branches..
+*
+*
+* On our feature tree..
+* git push origin origin:refs/heads/feature_2
+*
+* we clone directory into gitlive_feature/XXXXX
+* git branch issue_XXX
+* git checkout issue_XXX
+*
+* run this on the feature branch it merges and commits..
+* git pull origin master << or gitlive..
+*
+*
+* Standard change file (same bug as before..)
+* cd gitlive
+* commit etc.. (with bug no..)
+* cd featuredir
+* git pull origin gitlive
+* git push
+* cd gitlive
+* git push
+*
+* Change to new bug number..
+* cd featuredir
+* git checkout -b master origin/master
+* git checkout master <<< make sure
+* git pull --squash origin gitlive
+* git commit -m 'done with old bug number'
+* git push
+* cd gitlive
+* git push
+* cd featuredir
+* git push origin origin:refs/heads/feature_XXX
+* git checkout feature_XXX
+* cd gitlive
+* commit etc. (with new bug number)
+* cd featuredir
+* git pull origin gitlive
+* git push
+* cd gitlive
+* git push
+*
+*/
+
+GI = imports.gi.GIRepository
+GLib = imports.gi.GLib;
+
+// we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
+GI.IRepository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.1');
+
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Notify = imports.gi.Notify;
+
+Spawn = imports.Spawn;
+Git = imports.Git;
+StatusIcon = imports.StatusIcon.StatusIcon;
+Monitor = imports.Monitor.Monitor;
+File = imports.File.File;
+
+
+
+//File = imports[__script_path__+'/../introspection-doc-generator/File.js'].File
+Gtk.init (null, null);
+
+var gitlive = GLib.get_home_dir() + "/gitlive";
+
+if (!GLib.file_test(gitlive, GLib.FileTest.IS_DIR)) {
+ var msg = new Gtk.MessageDialog({message_type:
+ Gtk.MessageType.INFO, buttons : Gtk.ButtonsType.OK, text: "GIT Live - ~/gitlive does not exist."});
+ msg.run();
+ msg.destroy();
+
+ Seed.quit();
+}
+
+
+var monitor = new Monitor({
+ /**
+ *
+ * queue objects
+ * action: 'add' | rm | update
+ * repo : 'gitlive'
+ * file : XXXXX
+ *
+ *
+ *
+ */
+ action_queue : [],
+ queueRunning : false,
+
+ start: function()
+ {
+
+
+
+ this.dot_gitlive = GLib.get_home_dir() + "/.gitlive";
+ if (!File.exists(this.dot_gitlive)) {
+ File.mkdir(this.dot_gitlive);
+ }
+
+
+ var _this = this;
+ this.lastAdd = new Date();
+
+ // start monitoring first..
+ Monitor.prototype.start.call(this);
+
+ // then start our queue runner..
+ GLib.timeout_add(GLib.PRIORITY_LOW, 500, function() {
+ //TIMEOUT", _this.queue.length , _this.queueRunning].join(', '));
+ if (!_this.queue.length || _this.queueRunning) {
+ return 1;
+ }
+ var last = Math.floor(((new Date()) - this.lastAdd) / 100);
+ if (last < 4) { // wait 1/2 a seconnd before running.
+ return 1;
+ }
+ _this.runQueue();
+ return 1;
+ },null,null);
+
+
+ var notification = new Notify.Notification({
+ summary: "Git Live",
+ body : gitlive + "\nMonitoring " + this.monitors.length + " Directories"
+ });
+
+ notification.set_timeout(2000);
+ notification.show();
+ },
+
+ initRepo : function(src)
+ {
+ print("INIT REPO " + src);
+
+ function logrun(sp) {
+ print("LOGRUN?" + typeof(sp));
+ switch (sp.result * 1) {
+ case 0: // success:
+ print(sp.args.join(' '));
+ if (sp.output.length) print(sp.output + '');
+ // if (sp.stderr.length) success.push(sp.stderr + '');
+ break;
+ default:
+ print(sp.args.join(' '));
+ if (sp.output.length) print(sp.output);
+ if (sp.stderr.length) print(sp.stderr);
+ break;
+ }
+ }
+
+ // make hour mirrored directory
+ var rname = src.split('/').pop();
+ var dotdir = this.dot_gitlive + '/' + rname;
+
+ print("CHECK WORKING CACHE " + dotdir);
+
+ if (!File.isDirectory(dotdir)) {
+ // print("Not a dir?");
+ logrun(Git.run(this.dot_gitlive, 'clone', src , { shared : true } ));
+ }
+ // refresh - always..
+ logrun(Git.run(src, 'pull'));
+
+ // create and checkout gitlive branch.
+ logrun(Git.run(src, 'push', 'origin', 'origin:refs/heads/gitlive'));
+ logrun(Git.run(src, 'checkout', { track : true , 'b' : 'gitlive' } , 'origin/gitlive'));
+
+
+
+
+
+
+
+
+ },
+
+
+ /**
+ * 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.
+ *
+ */
+ runQueue: function()
+ {
+ this.queueRunning = true;
+ var cmds = [];
+ //this.queue.forEach(function (q) {
+ // cmds.push(q);
+ //});
+
+ this.action_queue.forEach(function (q) {
+ cmds.push(q);
+ });
+ //this.queue = []; // empty queue!
+ this.action_queue = [];
+ var success = [];
+ var failure = [];
+ var repos = [];
+ var done = [];
+
+ function readResult(sp) {
+ switch (sp.result * 1) {
+ case 0: // success:
+ success.push(sp.args.join(' '));
+ if (sp.output.length) success.push(sp.output + '');
+ // if (sp.stderr.length) success.push(sp.stderr + '');
+ break;
+ default:
+ failure.push(sp.args.join(' '));
+ if (sp.output.length) failure.push(sp.output);
+ if (sp.stderr.length) failure.push(sp.stderr);
+ break;
+ }
+ }
+
+ cmds.forEach(function(cmd) {
+ // prevent duplicate calls..
+ if (done.indexOf(JSON.stringify(cmd)) > -1) {
+ return;
+ }
+ done.push(JSON.stringify(cmd));
+ // --- we keep a list of repositories that will be pushed to at the end..
+
+ if (repos.indexOf(cmd.repos) < 0) {
+ repos.push(cmd.repos);
+ // Git.run(cmd.repos , 'pull'); // pull before we push!
+ }
+
+
+ // at this point we need to know the issue number...
+
+
+ var gp = gitlive + '/' + cmd.repo;
+ var dotdir = this.dot_gitlive + '/' + rname;
+
+ // create feature branch. - if it's a new feature..
+ readResult(Git.run(dotdir, 'push', 'origin', 'origin:refs/heads/feature_XXX'));
+ readResult(Git.run(dotdir, 'checkout', 'feature_XXX'));
+
+ switch( cmd.action ) {
+ case 'add':
+ readResult(Git.run(gp, 'add', cmd.file ));
+ readResult(Git.run(gp, 'commit', src.file, { message: cmd.file} ));
+
+ break;
+
+ case 'rm':
+ readResult(Git.run(gp, 'rm', cmd.file ));
+ readResult(Git.run(gp, 'commit', { all: true, message: cmd.file} ));
+ break;
+
+ case 'update':
+ readResult(Git.run(gp, 'commit', cmd.file , { message: cmd.file} ));
+ break;
+
+ case 'mv':
+ readResult(Git.run(gp, 'mv', cmd.file , cmd.target));
+ readResult(Git.run(gp, 'commit', cmd.file , cmd.target,
+ { message: 'MOVED ' + src.file +' to ' + dest.target } ));
+ break;
+ }
+ // duplicate the changes into the feature dir, and push it back into the data..
+ readResult(Git.run(dotdir, 'pull', 'origin', 'gitlive'));
+ readResult(Git.run(dotdir, 'push'));
+
+
+ });
+
+ // push upstream.
+ repos.forEach(function(r) {
+ var sp = Git.run(gitlive + '/' +r , 'push', { all: true } );
+ if (sp.length) {
+ success.push(sp);
+ }
+
+ });
+
+ if (success.length) {
+ print(success.join("\n"));
+ var notification = new Notify.Notification({
+ summary: "Git Live Commited",
+ body : success.join("\n")
+
+ });
+
+ notification.set_timeout(2000);
+ notification.show();
+ }
+ if (failure.length) {
+
+ var notification = new Notify.Notification({
+ summary: "Git Live ERROR!!",
+ body : failure.join("\n")
+
+ });
+
+ notification.set_timeout(5000); // show errros for longer
+ notification.show();
+ }
+ this.queueRunning = false;
+ },
+
+ shouldIgnore: function(f)
+ {
+ if (f.name[0] == '.') {
+ // except!
+ if (f.name == '.htaccess') {
+ return false;
+ }
+
+ return true;
+ }
+ if (f.name.match(/~$/)) {
+ return true;
+ }
+ // ignore anything in top level!!!!
+ if (!f.vpath.length) {
+ return true;
+ }
+
+ return false;
+
+ },
+
+ /**
+ * set gitpath and vpath
+ *
+ *
+ */
+
+ parsePath: function(f)
+ {
+
+ var vpath_ar = f.path.substring(gitlive.length +1).split('/');
+ f.repo = vpath_ar.shift();
+ f.gitpath = gitlive + '/' + f.repo;
+ f.vpath = vpath_ar.join('/');
+
+
+ },
+
+ just_created : {},
+
+ onChanged : function(src)
+ {
+ return; // always ignore this..?
+ //this.parsePath(src);
+ },
+
+ /**
+ * results in git add + git commit..
+ *
+ *
+ *
+ */
+
+ onChangesDoneHint : function(src)
+ {
+ this.parsePath(src);
+ if (this.shouldIgnore(src)) {
+ return;
+ }
+
+ var add_it = false;
+ if (typeof(this.just_created[src.path]) !='undefined') {
+ delete this.just_created[src.path];
+ this.lastAdd = new Date();
+ //this.queue.push(
+ // [ src.gitpath, 'add', src.vpath ],
+ // [ src.gitpath, 'commit', src.vpath, { message: src.vpath} ]
+ //
+ //);
+ this.action_queue.push({
+ action: 'add',
+ repo : src.repo,
+ file : src.vpath
+ });
+
+
+
+ return;
+ }
+ this.lastAdd = new Date();
+ //this.queue.push(
+ // [ src.gitpath, 'add', src.vpath ],
+ // [ src.gitpath, 'commit', src.vpath, { message: src.vpath} ]
+ //
+ //);
+
+ this.action_queue.push({
+ action: 'add',
+ repo : src.repo,
+ file : src.vpath
+ });
+
+
+ },
+ onDeleted : function(src)
+ {
+ this.parsePath(src);
+ if (this.shouldIgnore(src)) {
+ return;
+ }
+ // should check if monitor needs removing..
+ // it should also check if it was a directory.. - so we dont have to commit all..
+
+ this.lastAdd = new Date();
+ //this.queue.push(
+ // [ src.gitpath, 'rm' , src.vpath ],
+ // [ src.gitpath, 'commit', { all: true, message: src.vpath} ]
+ //
+ //);
+ this.action_queue.push({
+ action: 'rm',
+ repo : src.repo,
+ file : src.vpath
+ });
+
+ },
+ onCreated : function(src)
+ {
+ this.parsePath(src);
+ if (this.shouldIgnore(src)) {
+ return;
+ }
+
+ if (!GLib.file_test(src.path, GLib.FileTest.IS_DIR)) {
+ this.just_created[src.path] = true;
+ return; // we do not handle file create flags... - use done hint.
+ }
+ // director has bee created
+ this.monitor(src.path);
+
+ /*
+ since git does not really handle directory adds...
+
+ this.lastAdd = new Date();
+ this.action_queue.push({
+ action: 'add',
+ repo : src.repo,
+ file : src.vpath
+ });
+
+ this.queue.push(
+ [ src.gitpath, 'add' , src.vpath, { all: true } ],
+ [ src.gitpath, 'commit' , { all: true, message: src.vpath} ]
+
+ );
+ */
+
+
+ },
+ onAttributeChanged : function(src) {
+ this.parsePath(src);
+ if (this.shouldIgnore(src)) {
+ return;
+ }
+ this.lastAdd = new Date();
+
+
+ //this.queue.push(
+ // [ src.gitpath, 'commit' , src.vpath, { message: src.vpath} ]
+ // );
+ this.action_queue.push({
+ action: 'update',
+ repo : src.repo,
+ file : src.vpath
+ });
+
+
+ },
+
+ onMoved : function(src,dest)
+ {
+ this.parsePath(src);
+ this.parsePath(dest);
+
+ if (src.gitpath != dest.gitpath) {
+ this.onDeleted(src);
+ this.onCreated(dest);
+ this.onChangedDoneHint(dest);
+ return;
+ }
+ // needs to handle move to/from unsupported types..
+
+ if (this.shouldIgnore(src)) {
+ return;
+ }
+ if (this.shouldIgnore(dest)) {
+ return;
+ }
+ this.lastAdd = new Date();
+ // this.queue.push(
+ // [ src.gitpath, 'mv', '-k', src.vpath, dest.vpath ],
+ // [ src.gitpath, 'commit' , src.vpath, dest.vpath ,
+ // { message: 'MOVED ' + src.vpath +' to ' + dest.vpath} ]
+ // );
+
+ this.action_queue.push({
+ action: 'mv',
+ repo : src.repo,
+ file : src.vpath,
+ target : dest.vpath
+
+ });
+
+ }
+
+
+});
+
+
+
+
+function errorDialog(data) {
+ var msg = new Gtk.MessageDialog({
+ message_type: Gtk.MessageType.ERROR,
+ buttons : Gtk.ButtonsType.OK,
+ text: data
+ });
+ msg.run();
+ msg.destroy();
+}
+
+
+
+
+
+//
+// need a better icon...
+
+
+StatusIcon.init();
+
+
+Notify.init("gitlive");
+
+monitor.add(GLib.get_home_dir() + "/gitlive");
+monitor.start();
+Gtk.main();
+//icon.signal["activate"].connect(on_left_click);
+
--- /dev/null
+<?xml version="1.0"?>
+<!-- This file was automatically generated from C sources - DO NOT EDIT!
+To affect the contents of this file, edit the original C definitions,
+and/or use gtk-doc annotations. -->
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+ <namespace name="sqlite3"
+ version="1.0"
+ shared-library="libsqlite3.so.0"
+ c:prefix="sqlite3">
+ <callback name="callback" c:type="sqlite3_callback" doc="Test docs">
+ <return-value transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </return-value>
+ <parameters>
+ <parameter name="user_data" transfer-ownership="none" closure="0">
+ <type name="any" c:type="void*"/>
+ </parameter>
+ <parameter name="connection" transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </parameter>
+ <parameter name="data1" transfer-ownership="none">
+ <array c:type="char**">
+ <type name="utf8"/>
+ </array>
+ </parameter>
+ <parameter name="data2" transfer-ownership="none">
+ <array c:type="char**">
+ <type name="utf8"/>
+ </array>
+ </parameter>
+ </parameters>
+ </callback>
+ </namespace>
+</repository>
--- /dev/null
+#!/usr/bin/seed
+//<Script type="text/javascript">
+/**
+ * runtime file
+ * takes a gtk project directory, and turns it into an application!
+ * by compling the files into JS files..
+ *
+ * Initially developed for runtime testing. (the vte runner)
+ *
+ * Might be the way to go for full runtime
+ *
+ *
+ * Usage: (call with wrapper to set up directories..)
+ * sh builder.sh
+ *
+ * Concepts..
+ * a) load dependancies.. (eg. gi's..) - derived later?
+ * Gtk.init()
+ *
+ * loop the files (find .bjs)
+ * - comple to js (if not exist // or force enabled..)
+ * b) load all the files
+ *
+ * Gtk.main();
+ *
+ */
+// autogen?
+
+// sort out import path - this is a bit of a mess..
+GIRepository = imports.gi.GIRepository;
+GLib = imports.gi.GLib;
+
+// we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
+GIRepository.IRepository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.1');
+//print(JSON.stringify(GIRepository.IRepository.get_search_path()));
+
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+
+Gdl = imports.gi.Gdl;
+
+GtkClutter = imports.gi.GtkClutter;
+
+if (GtkClutter) {
+ GtkClutter.init(Seed.argv);
+}
+
+File = imports.File.File;
+
+XObject = imports.XObject.XObject;
+//XObject.debug = true;
+Gtk.init(Seed.argv);
+
+
+imports.searchPath.push('/'); // allow global paths..
+// error checking todo..
+
+var ret = imports.FixBug.FixBug.show();
+print("show returned\n");
+print(JSON.stringify(ret,null, 4));
+
+
+
+Gtk.main();
+
--- /dev/null
+/**
+ *
+ * let's see if we can pull a list of tickets from the tracker..
+ *
+ */
+
+GI = imports.gi.GIRepository
+GLib = imports.gi.GLib;
+
+// we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
+GI.IRepository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.1');
+
+Soup = imports.gi.Soup ;
+
+
+File = imports['../File.js'].File;
+
+Tickets = {
+
+ parseNetrc : function()
+ {
+ this.machines = {};
+ // very basic parsing - only support single line version..
+ var lines = File.read(GLib.get_home_dir() + '/.netrc').split(/\n/);
+ var t = this;
+ lines.forEach(function(l) {
+ if (!l.match(/^machine/)) {
+ return;
+ }
+ var ar = l.split(/\s+/);
+ // assume machine XXX login XXX password XXXX
+ t.machines[ar[1]] = { login : ar[3], password: ar[5]}
+ });
+
+
+ },
+
+ fetchBugs : function(url)
+ {
+ Tickets.parseNetrc();
+ var ar = url.split('/');
+ print(JSON.stringify(ar, null, 4));
+ var auth = new Soup.Auth()
+ var session = new Soup.SessionSync();
+ session.signal.authenticate.connect(function(sess, msg, auth, rt) {
+ //print("authenticate?");
+ auth.authenticate(
+ Tickets.machines[ar[2]].login,
+ Tickets.machines[ar[2]].password
+ );
+ });
+ var request = new Soup.Message({
+ method:"GET",
+ uri:new Soup.URI.c_new(url)
+ });
+ var status = session.send_message(request);
+
+ var data = request.response_body.data;
+ return JSON.parse(data).data;
+
+ }
+
+
+
+}
+
+
+//print ( JSON.stringify(Tickets.machines) );
+
+
+
+
+//Tickets.fetchBugs("http://www.roojs.com/mtrack/index.php/Gitlive/web.hex");
+
\ No newline at end of file