Sha256: afdc2095abf537616d3b56b033ea956204a259d2cd054d0f7f1511e388f43f33
Contents?: true
Size: 1.16 KB
Versions: 5
Compression:
Stored size: 1.16 KB
Contents
module Databasion class GitCommitter @@config = nil class GitCommitterError < StandardError; end def self.config=(config) @@config = config end def self.config @@config end def self.git_path @@config['git']['bin'] end def self.commit(path=Dir.pwd) raise GitCommitterError, "A file lock is in place. Cannot commit." if check_lock? create unless check_repo? create_lock Databasion::LOGGER.info 'running: git commit -am "databasion auto commit"' system git_path + ' commit -am "databasion auto commit"' remove_lock end def self.create Databasion::LOGGER.info 'creating new git repository' Databasion::LOGGER.info 'running: git init' system git_path + ' init' system git_path + ' add .' end def self.check_repo? File.exist?('.git') ? true : false end def self.check_lock? File.exist?('git.lock') ? true : false end def self.create_lock File.new('git.lock', 'w') unless check_lock? end def self.remove_lock FileUtils.rm 'git.lock' end end end
Version data entries
5 entries across 5 versions & 1 rubygems