Sha256: 2e7a0ef6572a9107b50cc0b2a424053d9d38332c44dc761cd31055425282fa9c
Contents?: true
Size: 950 Bytes
Versions: 1
Compression:
Stored size: 950 Bytes
Contents
# vim:fileencoding=utf-8 require 'git/duet' require 'git/duet/command_methods' require 'git/duet/script_die_error' class Git::Duet::PreCommitCommand include Git::Duet::CommandMethods def initialize(quiet = false) @quiet = !!quiet end def execute! in_repo_root do explode! if !env_cache_exists? || env_cache_stale? end end private def explode! error('Your git duet settings are stale, human!') error('Update them with `git duet` or `git solo`.') raise Git::Duet::ScriptDieError.new(1) end def env_cache_exists? with_output_quieted do exec_check("git config #{Git::Duet::Config.namespace}.mtime") end true rescue false end def env_cache_stale? Integer(exec_check("git config #{Git::Duet::Config.namespace}.mtime")) < stale_cutoff end def stale_cutoff Integer( Time.now - Integer(ENV.fetch('GIT_DUET_SECONDS_AGO_STALE', '1200')) ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git-duet-0.2.0 | lib/git/duet/pre_commit_command.rb |