-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the test more interactive and add minified version
- Loading branch information
1 parent
7ae5980
commit 27b76ee
Showing
4 changed files
with
88 additions
and
57 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,56 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script src="jsgit.js"></script> | ||
<script src="jsgit.min.js"></script> | ||
</head> | ||
<body> | ||
<h1>JS-Git Browser Test Page</h1> | ||
<p>You must serve this page using the included node server that proxies websocket connections out to real git servers.</p> | ||
<script> | ||
|
||
// Create a new in-memory database | ||
var db = jsgit.db("test"); | ||
var repo, remote; | ||
db.init(onInit); | ||
var repo, remote; | ||
var url = prompt("Enter the git url to a small repo", | ||
"git://github.com/creationix/conquest.git"); | ||
// Create a wrapper to a remote repository | ||
var remote = jsgit.remote(url); | ||
console.log(remote); | ||
var name = url.substr(url.lastIndexOf("/") + 1); | ||
// Create a new in-memory database | ||
var db = jsgit.db(name); | ||
console.log(db); | ||
// Wrap it in git logic | ||
var repo = jsgit.repo(db); | ||
console.log(repo); | ||
var element; | ||
// Initialize the database | ||
db.init(onInit); | ||
|
||
function onInit(err) { | ||
if (err) throw err; | ||
// Wrap it in git logic | ||
repo = jsgit.repo(db); | ||
console.log(repo); | ||
// Create a wrapper to a remote repository | ||
remote = jsgit.remote("git://github.com/creationix/conquest.git"); | ||
console.log(remote); | ||
// Clone the remote repo to te local db. | ||
var opts = { | ||
onProgress: onProgress, | ||
deline: true | ||
}; | ||
repo.fetch(remote, opts, onDone); | ||
} | ||
function onInit(err) { | ||
if (err) throw err; | ||
// Clone the remote repo to te local db. | ||
onProgress("Fetching updates for or cloning " + url + "\n"); | ||
repo.fetch(remote, { | ||
onProgress: onProgress, | ||
deline: true | ||
}, onDone); | ||
} | ||
|
||
function onProgress(progress) { | ||
console.log(progress); | ||
function onProgress(progress) { | ||
if (!element || progress[progress.length - 1] === "\n") { | ||
element = document.createElement("p"); | ||
document.body.appendChild(element); | ||
} | ||
element.textContent = progress.trim(); | ||
} | ||
|
||
function onDone(err) { | ||
if (err) throw err; | ||
console.log("Done"); | ||
function onDone(err) { | ||
if (err) { | ||
onProgress(err.stack + "\n"); | ||
throw err; | ||
} | ||
onProgress("Done!\n"); | ||
} | ||
|
||
</script> | ||
</head> | ||
<body> | ||
Look at the console for output. | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,56 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script src="jsgit.js"></script> | ||
<script src="jsgit.min.js"></script> | ||
</head> | ||
<body> | ||
<h1>JS-Git Browser Test Page</h1> | ||
<p>You must serve this page using the included node server that proxies websocket connections out to real git servers.</p> | ||
<script> | ||
|
||
// Create a new in-memory database | ||
var db = jsgit.db("test"); | ||
var repo, remote; | ||
db.init(onInit); | ||
var repo, remote; | ||
var url = prompt("Enter the git url to a small repo", | ||
"git://github.com/creationix/conquest.git"); | ||
// Create a wrapper to a remote repository | ||
var remote = jsgit.remote(url); | ||
console.log(remote); | ||
var name = url.substr(url.lastIndexOf("/") + 1); | ||
// Create a new in-memory database | ||
var db = jsgit.db(name); | ||
console.log(db); | ||
// Wrap it in git logic | ||
var repo = jsgit.repo(db); | ||
console.log(repo); | ||
var element; | ||
// Initialize the database | ||
db.init(onInit); | ||
|
||
function onInit(err) { | ||
if (err) throw err; | ||
// Wrap it in git logic | ||
repo = jsgit.repo(db); | ||
console.log(repo); | ||
// Create a wrapper to a remote repository | ||
remote = jsgit.remote("git://github.com/creationix/conquest.git"); | ||
console.log(remote); | ||
// Clone the remote repo to te local db. | ||
var opts = { | ||
onProgress: onProgress, | ||
deline: true | ||
}; | ||
repo.fetch(remote, opts, onDone); | ||
} | ||
function onInit(err) { | ||
if (err) throw err; | ||
// Clone the remote repo to te local db. | ||
onProgress("Fetching updates for or cloning " + url + "\n"); | ||
repo.fetch(remote, { | ||
onProgress: onProgress, | ||
deline: true | ||
}, onDone); | ||
} | ||
|
||
function onProgress(progress) { | ||
console.log(progress); | ||
function onProgress(progress) { | ||
if (!element || progress[progress.length - 1] === "\n") { | ||
element = document.createElement("p"); | ||
document.body.appendChild(element); | ||
} | ||
element.textContent = progress.trim(); | ||
} | ||
|
||
function onDone(err) { | ||
if (err) throw err; | ||
console.log("Done"); | ||
function onDone(err) { | ||
if (err) { | ||
onProgress(err.stack + "\n"); | ||
throw err; | ||
} | ||
onProgress("Done!\n"); | ||
} | ||
|
||
</script> | ||
</head> | ||
<body> | ||
Look at the console for output. | ||
</body> | ||
</html> |