Module: Git::Modified
- Defined in:
- lib/git/modified.rb,
lib/git/modified/version.rb
Constant Summary collapse
- VERSION =
"0.3.1"
Class Method Summary collapse
- .latest_hash ⇒ Object
- .modified(hash = nil) ⇒ Object
- .run ⇒ Object
- .show_modified_files_on_commit(hash) ⇒ Object
- .show_modified_files_on_working_tree ⇒ Object
- .version ⇒ Object
Class Method Details
.latest_hash ⇒ Object
44 45 46 |
# File 'lib/git/modified.rb', line 44 def self.latest_hash `git log --pretty=format:'%h' -n 1` end |
.modified(hash = nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/git/modified.rb', line 18 def self.modified(hash = nil) if hash.nil? show_modified_files_on_working_tree else show_modified_files_on_commit hash end end |
.run ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/git/modified.rb', line 5 def self.run case ARGV.first when '-v', '--version' version else modified ARGV.first end end |
.show_modified_files_on_commit(hash) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/git/modified.rb', line 34 def self.show_modified_files_on_commit(hash) 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 |
.show_modified_files_on_working_tree ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/git/modified.rb', line 26 def self.show_modified_files_on_working_tree puts `git status --short` \ .each_line \ .reject { |line| line[0..1].split('').lazy.any? { |x| x == 'D' } } \ .reject { |line| line.match /\.(jpe?g|png|gif|svg|eot|mp3|ttf|wav|wof)$/i } \ .map { |line| if line[0] == 'R' then line.split(' ')[-1] else line[3..-1] end } end |