diff options
-rw-r--r-- | .gitignore.d/mr | 3 | ||||
-rwxr-xr-x | bin/dfen | 24 | ||||
-rwxr-xr-x | bin/dfmk | 27 |
3 files changed, 54 insertions, 0 deletions
diff --git a/.gitignore.d/mr b/.gitignore.d/mr index 7813e73..e9d2752 100644 --- a/.gitignore.d/mr +++ b/.gitignore.d/mr @@ -9,6 +9,9 @@ !/.config/mr/config.d/ !/.config/mr/config.d/mr.vcsh !/.mrconfig +!/bin/ +!/bin/dfmk +!/bin/dfen !/.gitignore.d/ !/.gitignore.d/mr diff --git a/bin/dfen b/bin/dfen new file mode 100755 index 0000000..3cf4aef --- /dev/null +++ b/bin/dfen @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ ${#} -eq 0 ]; then + printf 'Usage: %s repository ...\n' "${0}" >&2 + exit 1 +fi + +for repo in "${@}"; do + if ! [ -f "${HOME}/.config/mr/available.d/${repo}.vcsh" ]; then + printf 'Error: %s: No such repository\n' "${repo}" >&2 + continue + fi + if [ -f "${HOME}/.config/mr/config.d/${repo}.vcsh" ]; then + printf 'Warning: %s: Already enabled\n' "${repo}" >&2 + continue + fi + + # Enable repository in mr configuration + ln -s "../available.d/${repo}.vcsh" \ + "${HOME}/.config/mr/config.d/${repo}.vcsh" + + # Clone repository + mr checkout +done 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 |