Module: RspecProfiling::CurrentCommit

Extended by:
CurrentCommit
Included in:
CurrentCommit
Defined in:
lib/rspec_profiling/current_commit.rb

Instance Method Summary collapse

Instance Method Details

#git?Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/rspec_profiling/current_commit.rb', line 7

def git?
  `git rev-parse 2>&1`
  $?.success?
end

#shaObject



12
13
14
15
16
17
18
# File 'lib/rspec_profiling/current_commit.rb', line 12

def sha
  if git?
    `git rev-parse HEAD`
  else
    `svn info -r 'HEAD' | grep "Revision" | cut -f2 -d' '`
  end
end

#timeObject



20
21
22
23
24
25
26
# File 'lib/rspec_profiling/current_commit.rb', line 20

def time
  if git?
    Time.parse `git show -s --format=%ci #{sha}`
  else
    Time.parse `svn info -r 'HEAD' | grep "Last Changed Date" | cut -f4,5,6 -d' '`
  end
end