Skip to content
Snippets Groups Projects
Commit 0cee2564 authored by Andrew Coward's avatar Andrew Coward
Browse files

Branch dev_2022_sette_updates. Add support for running SETTE on detached...

Branch dev_2022_sette_updates. Add support for running SETTE on detached HEADS. This occurs when older commits are checked out for testing. A detached HEAD is not associated with a branch but these changes will, at least, recover an appropriate date for the commit being tested rather than referring to the current origin.
parent c13d35b2
No related branches found
No related tags found
No related merge requests found
......@@ -171,7 +171,11 @@ clean_config() {
# define validation dir
set_valid_dir () {
REVISION_NB=`git -C ${MAIN_DIR} rev-list --abbrev-commit origin | head -1l`
if [ ${DETACHED_HEAD} == "no" ] ; then
REVISION_NB=`git -C ${MAIN_DIR} rev-list --abbrev-commit origin | head -1l`
else
REVISION_NB=${DETACHED_CMIT}
fi
REV_DATE0="`git -C ${MAIN_DIR} log -1 | grep Date | sed -e 's/.*Date: *//' -e's/ +.*$//'`"
REV_DATE=`${DATE_CONV}"${REV_DATE0}" +"%y%j"`
REVISION_NB=${REV_DATE}_${REVISION_NB}
......
......@@ -36,10 +36,25 @@ export USER_INPUT='yes' # Default: yes => request user input on decisions
# 3. regarding creation of directories
#
# Check that git branch is usable
export DETACHED_HEAD="no"
git branch --show-current >& /dev/null
if [[ $? == 0 ]] ; then
# subdirectory below NEMO_VALIDATION_DIR defaults to branchname
export SETTE_SUB_VAL="$(git branch --show-current)"
if [ -z $SETTE_SUB_VAL ] ; then
# Probabably on a detached HEAD (possibly testing an old commit).
# Verify this and try to recover original commit
MORE_INFO="$(git branch -a | head -1l | sed -e's/.*(//' -e 's/)//' )"
if [[ "${MORE_INFO}" == *"detached"* ]] ; then
export DETACHED_HEAD="yes"
export DETACHED_CMIT=$( echo \\${MORE_INFO} | awk '{print $NF}' )
# There is no robust way to recover a branch name in a detached state
# so just use the commit with a prefix
export SETTE_SUB_VAL="detached_"${DETACHED_CMIT}
else
export SETTE_SUB_VAL="Unknown"
fi
fi
export SETTE_THIS_BRANCH=${SETTE_SUB_VAL}
else
# subdirectory below NEMO_VALIDATION_DIR defaults to "MAIN"
......
......@@ -255,11 +255,31 @@ function runcmpres(){
#
if [ ${quiet} -eq 0 ] ; then echo "" ; fi
localchanges=`git status --short -uno | wc -l`
revision=`git rev-list --abbrev-commit origin | head -1l`
# Check that git branch is usable and use it to detect detached HEADs
git branch --show-current >& /dev/null
if [[ $? == 0 ]] ; then
branchname="$(git branch --show-current)"
if [ -z $branchname ] ; then
# Probabably on a detached HEAD (possibly testing an old commit).
# Verify this and try to recover original commit
MORE_INFO="$(git branch -a | head -1l | sed -e's/.*(//' -e 's/)//' )"
if [[ "${MORE_INFO}" == *"detached"* ]] ; then
revision=$( echo \\${MORE_INFO} | awk '{print $NF}' )
# There is no robust way to recover a branch name in a detached state
# so just use the commit with a prefix
branchname="detached_"${revision}
else
branchname="Unknown"
fi
else
revision=`git rev-list --abbrev-commit origin | head -1l`
fi
else
branchname="Unknown"
fi
rev_date0=`git log -1 | grep Date | sed -e 's/.*Date: *//' -e's/ +.*$//'`
rev_date=`${DATE_CONV}"${rev_date0}" +"%y%j"`
revision=${rev_date}_${revision}
branchname=`git branch --show-current`
if [[ $localchanges > 0 ]] ; then
if [ ${quiet} -eq 0 ] ; then echo "Current code is : $branchname @ $revision ( with local changes )" ; fi
lastchange=${revision}+
......
......@@ -567,11 +567,31 @@ function identictest(){
#
echo ""
localchanges=`git status --short -uno | wc -l`
revision=`git rev-list --abbrev-commit origin | head -1l`
# Check that git branch is usable and use it to detect detached HEADs
git branch --show-current >& /dev/null
if [[ $? == 0 ]] ; then
branchname="$(git branch --show-current)"
if [ -z $branchname ] ; then
# Probabably on a detached HEAD (possibly testing an old commit).
# Verify this and try to recover original commit
MORE_INFO="$(git branch -a | head -1l | sed -e's/.*(//' -e 's/)//' )"
if [[ "${MORE_INFO}" == *"detached"* ]] ; then
revision=$( echo \\${MORE_INFO} | awk '{print $NF}' )
# There is no robust way to recover a branch name in a detached state
# so just use the commit with a prefix
branchname="detached_"${revision}
else
branchname="Unknown"
fi
else
revision=`git rev-list --abbrev-commit origin | head -1l`
fi
else
branchname="Unknown"
fi
rev_date0=`git log -1 | grep Date | sed -e 's/.*Date: *//' -e's/ +.*$//'`
rev_date=`${DATE_CONV}"${rev_date0}" +"%y%j"`
revision=${rev_date}_${revision}
branchname=`git branch --show-current`
if [[ $localchanges > 0 ]] ; then
echo "Current code is : $branchname @ $revision ( with local changes )"
lastchange=${revision}+
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment