[ARVADOS] updated: d062a3ce560b4177d5254823df4461b7172449ee

git at public.curoverse.com git at public.curoverse.com
Wed Apr 15 15:46:32 EDT 2015


Summary of changes:
 services/api/app/models/commit.rb     | 11 +++++++++--
 services/api/test/unit/commit_test.rb |  4 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

       via  d062a3ce560b4177d5254823df4461b7172449ee (commit)
      from  85378b8c8d216f2aacaf0486896f57886f3e5349 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d062a3ce560b4177d5254823df4461b7172449ee
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Apr 15 15:45:59 2015 -0400

    3126: Fix test. Avoid excess "git init" by probing with "git branch" first.

diff --git a/services/api/app/models/commit.rb b/services/api/app/models/commit.rb
index 5d6e555..830854d 100644
--- a/services/api/app/models/commit.rb
+++ b/services/api/app/models/commit.rb
@@ -166,9 +166,16 @@ class Commit < ActiveRecord::Base
     unless /^[a-z]+:\/\// =~ git_url
       raise ArgumentError.new "invalid git url #{git_url}"
     end
-    FileUtils.mkdir_p gitdir
+    begin
+      must_git gitdir, "branch"
+    rescue GitError => e
+      raise unless /Not a git repository/ =~ e.to_s
+      # OK, this just means we need to create a blank cache repository
+      # before fetching.
+      FileUtils.mkdir_p gitdir
+      must_git gitdir, "init"
+    end
     must_git(gitdir,
-             "init",
              "fetch --no-progress --tags --prune --force --update-head-ok #{git_url.shellescape} 'refs/heads/*:refs/heads/*'")
   end
 
diff --git a/services/api/test/unit/commit_test.rb b/services/api/test/unit/commit_test.rb
index 1b82dcf..4f7aa0d 100644
--- a/services/api/test/unit/commit_test.rb
+++ b/services/api/test/unit/commit_test.rb
@@ -29,8 +29,8 @@ class CommitTest < ActiveSupport::TestCase
   ].each do |url|
     test "find_commit_range uses fetch_remote_repository to get #{url}" do
       fake_gitdir = repositories(:foo).server_path
-      Commit.expects(:fetch_remote_repository).
-        once.with(Commit.cache_dir_for(url), url).returns fake_gitdir
+      Commit.expects(:cache_dir_for).once.with(url).returns fake_gitdir
+      Commit.expects(:fetch_remote_repository).once.with(fake_gitdir, url).returns true
       c = Commit.find_commit_range url, nil, 'master', []
       refute_empty c
     end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list