bitx_hq

ghq-compatible repo manager (extension module for mizchi/bit)

git
ghq
moon add mizchi/bitx_hq@0.46.4
Download zip
Author
Version
0.46.4
License
Apache-2.0
Last updated
4 days ago
Downloads
53
README

#
HqConfig

pub struct HqConfig {
root : String
ghq_compat : Bool
}

Configuration for hq command

#
HqConfig::new

fn HqConfig::new(root : String, ghq_compat? : Bool) -> HqConfig

#
HqGetOptions

pub struct HqGetOptions {
update : Bool
shallow : Bool
depth : Int
ssh : Bool
branch : String?
unshallow : Bool
}

Options for hq get command

#
HqGetOptions::default

fn HqGetOptions::default() -> HqGetOptions

#
HqGetOptions::new

fn HqGetOptions::new(update? : Bool, shallow? : Bool, depth? : Int, ssh? : Bool, branch? : String?, unshallow? : Bool) -> HqGetOptions

#
HqGetResult

pub(all) enum HqGetResult {
Cloned(String)
Updated(String)
Skipped(String)
Error(String)
} derive(Eq,
Debug
)

Result of hq get operation
impl Show for HqGetResult

#
RepoPath

pub struct RepoPath {
host : String?
user : String
repo : String
subdir : String?
} derive(Eq,
Debug
)

Repository path parsed from URL or shorthand
impl Show for RepoPath

#
RepoPath::clone_url

fn RepoPath::clone_url(self : RepoPath, ssh? : Bool) -> String

Get the clone URL (always includes host)

#
RepoPath::full_name

fn RepoPath::full_name(self : RepoPath) -> String

#
RepoPath::host_name

fn RepoPath::host_name(self : RepoPath) -> String

#
RepoPath::local_path

fn RepoPath::local_path(self : RepoPath, root : String) -> String

Get the local path under bhq root github.com is normalized (no host in path)

#
RepoPath::needs_sparse

fn RepoPath::needs_sparse(self : RepoPath) -> Bool

Check if this repo requires sparse checkout

#
RepoPath::new

fn RepoPath::new(user : String, repo : String, host? : String?, subdir? : String?) -> RepoPath

#
build_clone_command

fn build_clone_command(repo : RepoPath, local_path : String, options : HqGetOptions) -> String

Build the git clone command string (for display/logging)

#
contract_home

fn contract_home(path : String, home : String) -> String

Contract home directory back to ~

#
expand_home

fn expand_home(path : String) -> String

Expand ~ to home directory (uses placeholder, prefer expand_home_with)

#
expand_home_with

fn expand_home_with(path : String, home : String) -> String

Expand ~ to home directory using provided home path

#
hq_get

fn hq_get(repo : RepoPath, config : HqConfig, options : HqGetOptions, exec : (String) -> (Int, String, String), path_exists : (String) -> Bool) -> HqGetResult

Execute hq get command

Clone a repository to the bhq root directory. If subdir is specified, use sparse checkout.

#
hq_list

fn hq_list(config : HqConfig, query : String?, list_dir : (String) -> Array[(String, Bool)], is_git_repo : (String) -> Bool) -> Array[String]

List repositories under bhq root

#
hq_list_full_paths

fn hq_list_full_paths(config : HqConfig, query : String?, list_dir : (String) -> Array[(String, Bool)], is_git_repo : (String) -> Bool) -> Array[String]

List repositories with full paths

#
hq_root

fn hq_root(config : HqConfig) -> String

Get the primary bhq root directory

#
hq_roots

fn hq_roots(env_get : (String) -> String?, bit_config_get_all : (String) -> Array[String]) -> Array[String]

Get all configured roots (for ghq compatibility)

#
load_config

fn load_config(env_get : (String) -> String?, bit_config_get : (String) -> String?, ghq_compat? : Bool) -> HqConfig

Load hq configuration from environment and git config

Priority:
  1. BHQ_ROOT environment variable
  2. ghq.root from git config (if ghq_compat mode)
  3. ~/bhq (default)

#
parse_repo_path

fn parse_repo_path(rel_path : String) -> RepoPath?

Parse a repository path back to RepoPath

#
parse_repo_url

fn parse_repo_url(input : String) -> RepoPath?

Parse a repository URL or shorthand into RepoPath

Supported formats:
  • user/repo
  • user/repo/path/to/subdir (slash separator for subdir)
  • user/repo:path/to/subdir (colon separator for subdir)
  • github.com/user/repo
  • github.com/user/repo:path/to/subdir
  • gitlab.com/user/repo
  • https://github.com/user/repo
  • https://github.com/user/repo/tree/main/path/to/subdir
  • git@github.com:user/repo.git

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io