Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chris #10

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e3ad578
Add simple test runner.
chrisdickinson Aug 12, 2011
12fdf26
Tests run using 'node test/index.js' now.
chrisdickinson Aug 12, 2011
65eee20
Add package.json.
chrisdickinson Aug 12, 2011
3927842
Remove deprecated 'require.paths' modification, change to relative pa…
chrisdickinson Aug 12, 2011
8b9fd6e
Refactor to use CommonJS idioms.
chrisdickinson Aug 12, 2011
3226e3d
Merge branch 'bugfix/npmpackage' into bugfix/testrunner
chrisdickinson Aug 12, 2011
5741842
Add lib/btoa.js for node.js btoa.
chrisdickinson Aug 12, 2011
dde2b4e
Rework jasmine tests to work with new commonjs pattern
chrisdickinson Aug 12, 2011
8af63d6
pack_index requires string_helpers
chrisdickinson Aug 12, 2011
275d7cf
Fix broken spec/commands/ log test
chrisdickinson Aug 13, 2011
59a96d4
Abstract out the http interface.
chrisdickinson Aug 14, 2011
01d7ce4
Compare callback to 'undefined'
chrisdickinson Aug 14, 2011
29b0e22
Rewrite package builder -- browser repo viewer works again.
chrisdickinson Aug 15, 2011
490a480
Prepare js-deflate for web workers
chrisdickinson Aug 15, 2011
2e9e5c4
Add lib/git/zlib.js; will attempt to provide a web worker version of …
chrisdickinson Aug 15, 2011
030656a
Add a nicer 'toString' method to BinaryFile
chrisdickinson Aug 15, 2011
e166fa9
Rework http.js
chrisdickinson Aug 15, 2011
6139427
Big rewrite: make zlib.inflate and zlib.deflate async, make smart_htt…
chrisdickinson Aug 15, 2011
f70bb38
Ensure build directory exists
danlucraft Aug 18, 2011
90c1347
Don't load diff.js explicitly in the repo-viewer demo now it is packaged
danlucraft Aug 18, 2011
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ response_body.bin
test/fixtures/test-repo1/
test/fixtures/test-repo1-packed
.DS_store
demos/serve
demos/serve
build
node_modules
98 changes: 87 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@



namespace :test do
desc "Reset the github test repo"
task :reset do
Expand All @@ -17,18 +15,96 @@ end

desc "Concatenate the javascript for the client"
task :package_client do
load_file = File.read(File.dirname(__FILE__) + "/lib/git-client.js")
paths = load_file.scan(/getScript\("\/([^"]*)"\)/)
js = ["jsGitInNode = false"]
paths.each do |path|
js << File.read(File.dirname(__FILE__) + "/" + path.first)
end
preamble = <<-PREAMBLE
(function(exp) {
exp.Git = {}
exp.Git.modules = {}
var getModule = function(path) {
var module = exp.Git.modules[path]
if(module)
return module
module = {
exports:{},
path:path,
execute:null,
toString:function() { return '<Module: "'+path+'">'; }
}
exp.Git.modules[path] = module
return module
}

var resolve = function(path) {
var bits = path.split('/')
var out = []
for(var i = 0, len = bits.length; i < len; ++i) {
var cur = bits[i]
if(bits[i] === '.')
continue;
else if(bits[i] === '..')
out.pop()
else
out.push(bits[i])
}
return out.join('/')
}

var getRequire = function(module) {
var basename = module.path.split('/').slice(0, -1).join('/');
return function(path) {
path === 'underscore' &&
(path = 'vendor/underscore-min')

var first = path.slice(0, 2),
fullpath
if(first === './' || first === '..') {
fullpath = resolve(basename+'/'+path)
} else {
fullpath = resolve(path)
}
var mod = exp.Git.modules[fullpath]
mod.execute && mod.execute()
return mod.exports
}
}

exp.GIT__module__ = getModule
exp.GIT__require__ = getRequire
exp.Git.require = getRequire(getModule('.'))
})(window);
PREAMBLE

wrap = <<-WRAP
(function() {
var module = GIT__module__('%s')
var require = GIT__require__(module)
module.execute = function() {
(function(module, exports, require) {
%s
})(this, this.exports, require)
module.execute = null;
}
})();
WRAP

# TODO: replace this hackiness with something better.
libraries = Dir['lib/*.js'] + Dir['lib/*/*.js'] + Dir['lib/*/*/*.js']
vendor = Dir['vendor/*.js'] + Dir['vendor/*/*.js']

js = [preamble]
(libraries + vendor).each do |path|
js << wrap % [
path.sub('.js', ''),
File.read(File.dirname(__FILE__) + "/" + path)
]
end

total_js = js.join("\n\n")
File.open("lib/git.min.js", "w") {|f| f.puts total_js }
puts "packaged lib/git.min.js"
FileUtils.mkdir_p("build")
File.open("build/git.min.js", "w") {|f| f.puts total_js }
puts "packaged build/git.min.js"
end

desc "Run the demo repo-viewer webapp off a local git http instance"
task :demo => :package_client do
exec("thin -R demos/config.ru -p 9292 start")
end
end
4 changes: 2 additions & 2 deletions bin/git.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node

require('../lib/git-server')
var Cli = require('../lib/git/cli')

// Get rid of process runner ('node' in most cases)
var arg, args = [], argv = process.argv.slice(2);

var cli = new Git.Cli(argv)
var cli = new Cli(argv)
cli.run()

4 changes: 2 additions & 2 deletions demos/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ServeGitJs

def call(env)
if env["PATH_INFO"] == "/git.min.js"
path = File.expand_path(File.dirname(__FILE__) + "/../lib/git.min.js")
path = File.expand_path(File.dirname(__FILE__) + "/../build/git.min.js")
if File.exist?(path)
content = File.read(path)
status = 200
Expand Down Expand Up @@ -51,4 +51,4 @@ puts
puts " * visit #{bold}http://localhost:9292/repo-viewer/index.html#{nobold}"
puts " * serving git repos from #{bold}#{serve_path}#{nobold}. "
puts " * Add more (bare) repos here to view them in repo-viewer. (SMALL repos work best) "
puts
puts
1 change: 0 additions & 1 deletion demos/repo-viewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="/git.min.js"></script>
<script src="repo-viewer.js"></script>
<script src="/vendor/diff.js"></script>
<script src="/vendor/syntaxhighlighter_3.0.83/scripts/shCore.js"></script>
<script src="/vendor/syntaxhighlighter_3.0.83/scripts/shBrushRuby.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
Expand Down
13 changes: 9 additions & 4 deletions demos/repo-viewer/repo-viewer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
var MemoryRepo = Git.require('lib/git/memory_repo')
, GithubProxyRepo = Git.require('lib/git/github_repo')
, TreeDiff = Git.require('lib/git/tree-diff')
, _ = Git.require('underscore')
, MyMD5 = Git.require('vendor/md5')

RepoViewer = {
repo: null,
Expand Down Expand Up @@ -72,7 +77,7 @@ RepoViewer = {
displayCommitDiffDiff: function(commit) {
RepoViewer.repo.getObject(commit.parents[0], function(err, parent) {
var parentTree = parent ? parent.tree : null
var treeDiff = new Git.TreeDiff(RepoViewer.repo, parentTree, commit.tree)
var treeDiff = new TreeDiff(RepoViewer.repo, parentTree, commit.tree)
treeDiff.toHtml(function(html) {
$("#diff").append(html)
})
Expand Down Expand Up @@ -212,7 +217,7 @@ RepoViewer = {
},

githubDemo: function(username, reponame, password) {
RepoViewer.repo = new Git.GithubProxyRepo(username, reponame, password)
RepoViewer.repo = new GithubProxyRepo(username, reponame, password)
var origin = RepoViewer.repo.getRemote("origin")
origin.fetchRefs(function() {
RepoViewer.displayRefs(RepoViewer.repo.getAllRefs())
Expand All @@ -229,7 +234,7 @@ RepoViewer = {
RepoViewer.clearRefs()
RepoViewer.clearCommits()
RepoViewer.clearErrors()
var repo = new Git.MemoryRepo()
var repo = new MemoryRepo()
RepoViewer.repo = repo
console.log("creating repo with origin: " + uri)
// if (uri.indexOf("//github.com")) {
Expand All @@ -242,4 +247,4 @@ RepoViewer = {
})

}
}
}
Loading