class Crit::Models::Repository

Overview

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

Defined in:

models/repository.cr

Constant Summary

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

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(name : String) #

Initializes a new repository instance

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


[View source]

Class Method Detail

def self.ensure_repo_dir #

Ensures the repository directory exists

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


[View source]
def self.list #

Lists all repositories

@return [Array] Array of repository names


[View source]

Instance Method Detail

def 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


[View source]
def exists? #

Checks if the repository exists

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


[View source]
def name : String #

Repository name


[View source]
def path #

Returns the full path to the repository

@return [String] The full path to the repository


[View source]