Last active
June 18, 2017 09:30
-
-
Save masiuchi/dfd1cb9342412df3d1ee9c108bb7b887 to your computer and use it in GitHub Desktop.
Forbit pushing in off time.
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 | |
# -*- mode:ruby; coding:utf-8 -*- | |
require 'date' | |
require 'off_time_jp' # https://github.com/masiuchi/off_time_jp | |
if OffTimeJp.off_time? | |
puts 'Forbid pushing in off time' | |
exit false | |
end | |
branch = `git symbolic-ref --short HEAD`.chomp | |
author_dates = `git log origin/#{branch}..#{branch} --date=iso --pretty=format:"%ad"`.split("\n") | |
if $? | |
puts 'Probably, destination branch is not created or upstream info is not set' | |
exit false | |
end | |
author_dates.each do |date| | |
if OffTimeJp.off_time?(DateTime.parse(date)) | |
puts 'Forbid pushing commits whose author date is in off time' | |
exit false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment