[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openembedded-core
Subject:    [OE-core] [PATCH 1/1] buildhistory: improve git commit robustness
From:       paul.eggleton () linux ! intel ! com (Paul Eggleton)
Date:       2011-12-30 13:36:11
Message-ID: aa7620cf200df388cc0ffcdf4ce8f04c652a0f89.1325252095.git.paul.eggleton () linux ! intel ! com
[Download RAW message or body]

* Check if BUILDHISTORY_DIR exists before doing anything with it, in
  case no tasks that would have created it have executed
* Ensure the git repo in BUILDHISTORY_DIR is initialised with "git init"
  before attempting to do anything with it
* Check if any files have been added or changed before adding and
  committing, to avoid an error from "git commit"

Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
 meta/classes/buildhistory.bbclass |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 39f5ff6..afd0fb5 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -339,11 +339,24 @@ def buildhistory_get_layers(d):
 
 
 buildhistory_commit() {
+	if [ ! -d ${BUILDHISTORY_DIR} ] ; then
+		# Code above that creates this dir never executed, so there can't be anything to \
commit +		exit
+	fi
+
 	( cd ${BUILDHISTORY_DIR}/
-		git add ${BUILDHISTORY_DIR}/*
-		git commit ${BUILDHISTORY_DIR}/ -m "Build ${BUILDNAME} for machine ${MACHINE} \
configured for ${DISTRO} ${DISTRO_VERSION}" --author "${BUILDHISTORY_COMMIT_AUTHOR}" \
>                 /dev/null
-		if [ "${BUILDHISTORY_PUSH_REPO}" != "" ] ; then
-			git push -q ${BUILDHISTORY_PUSH_REPO}
+		# Initialise the repo if necessary
+		if [ ! -d .git ] ; then
+			git init -q
+		fi
+		# Ensure there are new/changed files to commit
+		repostatus=`git status --porcelain`
+		if [ "$repostatus" != "" ] ; then
+			git add ${BUILDHISTORY_DIR}/*
+			git commit ${BUILDHISTORY_DIR}/ -m "Build ${BUILDNAME} for machine ${MACHINE} \
configured for ${DISTRO} ${DISTRO_VERSION}" --author "${BUILDHISTORY_COMMIT_AUTHOR}" \
> /dev/null +			if [ "${BUILDHISTORY_PUSH_REPO}" != "" ] ; then
+				git push -q ${BUILDHISTORY_PUSH_REPO}
+			fi
 		fi) || true
 }
 
-- 
1.7.5.4


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic