Module: Relaxo
- Extended by:
- Console
- Defined in:
- lib/relaxo/version.rb,
lib/relaxo.rb,
lib/relaxo/logger.rb,
lib/relaxo/dataset.rb,
lib/relaxo/database.rb,
lib/relaxo/changeset.rb,
lib/relaxo/directory.rb
Overview
Released under the MIT License. Copyright, 2012-2025, by Samuel Williams.
Defined Under Namespace
Classes: Changeset, Database, Dataset, Directory
Constant Summary collapse
- DEFAULT_BRANCH =
"main".freeze
- VERSION =
"1.8.0"- HEAD =
"HEAD".freeze
Class Method Summary collapse
Class Method Details
.connect(path, branch: nil, sync: nil, create: true, **metadata) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/relaxo.rb', line 14 def self.connect(path, branch: nil, sync: nil, create: true, **) if !File.exist?(path) || create repository = Rugged::Repository.init_at(path, true) if branch repository.head = "refs/heads/#{branch}" end if sync || ENV["RELAXO_SYNC"] repository.config["core.fsyncObjectFiles"] = true end else repository = Rugged::Repository.new(path) end # Automatically detect the current branch if `branch` is not provided: branch ||= self.default_branch(repository) database = Database.new(path, branch, ) if config = database.config unless config["user.name"] login = Etc.getpwuid hostname = Socket.gethostname if login config["user.name"] = login.name config["user.email"] = "#{login.name}@#{hostname}" end end end return database end |