feat(repo-sync): one local tree for every repo reachable on your forges
bin/repo-sync ports the Alphalink dotfiles repo/repo-reset zsh functions to bash + zsh on Linux and macOS, for several forges at once: GitLab, GitHub (+GHES), Gitea/Forgejo, Bitbucket Cloud, via curl + jq (no per-forge CLI). Tokens live in ~/.config/repos/forges.conf (0600, parsed line by line, never tracked), written by `repo-sync add`. Cache ~/.cache/repos/list refreshed at most once a day (mkdir lock: flock is not on macOS), same namespace/project on two forges kept once, archived and mirrors skipped. Layout ~/repos/<namespace with / as @>/<project>. rc files: `repo <project> [namespace]` clones on demand and cd's, with completion (bash compgen, zsh _describe), background refresh at shell start. install.sh: jq in the apt and brew lists, chmod repo-sync. Verified: shellcheck + bash -n, zsh -n; stub-curl harness over the four forges (pagination, dedup, auth headers, lock, stale cache, path/clone); live GitLab refresh (139 projects, 3s).
This commit is contained in:
@@ -63,6 +63,28 @@ alias cc='dtach_claude'
|
||||
# Rappeler a la demande le menu de reprise.
|
||||
alias d='source ~/.local/bin/dtach-router'
|
||||
|
||||
# repo-sync : un arbre local (~/repos) pour tous les depots des forges declarees
|
||||
# dans ~/.config/repos/forges.conf. `repo <projet> [namespace]` clone si besoin
|
||||
# puis s'y place ; la liste se rafraichit en arriere-plan, au plus 1 fois par jour.
|
||||
repo() {
|
||||
local dir
|
||||
dir="$(repo-sync path "$@")" && cd "$dir" || return
|
||||
}
|
||||
_repo() {
|
||||
local cache="${REPOS_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/repos/list}"
|
||||
local -a items
|
||||
[[ -f "$cache" ]] || return 0
|
||||
if (( CURRENT == 2 )); then
|
||||
items=(${(f)"$(cut -f1 "$cache" | sort -u)"})
|
||||
_describe 'project' items
|
||||
elif (( CURRENT == 3 )); then
|
||||
items=(${(f)"$(awk -F'\t' -v p="$words[2]" '$1 == p { print $2 }' "$cache")"})
|
||||
_describe 'namespace' items
|
||||
fi
|
||||
}
|
||||
compdef _repo repo
|
||||
[[ -o interactive ]] && command -v repo-sync >/dev/null && (repo-sync refresh --quiet >/dev/null 2>&1 &)
|
||||
|
||||
# Reglages propres a cette machine (non versionnes).
|
||||
[ -f "$HOME/.zshrc.local" ] && source "$HOME/.zshrc.local"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user