class Overcommit::Hook::PreCommit::ForbiddenBranches
Prevents commits to branches matching one of the configured patterns.
Public Instance Methods
Source
# File lib/overcommit/hook/pre_commit/forbidden_branches.rb, line 6 def run return :pass unless forbidden_commit? [:fail, "Committing to #{current_branch} is forbidden"] end
Private Instance Methods
Source
# File lib/overcommit/hook/pre_commit/forbidden_branches.rb, line 22 def current_branch @current_branch ||= Overcommit::GitRepo.current_branch end
Source
# File lib/overcommit/hook/pre_commit/forbidden_branches.rb, line 18 def forbidden_branch_patterns @forbidden_branch_patterns ||= Array(config['branch_patterns']) end
Source
# File lib/overcommit/hook/pre_commit/forbidden_branches.rb, line 14 def forbidden_commit? forbidden_branch_patterns.any? { |p| File.fnmatch(p, current_branch) } end