From f4bb2414d788bec6cdeba75d28b31120636cd37a Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Tue, 9 Nov 2010 19:25:53 +0100 Subject: Improved buildinfo, adding some kind of git tree state information This patch adds a list over uncommitted files. Signed-off-by: David Sommerseth --- eurephiadm/commands/buildinfo.c | 7 ++++++- eurephiadm/mk_buildinfo.sh | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/eurephiadm/commands/buildinfo.c b/eurephiadm/commands/buildinfo.c index 57ca9b6..aa518a4 100644 --- a/eurephiadm/commands/buildinfo.c +++ b/eurephiadm/commands/buildinfo.c @@ -81,7 +81,12 @@ int cmd_BuildInfo(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, " System info: " BUILDSYSTEM "\n"); #ifdef BUILDBRANCH printf(" git branch: " BUILDBRANCH "\n" - " git commit: " BUILDGITREV "\n\n"); + " git commit: " BUILDGITREV "\n"); + if( GITSTATE != 0 ) { + printf(" Uncommitted changes to the git tree:\n" + MODIFIEDFILES); + } #endif + printf("\n"); return 0; } diff --git a/eurephiadm/mk_buildinfo.sh b/eurephiadm/mk_buildinfo.sh index 2f45bbe..64d9d86 100755 --- a/eurephiadm/mk_buildinfo.sh +++ b/eurephiadm/mk_buildinfo.sh @@ -24,11 +24,16 @@ builddate="`date -u`" buildsystem="`uname -a`" buildhost="`hostname`" -if [[ -d ../.git ]]; then + +# Check if we're in a git tree +git rev-parse --git-dir 2> /dev/null 1> /dev/null +if [[ $? = 0 ]]; then # If we have a .git directory, presume the source is from a git tree - branch=`awk '{print $2}' ../.git/HEAD` + branch=`git symbolic-ref HEAD` gitrev=`git rev-list ${branch} -1` buildsource="`git remote -v | awk '/^origin/{print $2; exit 0}'`" + modfiles="`git status -s | awk '/^[ADM\?]/{ printf " %s\\\n", $0 }'`" + [[ -z ${modfiles} ]] && state=0 || state=1 else # Otherwise, it's from a source tarball buildsource="tar.bz2" @@ -47,5 +52,7 @@ if [[ -n "${gitrev}" ]]; then cat <> buildinfo.h #define BUILDBRANCH "${branch}" #define BUILDGITREV "${gitrev}" +#define GITSTATE "${state}" +#define MODIFIEDFILES "${modfiles}" EOF fi -- cgit