Gio = imports.gi.Gio;
GLib = imports.gi.GLib;
-Spawn = imports.Spawn.Spawn;
+Spawn = imports.Spawn.Spawn;
+File = imports.File.File;
/**
* @namespace Git
*
repo : '',
/**
* @method run
- *
* @arg command {String} command to run
* @arg arguments.... {String|Object} arguments to send to command
- *
+ * { xxxx : yyyy} -> --xxxx YYYYY
+ * { x : yyyy} -> -x yyyy
*
*/
run : function() {
+ //print("GIT RUN");
var args = ['git'];
+
for (var i=0;i< arguments.length;i++) {
if (typeof(arguments[i]) == 'string') {
args.push(arguments[i]);
if (typeof(arguments[i]) == 'object') {
for(var k in arguments[i]) {
var v = arguments[i][k];
- args.push('--' + k);
+
+ args.push(k.length > 1 ? ('--' + k) : ('-' + k));
+
if (v === true) {
continue;
}
}
}
+ var env = [ "HOME=" + GLib.get_home_dir() ];
+ if (File.exists(this.repo + '/.git/config')) {
+ env.push("GITPATH=" + this.repo );
+ }
+
+
+ //print(args.join( ' '));
var sp = new Spawn({
- env : [ "GITPATH=" + this.repo , "HOME=" + GLib.get_home_dir() ],
+ //env : [ "GITPATH=" + this.repo , "HOME=" + GLib.get_home_dir() ],
+ env : env,
cwd : this.repo,
args: args,
debug: true,
*/
function run() {
+ //print("Git.run()");
var args = Array.prototype.slice.call(arguments);
-
+ //print(JSON.stringify(args));
var repo = args.shift(args);
var x = new Git(repo);
-
+ //print(JSON.stringify(args));
return x.run.apply(x, args);
}
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
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();
notification.show();
},
- initRepo : function(src) {
- print("INIT REPO " + src);
+ 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'));
+
+
+
+
+
+
+
},