diff options
author | Jonas Smedegaard <dr@jones.dk> | 2013-05-10 20:46:04 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2013-05-10 20:46:04 +0200 |
commit | 27d338dec0428bc22e2838eb8641c6e0d1681e22 (patch) | |
tree | 18eeb76e189ce03838dd9b23194f1c707b1eabbb /mkgit |
Include mk* scripts
Diffstat (limited to 'mkgit')
-rwxr-xr-x | mkgit | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,43 @@ +#!/bin/sh + +# create local git, and create and push to remote git + +set -e + +login=debian@source.jones.dk +path="/srv/git/source.jones.dk/epfsug/diff" + +# resolve options +eval set -- "$(getopt -s sh -o f -- "$@")" +while true; do case "$1" in -f) force=-f; shift;; --) shift; break;; esac; done + +. /lib/lsb/init-functions + +# add suffix unless already included +gitpath="$(dirname "$path")/$(basename "$path" .git).git" + +log_action_begin_msg "Publish git" + +# initialize local git +log_action_cont_msg "init" +if [ -d .git ]; then + if [ -n "$force" ]; then + log_warning_msg "purging" + rm -rf .git + else + log_failure_msg "local git already exist (force with -f)" + exit 1 + fi +fi +git init + +# add scripts +log_action_cont_msg "add" +git add mk*; git commit -m "Include mk* scripts" + +# create and populate remote git +log_action_cont_msg "push" +ssh "$login" git init --bare "$gitpath" \&\& cd "$gitpath" \&\& mv hooks/post-update{.sample,} \&\& touch git-daemon-export-ok +git push $force --all -u "$login:$gitpath" || { log_failure_msg "remote git already exist (force with -f)"; exit 1; } + +log_action_end_msg $? |