1 ///<script type="text/javascript">
4 GLib = imports.gi.GLib;
6 Spawn = imports.Spawn.Spawn;
7 File = imports.File.File;
11 * Class to handle git operations..???
15 * Git = import.Git.Git;
17 * var g = new Git( '/home/me/git' );
19 * g.run('commit', { all : true , message : 'test' }, 'filename',)
22 * print(Git.run('/home/me/git', 'log'))
31 * @param repo {String} directory that the repo is in, either bare or not.
35 //var prototypeInit = false;
38 if (!GLib.file_test(repo, GLib.FileTest.IS_DIR)) {
39 throw "Repo does not exist";
44 // proto type on set up yet..
45 // we could list this to generate methods.. /usr/lib/git-core/
46 var props = Gil.prototypeInit();
47 for (var i in props) {
58 * @arg command {String} command to run
59 * @arg arguments.... {String|Object} arguments to send to command
60 * { xxxx : yyyy} -> --xxxx YYYYY
61 * { x : yyyy} -> -x yyyy
69 for (var i=0;i< arguments.length;i++) {
70 if (typeof(arguments[i]) == 'string') {
71 args.push(arguments[i]);
74 if (typeof(arguments[i]) == 'object') {
75 for(var k in arguments[i]) {
76 var v = arguments[i][k];
78 args.push(k.length > 1 ? ('--' + k) : ('-' + k));
88 var env = [ "HOME=" + GLib.get_home_dir() ];
90 if (File.exists(this.repo + '/.git/config')) {
91 env.push("GITPATH=" + this.repo );
95 //print(args.join( ' '));
97 //env : [ "GITPATH=" + this.repo , "HOME=" + GLib.get_home_dir() ],
106 // parse output for some commands ?
114 * @arg command {String} command to run
115 * @arg arguments.... {String|Object} arguments to send to command
121 // print("Git.run()");
122 var args = Array.prototype.slice.call(arguments);
123 //print(JSON.stringify(args));
124 var repo = args.shift(args);
125 var x = new Git(repo);
126 // print(JSON.stringify(args));
127 return x.run.apply(x, args);
133 //print(run('/home/alan/gitlive/gitlive', 'log'));