diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-05-05 12:47:46 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-05-05 12:47:46 -0400 |
commit | cdba3ca2afdf617fd856865d50a550cc6770e0d0 (patch) | |
tree | fcda4c953c6b4a577a3a82fb98b9c4747690ad63 |
Initial commit
-rw-r--r-- | COPYING | 14 | ||||
-rwxr-xr-x | git-mirror | 54 |
2 files changed, 68 insertions, 0 deletions
@@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/git-mirror b/git-mirror new file mode 100755 index 0000000..d09dfb6 --- /dev/null +++ b/git-mirror @@ -0,0 +1,54 @@ +#!/bin/bash +# Copyright © 2014 Luke Shumaker <lukeshu@sbcglobal.net> +# This work is free. You can redistribute it and/or modify it under the +# terms of the Do What The Fuck You Want To Public License, Version 2, +# as published by Sam Hocevar. See the COPYING file for more details. + +# Depends on the 'gitget' and 'libremessages' commands. On Parabola +# GNU/Linux-libre, those are the 'gitget' and 'librelib' packages, +# respectively. +# +# For other systems, the both live at: +# https://projects.parabolagnulinux.org/packages/libretools.git/ + +set -o pipefail +set -e +. libremessages + +config-get() { + [[ $# == 1 ]] || panic + git config --file "$conf_file" --get "$1" +} + +list-repos() { + [[ $# == 0 ]] || panic + git config --file "$conf_file" --list | cut -s -d. -f2 | sort -u +} + +mirror-repo() { + [[ $# == 1 ]] || panic + repo=$1 + canonical_path="$(config-get "repo.${repo}.canonical")" + local_path="$(config-get "repo.${repo}.local")" + description="$(config-get "repo.${repo}.description")" + [[ -n $description ]] || description="mirror of ${canonical_path}" + + gitget -f -n "$repo" bare "$canonical_path" "$local_path" + printf '%s\n' "$description" > "$local_path/description.tmp" + mv -- "$local_path/description.tmp" "$local_path/description" +} + +usage() { + print 'Usage %s CONFIG-FILE' "${0##*/}" +} + +main() { + if [[ $# != 1 ]]; then + usage + exit + fi + declare -g conf_file="$1" + while read -r repo; do mirror-repo "$repo"; done < <(list-repos) +} + +main "$@" |