Module: Git::Changed

Defined in:
lib/git/changed.rb,
lib/git/changed/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.changed(hash = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/git/changed.rb', line 18

def self.changed(hash = nil)
  hash = latest_hash if hash.nil?
  hashes = `git show --summary --format="%P" #{hash} | head -n 1`.split ' '

  if hashes.size == 2
    puts `git diff --name-only #{hashes[0]}...#{hashes[1]}`
  else
    puts `git log -m -1 --name-only --pretty="format:" #{hash}`
  end
end

.latest_hashObject



29
30
31
# File 'lib/git/changed.rb', line 29

def self.latest_hash
  `git log --pretty=format:'%h' -n 1`
end

.runObject



5
6
7
8
9
10
11
12
# File 'lib/git/changed.rb', line 5

def self.run
  case ARGV.first
  when '-v', '--version'
    version
  else
    changed ARGV.first
  end
end

.versionObject



14
15
16
# File 'lib/git/changed.rb', line 14

def self.version
  puts Git::Changed::VERSION
end