public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: files/hooks/
Date: Wed,  4 Sep 2013 13:13:56 +0000 (UTC)	[thread overview]
Message-ID: <1378300410.e5b7893c8af1ab5873761e55d7e21b41ba0ff56c.dywi@gentoo> (raw)

commit:     e5b7893c8af1ab5873761e55d7e21b41ba0ff56c
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Sep  4 13:13:30 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> 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 "<remote> :"
+
+   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


             reply	other threads:[~2013-09-04 13:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04 13:13 André Erdmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-04-01 16:38 [gentoo-commits] proj/R_overlay:master commit in: files/hooks/ André Erdmann
2014-01-25 18:14 André Erdmann
2013-09-23 15:30 André Erdmann
2013-09-06 11:10 André Erdmann
2013-09-06 11:10 André Erdmann
2013-09-06 10:22 André Erdmann
2013-09-06 10:22 André Erdmann
2013-09-06 10:22 André Erdmann
2013-09-04 12:50 André Erdmann
2013-09-04 10:16 André Erdmann
2013-08-02 10:34 André Erdmann
2013-06-22 15:24 André Erdmann
2013-06-22 15:24 André Erdmann
2013-06-21 18:41 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-06-22 15:24 ` [gentoo-commits] proj/R_overlay:master " André Erdmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378300410.e5b7893c8af1ab5873761e55d7e21b41ba0ff56c.dywi@gentoo \
    --to=dywi@mailerd.de \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox