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 12:50:46 +0000 (UTC)	[thread overview]
Message-ID: <1378298886.8460261ad790e6a35f47bda6b3089c0bf886143e.dywi@gentoo> (raw)

commit:     8460261ad790e6a35f47bda6b3089c0bf886143e
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Sep  4 12:48:06 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Sep  4 12:48:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=8460261a

git-commit-overlay: reinit git repo, use config vars

* partially reconfigure the git repo (user name/email, ...)
* use GIT_COMMIT_MESSAGE, GIT_COMMIT_MAX_LINE_WIDTH from the hookrc config file
  (if defined there)

---
 files/hooks/git-commit-overlay.sh | 51 ++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/files/hooks/git-commit-overlay.sh b/files/hooks/git-commit-overlay.sh
index d8b936c..e9630d9 100644
--- a/files/hooks/git-commit-overlay.sh
+++ b/files/hooks/git-commit-overlay.sh
@@ -19,18 +19,6 @@ set -u
 $lf git
 #autodie qwhich ${GIT}
 
-## "config" for this script
-# FIXME/TODO: remove config here?
-##GIT_COMMIT_AUTHOR='undef undef undef@undef.org'
-GIT_COMMIT_MESSAGE='roverlay updates'
-
-GIT_COMMIT_MAX_LINE_WIDTH=79
-
-
-## other vars
-EX_ADD_ERR=2
-EX_COMMIT_ERR=3
-
 
 ## functions
 
@@ -47,7 +35,7 @@ git_try_rollback() {
    fi
 }
 
-# int git_commit()
+# int git_commit ( **GIT_COMMIT_MESSAGE, **GIT_COMMIT_MAX_LINE_WIDTH )
 #
 #  Adds changes and creates a commit.
 #
@@ -60,17 +48,18 @@ git_commit() {
    #  --all: add changed, new and deleted files
    if ! run_command_logged ${GIT} add --all; then
       git_try_rollback
-      return ${EX_ADD_ERR}
+      return ${EX_GIT_ADD_ERR}
    fi
 
    # create a commit message (file)
    {
-      echo "${GIT_COMMIT_MESSAGE}" && \
+      echo "${GIT_COMMIT_MESSAGE:-roverlay updates}" && \
       echo && \
       ${GIT} status \
          --porcelain --untracked-files=no --ignore-submodules | \
             sed -n -e 's,^[MADRC].[[:blank:]]\(.*\)\/..*[.]ebuild$,\1,p' | \
-               sort -u | xargs echo | fold -s -w ${GIT_COMMIT_MAX_LINE_WIDTH}
+               sort -u | xargs echo | \
+               fold -s -w ${GIT_COMMIT_MAX_LINE_WIDTH:-79}
    } > "${f}" || die
    COMMIT_MSG_FILE="${f}"
 
@@ -84,7 +73,26 @@ git_commit() {
       return 0
    else
       git_try_rollback
-      return ${EX_COMMIT_ERR}
+      return ${EX_GIT_COMMIT_ERR}
+   fi
+}
+
+# void git_reinit (
+#    **GIT_REPO_USER_NAME, **GIT_REPO_USER_EMAIL, **GIT_DEFAULT_REMOTE
+# ), raises die()
+#
+#  Configures the git repo.
+#
+git_reinit() {
+   # update git config
+   git_update_config "user.name" "${GIT_REPO_USER_NAME-}" "roverlay"
+   git_update_config \
+      "user.email" "${GIT_REPO_USER_EMAIL-}" "roverlay@undef.org"
+   git_update_config "push.default" "" "matching"
+
+   # add default remote
+   if [ -n "${GIT_DEFAULT_REMOTE-}" ] && ! git remote | grep -q .; then
+      autodie ${GIT} remote add origin "${GIT_DEFAULT_REMOTE}"
    fi
 }
 
@@ -104,12 +112,5 @@ elif ! git_has_changes; then
    return 0
 fi
 
-
-
+autodie git_reinit
 autodie git_commit
-
-##push changes to local repo?
-##
-##if ! yesno ${NOSYNC}; then
-##   #push changes to remote?
-##fi


             reply	other threads:[~2013-09-04 12:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04 12:50 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 13:13 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=1378298886.8460261ad790e6a35f47bda6b3089c0bf886143e.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