buildhistory: set commit user name and email for the new git repo

Submitted by Mikko Rapeli on May 20, 2015, 6:45 a.m. | Patch ID: 93911

Details

Message ID 1432104329-6352-1-git-send-email-mikko.rapeli@bmw.de
State New
Headers show

Commit Message

Mikko Rapeli May 20, 2015, 6:45 a.m.
git commit needs a user name and email even if --author is set. In most
cases users have ~/.gitconfig but in some cases the build user account
does not have these set which breaks the build.

Change-Id: Idd35df626332756ba5bd61d9273c76c7e63ed3f9
Signed-off-by: Mikko Rapeli <mikko.rapeli@bmw.de>
---
 meta/classes/buildhistory.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 211dcf1..dbd27b0 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -14,7 +14,9 @@  BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}
 BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}/${IMAGE_BASENAME}"
 BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group"
 BUILDHISTORY_COMMIT ?= "0"
-BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>"
+BUILDHISTORY_COMMIT_USER_NAME ?= "buildhistory"
+BUILDHISTORY_COMMIT_USER_EMAIL ?= "<buildhistory@${DISTRO}>"
+BUILDHISTORY_COMMIT_AUTHOR ?= "${BUILDHISTORY_COMMIT_USER_NAME} ${BUILDHISTORY_COMMIT_USER_EMAIL}"
 BUILDHISTORY_PUSH_REPO ?= ""
 
 SSTATEPOSTINSTFUNCS_append = " buildhistory_emit_pkghistory"
@@ -586,6 +588,11 @@  END
 		HOSTNAME=`hostname 2>/dev/null || echo unknown`
 		CMDLINE="${@buildhistory_get_cmdline(d)}"
 		if [ "$repostatus" != "" ] ; then
+			# git commit needs this setup, done every time before
+			# commit to support name and email changes via
+			# bitbake configuration
+			git config user.name "${BUILDHISTORY_COMMIT_USER_NAME}"
+			git config user.email "${BUILDHISTORY_COMMIT_USER_EMAIL}"
 			git add -A .
 			# porcelain output looks like "?? packages/foo/bar"
 			# Ensure we commit metadata-revs with the first commit

Comments

Mikko Rapeli May 26, 2015, 2:58 p.m.
Already fixed by merged commit:

http://git.openembedded.org/openembedded-core/commit/?id=f62255bfa6c5a322c867b7c4ea5686ea7bfab3fe

-Mikko
Paul Eggleton May 26, 2015, 5:39 p.m.
Hi Mikko,

On Tuesday 26 May 2015 14:58:02 Mikko.Rapeli@bmw.de wrote:
> Already fixed by merged commit:
> 
> http://git.openembedded.org/openembedded-core/commit/?id=f62255bfa6c5a322c86
> 7b7c4ea5686ea7bfab3fe
> 
> -Mikko

My apologies for basically duplicating your patch - by coincidence I was 
talking to our QA team about resolving what turned out to be the same issue at 
around the same time.

Cheers,
Paul
Mikko Rapeli May 27, 2015, 6:52 a.m.
On Tue, May 26, 2015 at 06:39:18PM +0100, Paul Eggleton wrote:
> Hi Mikko,
> 
> On Tuesday 26 May 2015 14:58:02 Mikko.Rapeli@bmw.de wrote:
> > Already fixed by merged commit:
> > 
> > http://git.openembedded.org/openembedded-core/commit/?id=f62255bfa6c5a322c86
> > 7b7c4ea5686ea7bfab3fe
> > 
> > -Mikko
> 
> My apologies for basically duplicating your patch - by coincidence I was 
> talking to our QA team about resolving what turned out to be the same issue at 
> around the same time.

No problem. In my patch I set the git user.name and user.email every time
to allow changing settings in local.conf without rebuilding from scratch
but if that really becomes a problem then I'll send a new patch.

-Mikko