blob: 3502516e4930bd192d63e0d7df68f3f9c129434c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/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"
done
|