Skip to content

Instantly share code, notes, and snippets.

@davidpdrsn
Created October 30, 2017 14:09
Show Gist options
  • Select an option

  • Save davidpdrsn/c1caa66131105b3f86b3d790b328b5b4 to your computer and use it in GitHub Desktop.

Select an option

Save davidpdrsn/c1caa66131105b3f86b3d790b328b5b4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "active_support/core_ext/date"
require "pp"
def extract_date(line)
regex = /HEAD@{(?<date>[^}]+)}/
return unless line =~ regex
line.match(regex)[:date]
end
lines = `git reflog --date=iso`.lines.map(&:chomp)
lines_from_today = lines.select do |line|
date_string = extract_date(line)
next unless date_string
date = Date.parse(date_string)
date.today?
end
puts "# Todays commits\n\n"
puts lines_from_today.grep(/commit/)
.map { |line| line.split(": ").last }
.map { |line| "- #{line}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment