Remove git churn command

I added this four years ago but haven't been using it.
Not common enough to be included in company-wide dotfiles?
Can move to personal dotfiles if desired.
This commit is contained in:
Dan Croak 2017-04-25 22:19:45 -07:00
parent 09d54d448c
commit 8fbef47fda
2 changed files with 0 additions and 63 deletions

View file

@ -203,7 +203,6 @@ Shell aliases and scripts:
* `b` for `bundle`.
* `g` with no arguments is `git status` and with arguments acts like `git`.
* `git-churn` to show churn for the files changed in the branch.
* `migrate` for `rake db:migrate && rake db:rollback && rake db:migrate`.
* `mcd` to make a directory and change into it.
* `replace foo bar **/*.rb` to find and replace within a given list of files.

View file

@ -1,62 +0,0 @@
#!/usr/bin/ruby
#
# Put this on your $PATH (~/bin is recommended).
#
# Show churn for the files changed in the branch:
#
# $ git-churn
#
class GitChurn
attr_accessor :all_files_with_churn_count, :changed_files, :result
def calculate
get_all_files_with_churn_count
get_changed_files
filter_into_result
print_result
end
private
def get_all_files_with_churn_count
self.all_files_with_churn_count =
`git log --all #{format_logs} | #{remove_blank_lines} | #{sort_by_ascending_churn_count}`.split("\n")
end
def format_logs
"--name-only --format='format:'"
end
def remove_blank_lines
"grep -v '^$'"
end
def sort_by_ascending_churn_count
'sort | uniq -c | sort'
end
def get_changed_files
self.changed_files =
`git log origin/master..HEAD #{format_logs} | #{remove_blank_lines} | #{remove_duplicates}`.split("\n")
end
def remove_duplicates
'sort | uniq'
end
def filter_into_result
self.result = all_files_with_churn_count.select { |file| file_changed?(file) }.join("\n")
end
def file_changed?(file)
changed_files.any? { |changed_file| file.include?(changed_file) }
end
def print_result
puts result
end
end
git_churn = GitChurn.new
git_churn.calculate