add function to check for git config user
PATCH v2 1/1 add function to check for git config user
Changed since V1:
forgot to add Yocto bug #, also cleaned up commit message
Stephano Cetola (1):
sanity: add function to check for git config user
meta/classes/buildhistory.bbclass | 13 ++++--------- meta/classes/kernel-yocto.bbclass | 2 ++ meta/classes/sanity.bbclass | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-)
Signature · 1 line
2.10.0
PATCH v2 1/1 sanity: add function to check for git config user
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
--- meta/classes/buildhistory.bbclass | 13 ++++--------- meta/classes/kernel-yocto.bbclass | 2 ++ meta/classes/sanity.bbclass | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-)
meta/classes/buildhistory.bbclass +4 -9
@@ -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`
meta/classes/kernel-yocto.bbclass +2 -0
@@ -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
meta/classes/sanity.bbclass +15 -0
@@ -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 +}
Signature · 1 line
2.10.0
Re: [PATCH V2] sanity: add function to check for git config user
On 3 October 2016 at 01:43, Stephano Cetola <[email protected]
Quoted 7 lines
wrote:
meta/classes/sanity.bbclass +4
-0+# If the user hasn't set up their name/email, set some defaults +check_git_config() { + if [ -z "$1" ]; then + name="OE"
meta/classes/sanity.bbclass python check_sanity_eventhandler() { · line 1040
Quoted 10 lines
meta/classes/sanity.bbclass +10
-0+ 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 +}
Instead of embedding this into sanity.bbclass, could it just go into meta/lib/oe/ somewhere?
Ross
Re: [PATCH V2] sanity: add function to check for git config user
Quoted 22 lines · Ross
On 3 October 2016 at 01:43, Stephano Cetola <[email protected]
Quoted 7 lines
wrote:
meta/classes/sanity.bbclass +4
-0+# If the user hasn't set up their name/email, set some defaults +check_git_config() { + if [ -z "$1" ]; then + name="OE"meta/classes/sanity.bbclass python check_sanity_eventhandler() { · line 1040
Quoted 10 lines
meta/classes/sanity.bbclass +10
-0+ 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 +}Instead of embedding this into sanity.bbclass, could it just go into meta/lib/oe/ somewhere?
Quoted 1 line
Ross
Yeah, I saw /meta/lib/oe/patch when Paul mentioned it. It looks like things should be moving in this direction log-term anyhow. I could move this to patch.py for now, and then submit a bug to move functionality as well, if that's the direction we'd want to go.
Cheers,
Stephano
Re: [PATCH V2] sanity: add function to check for git config user
In reply to Stephano CetolaQuoted 93 lines · Stephano Cetola
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 revision0f698dfd1c8bbc0d53ae7977e26685a7a3df52a3Signed-off-by Stephano Cetola <[email protected]>---
meta/classes/buildhistory.bbclass | 13 ++++--------- meta/classes/kernel-yocto.bbclass | 2 ++ meta/classes/sanity.bbclass | 15 +++++++++++++++3 files changed, 21 insertions(+), 9 deletions(-)meta/classes/buildhistory.bbclass +0
-0@@ -688,6 +688,7 @@ ENDrm $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 commitmeta/classes/buildhistory.bbclass +0
-0@@ -708,15 +709,9 @@ ENDgit tag -f build-minus-2 build-minus-1 >
/dev/null2>&1 || true
git tag -f build-minus-1 >/dev/null2>&1 || true
fimeta/classes/buildhistory.bbclass +0
-1- # If the user hasn't set up their name/email, setsome defaults
meta/classes/buildhistory.bbclass +0
-1- # just for this repo (otherwise the commit will failwith older
meta/classes/buildhistory.bbclass +0
-3- # versions of git) - if ! git config user.email > /dev/null ; then - git config --local user.email"buildhistory@${DISTRO}"
meta/classes/buildhistory.bbclass +3
-4- 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 unknownmeta/classes/kernel- renamed from meta/classes/kernel-yocto.bbclass +0
-0yocto.bbclass
index 53659f2..035edeb 100644meta/classes/kernel-yocto.bbclass +0
-0@@ -156,9 +156,11 @@ do_kernel_metadata() {fi
}
+inherit sanity
do_patch() {
cd ${S}meta/classes/kernel-yocto.bbclass +1
-0+ check_git_config "kernel-yocto"meta_dir=$(kgit --meta)
(cd ${meta_dir}; ln -sf patch.queue series) if [ -f "${meta_dir}/series" ]; thenmeta/classes/sanity.bbclass +0
-0@@ -1023,3 +1023,18 @@ python check_sanity_eventhandler() {
return
}meta/classes/sanity.bbclass +5
-0+ +# If the user hasn't set up their name/email, set some defaults +check_git_config() { + if [ -z "$1" ]; then + name="OE"
meta/classes/sanity.bbclass python check_sanity_eventhandler() { · line 1040
Quoted 10 lines
meta/classes/sanity.bbclass +10
-0+ 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 +}
I worry you're causing a load of the classes to end up cross linked here which is bad from a usability standpoint. Nobody can easily disable the sanity checks after this patch.
If we're keeping this as a shell function this function would probably go to utils.bbclass. Adding something to lib/oe is probably ultimately the way to go but I appreciate its harder to write the above in a python lib, so perhaps utils.bbclass is good enough for now? We can assume utils is inherited globally.
Cheers,
Richard