Module: RSpec::GitSpecifier

Defined in:
lib/rspec/git_specifier.rb,
lib/rspec/git_specifier/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#commitsObject



14
15
16
# File 'lib/rspec/git_specifier.rb', line 14

def commits
  walker.walk
end

#current_branchObject



30
31
32
# File 'lib/rspec/git_specifier.rb', line 30

def current_branch
  travis_branch || repository.branches.detect(&:head?)
end

#current_directoryObject



10
11
12
# File 'lib/rspec/git_specifier.rb', line 10

def current_directory
  Dir.pwd
end

#master_object_idObject



26
27
28
# File 'lib/rspec/git_specifier.rb', line 26

def master_object_id
  repository.ref('refs/remotes/origin/master').target_id
end

#repositoryObject



6
7
8
# File 'lib/rspec/git_specifier.rb', line 6

def repository
  Rugged::Repository.discover(current_directory)
end

#travis_branchObject



34
35
36
37
38
39
40
41
# File 'lib/rspec/git_specifier.rb', line 34

def travis_branch
  name = ENV['TRAVIS_BRANCH']
  return unless name

  repository.branches.detect do |branch|
    branch.name == name
  end
end

#walkerObject



18
19
20
21
22
23
24
# File 'lib/rspec/git_specifier.rb', line 18

def walker
  walker = Rugged::Walker.new(repository)
  walker.sorting(Rugged::SORT_DATE | Rugged::SORT_REVERSE)
  walker.push('HEAD')
  walker.hide(master_object_id)
  walker
end