-
-
Save devoncarew/6893556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library git; | |
import 'dart:async'; | |
import 'dart:html'; | |
import 'dart:js' as js; | |
import 'package:chrome/app.dart' as chrome; | |
import 'lib/utils.dart'; | |
class GitResult { | |
var foo; | |
GitResult.fromData(this.foo); | |
} | |
class Git { | |
static final _jsContext = js.context; | |
static final JsObject _jsgit = context['GitApi']; | |
var fs; | |
Git() { | |
print("hello in this new world."); | |
_jsContext.console.log(_jsgit); | |
this.getFilesystem(); | |
} | |
void requestFileSystemCallback(fs) { | |
this.fs = fs; | |
vlog(fs); | |
fs.root.createDirectory("grv") | |
.then(this.abc, onError: this.handleError); | |
} | |
void abc(entry) { | |
print('abc'); | |
this.clone(entry); | |
} | |
void handleError(e) { | |
vlog(e); | |
print('error in getting filesystem.'); | |
} | |
void getFilesystem() { | |
window.requestFileSystem(2*1024*1024, persistent: false) | |
.then(this.requestFileSystemCallback, onError: this.handleError); | |
} | |
void cloneSuccess() { | |
print('clone successful'); | |
} | |
void cloneFailed() { | |
print('clone failed'); | |
} | |
void vlog(obj) { | |
window.console.log(obj); | |
} | |
void cloneProgress(info) { | |
js.context.console.log("nothing"); | |
js.context.console.log(info); | |
} | |
Future<GitResult> clone(DirectoryEntry entry) { | |
Completer<GitResult> completer = new Completer(); | |
var source ="http://github.com/gaurave/trep.git"; | |
var options = js.map({ | |
'dir': entry, | |
'url': source, | |
'depth': 1, | |
'progress': this.cloneProgress | |
}); | |
var successCallback = (someData) { | |
print('inside success.'); | |
completer.complete(new GitResult.fromData(someData)); | |
}; | |
var errorCallback = (String message) { | |
print('inside error'); | |
completer.complete(new GitResult.fromData(message)); | |
}; | |
js.context.console.log(js.context.GitApi); | |
print('just before'); | |
JsObject jsgit = context['GitApi']; | |
//jsgit.callMethod('clone',[options, successCallback, errorCallback]); | |
//var callbackSuccess = new js.Callback.once(this.cloneSuccess); | |
//var callbackFailed = new js.Callback.once(this.cloneFailed); | |
//_jsgit.callMethod("clone", [options, callbackSuccess, callbackFailed]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment