Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions lib/octocatalog-diff/catalog-util/git.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'rugged'
require 'git'

require_relative '../errors'
require_relative '../util/scriptrunner'
Expand Down Expand Up @@ -64,8 +64,8 @@ def self.branch_sha(options = {})
if dir.nil? || !File.directory?(dir)
raise Errno::ENOENT, "Git directory #{dir.inspect} does not exist"
end
repo = Rugged::Repository.new(dir)
repo.branches[branch].target_id
repo = ::Git.open(dir)
repo.branch(branch).gcommit.sha
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion octocatalog-diff.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ EOF
s.add_runtime_dependency 'httparty', '>= 0.21.0'
s.add_runtime_dependency 'hashdiff', '>= 0.3.0'
s.add_runtime_dependency 'parallel', '>= 1.12.0'
s.add_runtime_dependency 'rugged', '>= 0.25.0b2'
s.add_runtime_dependency 'git', '~> 4'
s.add_runtime_dependency 'puppet', '>= 5.5.0'
s.add_development_dependency 'puppet', '>= 5.5.0'
s.add_development_dependency 'rspec', '~> 3.4.0'
Expand Down
1 change: 0 additions & 1 deletion rake/doc.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'erb'
require 'optparse'
require 'rugged'

require_relative '../lib/octocatalog-diff/cli/options'
require_relative '../lib/octocatalog-diff/version'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
require OctocatalogDiff::Spec.require_path('/catalog-util/cached_master_directory')

require 'fileutils'
require 'git'
require 'json'
require 'open3'
require 'rugged'
require 'tmpdir'

describe OctocatalogDiff::CatalogUtil::CachedMasterDirectory do
Expand Down Expand Up @@ -66,9 +66,9 @@

it 'should have the expected SHA returned by rugged' do
pending 'repository checkout fixture missing' unless File.directory?(@default_options[:basedir])
repo = Rugged::Repository.new(@default_options[:basedir])
test_rugged_sha = repo.branches['master'].target_id
expect(test_rugged_sha).to eq(@master_sha)
repo = Git.open(@default_options[:basedir])
test_git_sha = repo.branch('master').gcommit.sha
expect(test_git_sha).to eq(@master_sha)
end
end

Expand Down
11 changes: 4 additions & 7 deletions spec/octocatalog-diff/tests/catalog-util/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@logger, @logger_str = OctocatalogDiff::Spec.setup_logger
allow(File).to receive(:'directory?').with('/tmp/foo').and_return(false)
allow(File).to receive(:'directory?').with('/tmp/bar').and_return(true)
allow(File).to receive(:'directory?').with('.').and_return(true)
end

describe '#check_out_git_archive' do
Expand Down Expand Up @@ -93,14 +94,10 @@
end

context 'with valid directory' do
it 'should return the sha from rugged' do
opts = { branch: 'foo', basedir: '/tmp/bar' }
expect(Rugged::Repository).to receive(:new).with('/tmp/bar')
.and_return(OpenStruct.new(branches: {
'foo' => OpenStruct.new(target_id: 'abcdef012345')
}))
it 'should return the sha' do
opts = { branch: 'master', basedir: '.' }
result = described_class.branch_sha(opts)
expect(result).to eq('abcdef012345')
expect(result).to match(/^[0-9a-f]+$/)
end
end
end
Expand Down