lib/fulmar/infrastructure/service/git_service.rb in fulmar-1.0.0 vs lib/fulmar/infrastructure/service/git_service.rb in fulmar-1.1.0
- old
+ new
@@ -1,6 +1,6 @@
-require 'git'
+require 'rugged'
module Fulmar
module Infrastructure
module Service
# Provides access to to the local git repository
@@ -27,41 +27,38 @@
else
'master'
end
end
- @git = Git.open(@config[:local_path]) # :log => Logger.new(STDOUT)
+ @git = Rugged::Repository.new(@config[:local_path]) # :log => Logger.new(STDOUT)
end
def branches
- @git.branches
+ @git.branches.collect(:name)
end
def feature_branches
- @git.branches.collect { |b| b.full }.select { |name| name.match(/^feature_/) }.sort
+ branches.select { |name| name.match(/^feature_/) }.sort
end
def preview_branches
- @git.branches.collect { |b| b.full }.select { |name| name.match(/^preview_/) }.sort
+ branches.select { |name| name.match(/^preview_/) }.sort
end
def checkout(branch_name = derive_branch_name)
- branches = @git.branches.local.find(branch_name)
- if branches.any?
+ if branches.include?(branch_name)
@git.checkout(branches.first)
else
- branches = @git.branches.remote.find(branch_name)
+ branches = @git.branches.select { |b| b.name.match(/\/#{branch_name}$/) }
fail "Cannot find a valid branch, last search was for #{branch_name}" unless branches.any?
- @git.branch(branches.first)
@git.checkout(branches.first)
end
end
# The current preview branch is the alphabetically last preview branch
def derive_branch_name
@config[:git][:branch] == 'preview' ? preview_branches.last : @config[:git][:branch]
end
-
end
end
end
end