Permalink
Browse files

added debugging

  • Loading branch information...
1 parent 5cbee44 commit 3065fc3d567903dff0bf051b14e77cba835a93c0 @runemadsen committed Mar 27, 2012
Showing with 23 additions and 3 deletions.
  1. +6 −2 config.ru
  2. +4 −0 lib/git-api/helpers.rb
  3. +13 −1 test/main_test.rb
View
@@ -1,6 +1,10 @@
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
require 'git-api.rb'
-GitApi::App.set :git_path => "/tmp/testrepos"
+# Setup git api
+# --------------------------------------------------------
-run GitApi::App
+GitApi::App.set :git_path => "/tmp/testrepos"
+map '/gitapi' do
+ run GitApi::App
+end
View
@@ -26,10 +26,14 @@ def get_object_from_tree(repo, tree, name)
def make_file(repo, branch, name, data, encoding, user, email, message, from_branch = nil)
repo = get_repo(File.join(settings.git_path, repo))
+ puts "Repo: #{repo.inspect}"
index = Grit::Index.new(repo)
+ puts "Index: #{index.inspect}"
+ puts "Using branch: #{from_branch || branch}"
index.read_tree(from_branch || branch)
index.add(name, data)
sha = index.commit(message, repo.commit_count > 0 ? [repo.commit(from_branch || branch)] : nil, Grit::Actor.new(user, email), nil, branch)
+ puts "Sha is #{sha}"
end
def enable_hooks(repo, hooks)
View
@@ -116,9 +116,10 @@ def test_create_file
def test_update_file
post '/repos', {:name => GIT_REPO}
post "/repos/#{GIT_REPO}.git/branches/master/files", {:name => "myfile.txt", :data => "Hello There", :encoding => "utf-8", :user => "Rune Madsen", :email => "rune@runemadsen.com", :message => "My First Commit"}
+ post "/repos/#{GIT_REPO}.git/branches/master/files", {:name => "myfile.txt", :data => "Hello There Again", :encoding => "utf-8", :user => "Rune Madsen", :email => "rune@runemadsen.com", :message => "My First Commit"}
blob = Grit::Repo.new(path).tree("master")/"myfile.txt"
assert last_response.ok?
- assert_equal(blob.data, "Hello There")
+ assert_equal(blob.data, "Hello There Again")
assert last_response.body.include?("sha")
FileUtils.rm_rf path
end
@@ -318,4 +319,15 @@ def test_get_blame
FileUtils.rm_rf path
end
+ # Test git repo valid
+ # ------------------------------------------------------------------
+
+ def test_repo_valid
+ post '/repos', {:name => GIT_REPO}
+ post "/repos/#{GIT_REPO}.git/branches/master/files", {:name => "myfile.txt", :data => "Hello There", :encoding => "utf-8", :user => "Rune Madsen", :email => "rune@runemadsen.com", :message => "My First Commit"}
+ post "/repos/#{GIT_REPO}.git/branches/master/files", {:name => "myfile.txt", :data => "Hello There Again", :encoding => "utf-8", :user => "Rune Madsen", :email => "rune@runemadsen.com", :message => "My First Commit"}
+ puts `git clone #{path} /tmp/test`
+ FileUtils.rm_rf "/tmp/test"
+ end
+
end

0 comments on commit 3065fc3

Please sign in to comment.