Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Stephano Cetola <stephano.cetola@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH V2] sanity: add function to check for git config user
Date: Sun,  2 Oct 2016 17:43:07 -0700	[thread overview]
Message-ID: <20161003004307.824-2-stephano.cetola@linux.intel.com> (raw)
In-Reply-To: <20161003004307.824-1-stephano.cetola@linux.intel.com>

If attempting to patch a git repo without a proper git config setup,
an error will occur saying user.name/user.email are needed by git
am/apply. After some code was removed from kernel-yocto, it was
simple enough to reproduce this error by creating a kernel patch and
using a container to build.

This patch abstracts out functionality that existed in buildhistory
for use in other classes. It also adds a call to this functionality
to the kernel-yocto class.

Fixes [YOCTO #10346]

introduced in
OE-core revision 0f698dfd1c8bbc0d53ae7977e26685a7a3df52a3

Signed-off-by: Stephano Cetola <stephano.cetola@linux.intel.com>
---
 meta/classes/buildhistory.bbclass | 13 ++++---------
 meta/classes/kernel-yocto.bbclass |  2 ++
 meta/classes/sanity.bbclass       | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 6e5de0e..ed79029 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -688,6 +688,7 @@ END
 	rm $commitmsgfile
 }
 
+inherit sanity
 buildhistory_commit() {
 	if [ ! -d ${BUILDHISTORY_DIR} ] ; then
 		# Code above that creates this dir never executed, so there can't be anything to commit
@@ -708,15 +709,9 @@ END
 			git tag -f build-minus-2 build-minus-1 > /dev/null 2>&1 || true
 			git tag -f build-minus-1 > /dev/null 2>&1 || true
 		fi
-		# If the user hasn't set up their name/email, set some defaults
-		# just for this repo (otherwise the commit will fail with older
-		# versions of git)
-		if ! git config user.email > /dev/null ; then
-			git config --local user.email "buildhistory@${DISTRO}"
-		fi
-		if ! git config user.name > /dev/null ; then
-			git config --local user.name "buildhistory"
-		fi
+
+		check_git_config "buildhistory"
+
 		# Check if there are new/changed files to commit (other than metadata-revs)
 		repostatus=`git status --porcelain | grep -v " metadata-revs$"`
 		HOSTNAME=`hostname 2>/dev/null || echo unknown`
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
index 53659f2..035edeb 100644
--- a/meta/classes/kernel-yocto.bbclass
+++ b/meta/classes/kernel-yocto.bbclass
@@ -156,9 +156,11 @@ do_kernel_metadata() {
 	fi
 }
 
+inherit sanity
 do_patch() {
 	cd ${S}
 
+	check_git_config "kernel-yocto"
 	meta_dir=$(kgit --meta)
 	(cd ${meta_dir}; ln -sf patch.queue series)
 	if [ -f "${meta_dir}/series" ]; then
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 7682ffb..40033ab 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -1023,3 +1023,18 @@ python check_sanity_eventhandler() {
 
     return
 }
+
+# If the user hasn't set up their name/email, set some defaults
+check_git_config() {
+	if [ -z "$1" ]; then
+		name="OE"
+	else
+		name="$1"
+	fi
+	if ! git config user.email > /dev/null ; then
+        	git config --local user.email "${name}@${DISTRO}"
+	fi
+	if ! git config user.name > /dev/null ; then
+        	git config --local user.name "${name}"
+	fi
+}
-- 
2.10.0



  reply	other threads:[~2016-10-03  0:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-03  0:43 [PATCH V2] add function to check for git config user Stephano Cetola
2016-10-03  0:43 ` Stephano Cetola [this message]
2016-10-03 15:31   ` [PATCH V2] sanity: " Burton, Ross
2016-10-03 16:09     ` Stephano Cetola
2016-10-03 22:21   ` Richard Purdie

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=20161003004307.824-2-stephano.cetola@linux.intel.com \
    --to=stephano.cetola@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.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