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 EEF601381F3 for ; Wed, 4 Sep 2013 12:50:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 80ED7E0FC9; Wed, 4 Sep 2013 12:50:50 +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 ED0D7E0FC9 for ; Wed, 4 Sep 2013 12:50:49 +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 D01D133EC1E for ; Wed, 4 Sep 2013 12:50:48 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 712A2E5465 for ; Wed, 4 Sep 2013 12:50:46 +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: <1378298886.8460261ad790e6a35f47bda6b3089c0bf886143e.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-commit-overlay.sh X-VCS-Directories: files/hooks/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 8460261ad790e6a35f47bda6b3089c0bf886143e X-VCS-Branch: master Date: Wed, 4 Sep 2013 12:50:46 +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: 79cbd8a3-85a6-4703-82c9-6a68d9e23f47 X-Archives-Hash: ed491782ac8307885ca2bcbb0a55d10c commit: 8460261ad790e6a35f47bda6b3089c0bf886143e Author: André Erdmann mailerd de> AuthorDate: Wed Sep 4 12:48:06 2013 +0000 Commit: André Erdmann mailerd 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