Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Add submodules info for repository via grit
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
  • Loading branch information
dzaporozhets committed Feb 9, 2014
1 parent a26ba07 commit 340ba38
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
gitlab_git (5.1.0)
gitlab_git (5.2.0)
activesupport (~> 4.0.0)
charlock_holmes (~> 0.6.9)
gitlab-grit (~> 2.6.1)
Expand Down Expand Up @@ -33,7 +33,7 @@ GEM
escape_utils (0.2.4)
ffi (1.8.1)
formatador (0.2.4)
gitlab-grit (2.6.3)
gitlab-grit (2.6.4)
charlock_holmes (~> 0.6.9)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
Expand Down
18 changes: 18 additions & 0 deletions lib/gitlab_git/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,24 @@ def refs_hash
def lookup(oid)
rugged.lookup(oid)
end

# Return hash with submodules info for this repository
#
# Ex.
# {
# "rack" => {
# "id" => "c67be4624545b4263184c4a0e8f887efd0a66320",
# "path" => "rack",
# "url" => "git://github.com/chneukirchen/rack.git"
# },
# "encoding" => {
# "id" => ....
# }
# }
#
def submodules(ref)
Grit::Submodule.config(grit, ref)
end
end
end
end
22 changes: 22 additions & 0 deletions spec/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,26 @@
its(:data) { should include "bundle exec rake db:seed_fu RAILS_ENV=test" }
end
end

context :submodules do
let(:repository) { Gitlab::Git::Repository.new(TEST_SUB_REPO_PATH) }
let(:submodules) { repository.submodules('898ce92b0e0b5ade8a7ef7e3c779dda476b3eef8') }

it { submodules.should be_kind_of Hash }
it { submodules.empty?.should be_false }

describe :submodule do
let(:submodule) { submodules.first }

it 'should have valid data' do
submodule.should == [
"rack", {
"id"=>"c67be4624545b4263184c4a0e8f887efd0a66320",
"path"=>"rack",
"url"=>"git://github.com/chneukirchen/rack.git"
}
]
end
end
end
end

0 comments on commit 340ba38

Please sign in to comment.