class

Crit::Services::RepoService

Inherits Reference < Object

Repository service class

Provides Git-specific operations for repositories such as listing files, getting file content, and listing branches. This service layer interacts with Git commands to perform operations on repositories.

Example

# List files in a repository
files = Crit::Services::RepoService.list_files("my-project", "master")

Constants

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

Class methods

get_file_content(repo_name : String, ref : String = "master", path : String = "")

Gets file content for a specific file in a repository

@param repo_name [String] The name of the repository @param ref [String] The Git reference (branch, tag, or commit) @param path [String] The path to the file within the repository @return [String] The content of the file @return [Nil] If the repository or file doesn't exist

Source
list_branches(repo_name : String)

Gets list of branches for a repository

@param repo_name [String] The name of the repository @return [Array<String>] Array of branch names @return [Array<String>] Empty array if the repository doesn't exist or has no branches

Source
list_files(repo_name : String, ref : String = "master", path : String = "")

Gets file listing for a repository at a specific path and reference

@param repo_name [String] The name of the repository @param ref [String] The Git reference (branch, tag, or commit) @param path [String] The path within the repository @return [Array<{type: String, mode: String, hash: String, name: String}>] Array of file entries @return [Nil] If the repository or path doesn't exist

Source