-
-
Save oieioi/16ecb07dd27f69ab85fd to your computer and use it in GitHub Desktop.
Getting commit massage samples script powered by http://commit-m.minamijoyo.com/
This file contains 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 | |
require "net/http" | |
require "uri" | |
require "nokogiri" | |
params = { keyword: ARGV.join("\s") } | |
uri = URI.parse("http://commit-m.minamijoyo.com/commits/search") | |
uri.query = URI.encode_www_form(params) | |
response = Net::HTTP.get(uri) | |
html = Nokogiri::HTML.parse(response) | |
puts number_result = html.css(".container").inner_text[/[0-9]+ results/] | |
puts html.css("tbody > tr").map { |e| | |
message = e.css('td').first.inner_text.strip | |
meta = "#{e.css('td:nth-child(2)').inner_text}" | |
commit_url = "#{e.css('td:nth-child(3) a').first.attribute('href')}" | |
# 検索ワードに色付ける | |
params[:keyword]. | |
split("\s"). | |
each { |key| message.gsub!(/(#{key})/i, "\e[33m\\1\e[0m") } | |
"#{message} \e[36m(#{meta})\e[0m #{commit_url}" | |
}.join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment