#!/bin/sh REPO_FMT='ssh://git@git.pehjota.net/dotfiles/%s.git' if [ ${#} -eq 0 ]; then printf 'Usage: %s repository ...\n' "${0}" >&2 exit 1 fi if ! [ "x$(vcsh mr status --porcelain | wc -l)" = 'x0' ]; then printf 'Error: mr repository has uncommited changes\n' exit 1 fi for repo in "${@}"; do # Initialize repository vcsh init "${repo}" vcsh "${repo}" remote add origin "$(printf "${REPO_FMT}" "${repo}")" cat >"${HOME}/.gitignore.d/${repo}" <<-EOF # Exclude all files * # Include relevant files !/.gitignore.d/ !/.gitignore.d/${repo} # Exclude swap and backup files *.s[a-w]? *.vim *~ *.orig EOF # Add repository to mr.git cat >"${HOME}/.config/mr/available.d/${repo}.vcsh" <<-EOF [\$HOME/.config/vcsh/repo.d/${repo}.git] checkout = vcsh clone $(printf "${REPO_FMT}" "${repo}") ${repo} EOF vcsh mr add "${HOME}/.config/mr/available.d/${repo}.vcsh" vcsh mr commit -m "${repo}: New repository" # Enable repository in mr configuration ln -s "../available.d/${repo}.vcsh" \ "${HOME}/.config/mr/config.d/${repo}.vcsh" done