From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 0C3D91381F3 for ; Wed, 4 Sep 2013 13:14:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9ED7DE11CD; Wed, 4 Sep 2013 13:13:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2BC9CE11CD for ; Wed, 4 Sep 2013 13:13:59 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 33AC933E79A for ; Wed, 4 Sep 2013 13:13:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id E40E1E545E for ; Wed, 4 Sep 2013 13:13:56 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1378300410.e5b7893c8af1ab5873761e55d7e21b41ba0ff56c.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: files/hooks/ X-VCS-Repository: proj/R_overlay X-VCS-Files: files/hooks/git-push.sh X-VCS-Directories: files/hooks/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: e5b7893c8af1ab5873761e55d7e21b41ba0ff56c X-VCS-Branch: master Date: Wed, 4 Sep 2013 13:13:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 086c0233-27ab-489b-a7da-c43634979d36 X-Archives-Hash: d4ff10bd6fdb4e203169bfb729dbd8de commit: e5b7893c8af1ab5873761e55d7e21b41ba0ff56c Author: André Erdmann mailerd de> AuthorDate: Wed Sep 4 13:13:30 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Wed Sep 4 13:13:30 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=e5b7893c files/hooks: git-push (experimental/todo) --- files/hooks/git-push.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/files/hooks/git-push.sh b/files/hooks/git-push.sh new file mode 100644 index 0000000..2dbb73e --- /dev/null +++ b/files/hooks/git-push.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# -*- coding: utf-8 -*- +# roverlay hook that pushes the git history to a remote +# +# It's expected that git-commit-overlay is run before this hook. +# +set -u + +## load core functions +. "${FUNCTIONS?}" || exit +#dont_run_as_root + +# using line_iterator() from itertools +$lf itertools + + +## functions + +# void git_push_to_remote ( +# remote, *refspec, **__GIT_PUSH_SUCCESS!, **GIT_PUSH_ARGS +# ) +# +# Runs "git push" for the given remote and sets __GIT_PUSH_SUCCESS to 'n' +# if errors occured. +# +git_push_to_remote() { + if run_command_logged echo ${GIT} push ${GIT_PUSH_ARGS-} "$@"; then + veinfo "successfully pushed changes to ${1}" + else + __GIT_PUSH_SUCCESS=n + eerror "could not push changes to ${1}" + fi + return 0 +} + +# int git_push_to_remotes ( **GIT_REMOTES, **GIT_DEFAULT_REMOTE ) +# +# Calls git_push_to_remote() for each remote in GIT_REMOTES. +# Returns EX_GIT_PUSH_ERR if pushing failed for at least one remote, +# else 0. +# +git_push_to_remotes() { + [ -n "${GIT_REMOTES-}" ] || \ + local GIT_REMOTES="${GIT_DEFAULT_REMOTE:-origin} master" + # or " :" + + local __GIT_PUSH_SUCCESS=y + + F_ITER=git_push_to_remote \ + F_ITER_ON_ERROR=return \ + ITER_SKIP_EMTY=y \ + ITER_UNPACK_ITEM=y \ + line_iterator "${GIT_REMOTES}" + + if [ "${__GIT_PUSH_SUCCESS}" = "y" ]; then + return 0 + else + return ${EX_GIT_PUSH_ERR} + fi +} + + +## main + +if yesno "${NOSYNC?}"; then + einfo "sync is disabled - not pushing anything." +else + git_push_to_remotes +fi