class

Crit::Models::Repository

Inherits Reference < Object

Repository model class

Provides basic operations for Git repositories such as creation, existence checking, and listing. This class is responsible for the basic management of repositories, while actual Git operations are handled by the service layer.

Example

repo = Crit::Models::Repository.new("my-project")
if !repo.exists?
  repo.create
end

Constants

MAX_NAME_LENGTH = 100

Maximum length for repository names

MIN_NAME_LENGTH = 1

Minimum length for repository names

RESERVED_NAMES = ["new", "admin", "settings", "login", "logout", "api"]

Reserved repository names

VALID_NAME_REGEX = /^[a-zA-Z0-9_\-\.]+$/

Regular expression for repository name validation

Constructors

new(name : String)

Initializes a new repository instance

@param name [String] The name of the repository @raise [ArgumentError] If the repository name is invalid

Source

Class methods

ensure_repo_dir

Ensures the repository directory exists

@return [Boolean] True if the directory exists or was created successfully

Source
list

Lists all repositories

@return [Array<String>] Array of repository names

Source

Instance methods

create

Creates a new bare Git repository

@return [Boolean] True if the repository was created successfully, false otherwise @return [Boolean] False if the repository already exists

Source
delete

Deletes a repository directory

@return [Boolean] True if deleted successfully, false otherwise

Source
exists?

Checks if the repository exists

@return [Boolean] True if the repository exists, false otherwise

Source
name

Repository name

Source
path

Returns the full path to the repository

@return [String] The full path to the repository

Source
rename_to(new_name : String)

Renames a repository

@param new_name [String] The new repository name @return [Boolean] True if renamed successfully, false otherwise @raise [ArgumentError] If the new repository name is invalid

Source