Sha256: fa9f18bbb45c0f3f57ec7b9c4fcbac88ec7a5fd70ef840250f6172a3ade9c4e6
Contents?: true
Size: 859 Bytes
Versions: 4
Compression:
Stored size: 859 Bytes
Contents
require "pathname" module GitCommands class Repository LOCKING_FILES = %w(rebase-merge rebase-apply) class InvalidError < StandardError; end def initialize(path) @path = Pathname::new(path.to_s) fail InvalidError, "'#{path}' is not a valid GIT repository!" unless valid? end def to_path @path.to_s end def locked? LOCKING_FILES.any? do |name| File.exists?(@path.join(".git", name)) end end def unlock Dir.chdir(@path) do `git rebase --abort` end end private def valid? return false unless exists? work_tree? end private def exists? File.directory?(@path) end private def work_tree? Dir.chdir(@path) do `git rev-parse --is-inside-work-tree 2> /dev/null`.strip == "true" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems