summaryrefslogtreecommitdiffstats
path: root/bin/dfmk
diff options
context:
space:
mode:
Diffstat (limited to 'bin/dfmk')
-rwxr-xr-xbin/dfmk27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/dfmk b/bin/dfmk
new file mode 100755
index 0000000..4a87feb
--- /dev/null
+++ b/bin/dfmk
@@ -0,0 +1,27 @@
+#!/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
+
+for repo in "${@}"; do
+ if ! [ "x$(vcsh "${repo}" status --porcelain | wc -l)" = 'x0' ]; then
+ printf 'Error: Repository %s has uncommited changes\n' "${repo}"
+ continue
+ fi
+
+ # Initialize repository
+ vcsh init "${repo}"
+ vcsh "${repo}" remote add origin "$(printf "${REPO_FMT}" "${repo}")"
+
+ # 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"
+done