class Fontist::Repo
Public Class Methods
Source
# File lib/fontist/repo.rb, line 147 def info(name) path = Pathname.new repo_path(name) unless path.exist? raise(Errors::RepoNotFoundError, "No such repo '#{name}'.") end Info.new(name, path) end
Source
# File lib/fontist/repo.rb, line 141 def list Dir.glob(Fontist.private_formulas_path.join("*")) .select { |path| File.directory?(path) } .map { |path| File.basename(path) } end
Source
# File lib/fontist/repo.rb, line 131 def remove(name) path = repo_path(name) unless Dir.exist?(path) raise(Errors::RepoNotFoundError, "No such repo '#{name}'.") end FileUtils.rm_r(path) rebuild_index_if_needed end
Source
# File lib/fontist/repo.rb, line 63 def setup(name, url) ensure_private_formulas_path_exists path = repo_path(name) # Check for duplicate URL across all repos existing_repo_with_url = find_repo_by_url(url) if existing_repo_with_url && existing_repo_with_url != name Fontist.ui.error(Paint["Repository URL already in use by '#{existing_repo_with_url}'", :red]) Fontist.ui.error(Paint["URL: #{url}", :yellow]) Fontist.ui.error(Paint["Cannot setup duplicate repository.", :red]) return false end if Dir.exist?(path) Fontist.ui.say(Paint["Repository '#{name}' already exists at #{path}", :yellow]) # Determine whether to proceed with overwrite: # - If auto_overwrite is explicitly set, use that value # - If interactive, prompt the user # - Otherwise (non-interactive without explicit setting), proceed automatically proceed = if !Fontist.auto_overwrite.nil? Fontist.auto_overwrite elsif Fontist.interactive? Fontist.ui.yes?(Paint["Do you want to overwrite it? [y/N]", :yellow, :bright]) else true end unless proceed Fontist.ui.say(Paint["Setup cancelled.", :red]) return false end Fontist.ui.say(Paint["Removing existing repository...", :yellow]) Fontist::Utils::FileOps.safe_rm_rf(path) end validate_and_fetch_repo(name, url) rebuild_index_if_needed true rescue StandardError => e # Catch all git-related errors if e.class.name.include?("Git") || e.message.match?(/git|clone|repository/i) handle_git_error(name, url, e, :setup) else raise end end
Source
# File lib/fontist/repo.rb, line 112 def update(name) path = repo_path(name) unless Dir.exist?(path) raise(Errors::RepoNotFoundError, "No such repo '#{name}'.") end git = Git.open(path) git.pull("origin", git.current_branch) rebuild_index_if_needed rescue StandardError => e # Catch all git-related errors if e.class.name.include?("Git") || e.message.match?(/git|pull|repository/i) handle_git_error(name, git.config["remote.origin.url"], e, :update) else raise end end