Last active
December 11, 2015 15:28
-
-
Save peteryates/4620601 to your computer and use it in GitHub Desktop.
Colourise SVN blame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby-local-exec | |
| require 'colorize' | |
| def get_revision_number(line) | |
| line.split(" ").first.to_i | |
| end | |
| def revision_position(revisions, number) | |
| revisions[number] || revisions.last | |
| end | |
| lines = ARGF.readlines | |
| revisions = lines.map { |line| get_revision_number(line) }.sort.uniq | |
| lines.each do |line| | |
| revision = get_revision_number(line) | |
| colour = case revision | |
| when revision_position(revisions, -5)..revisions.last then 'light_green' | |
| when revision_position(revisions, -10)..revisions.last then 'green' | |
| when revision_position(revisions, -20)..revisions.last then 'light_yellow' | |
| when revision_position(revisions, -30)..revisions.last then 'yellow' | |
| when revision_position(revisions, -80)..revisions.last then 'light_red' | |
| when revision_position(revisions, -100)..revisions.last then 'red' | |
| else | |
| 'white' | |
| end | |
| print line.send(colour) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby-local-exec | |
| require 'colorize' | |
| def get_user(line) | |
| line.split(" ")[1] | |
| end | |
| def revision_position(revisions, number) | |
| revisions[number] || revisions.last | |
| end | |
| lines = ARGF.readlines | |
| users = lines.map { |line| get_user(line) }.uniq | |
| available_colours = [ | |
| :red, | |
| :green, | |
| :yellow, | |
| :blue, | |
| :magenta, | |
| :cyan, | |
| :white, | |
| :default, | |
| :light_black, | |
| :light_red, | |
| :light_blue, | |
| :light_magenta, | |
| :light_cyan, | |
| :light_green, | |
| :light_yellow, | |
| :light_white | |
| ] | |
| user_colours = Hash[*users.zip(available_colours).flatten] | |
| lines.each do |line| | |
| user = get_user(line) | |
| print line.send(user_colours[user]) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment