diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2017-10-27 17:38:16 +0100 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2017-10-27 17:38:16 +0100 |
commit | 5a6df11805484393cd14a0ba1483957461bbdcb4 (patch) | |
tree | f6675762bd71f3afaa5aaf6a6a07631e03f7fc6e | |
parent | 581866c2670360c682ec2b57b6e6b18afd95b8ff (diff) |
pmwg-ci: Initialize correctly and get the baseline branch
This change group all setup functions into a bigger one which make
sure the underlying functions are called in the right order.
The baseline branch name is retrieved from the configuration file
in order to get the tag from the branch itself and not in a global
manner. That will allow to specify if we track <branch>/HEAD or
<branch>/TAG change.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rwxr-xr-x | pmwg-ci-integ | 91 |
1 files changed, 73 insertions, 18 deletions
diff --git a/pmwg-ci-integ b/pmwg-ci-integ index db30048..9f03bf1 100755 --- a/pmwg-ci-integ +++ b/pmwg-ci-integ @@ -102,6 +102,9 @@ INTEG_BRANCH="integ" # The baseline remote repo BASELINE="baseline" +# The baseline branch defaulting to 'master' +BASELINE_BRANCH=master + Help() { echo @@ -169,11 +172,6 @@ pushd $LOCAL_REPO # The configuration file containing the name + url + branch CONFIG=$(pmwg-ci-config) -if [ "$CONFIG" == "" ]; then - echo "No configuration file found, aborting." - exit 1 -fi - # Global variable to test if a change occured during the last merge # or not. If one branch is added, deleted or updated, this variable # will be different from zero and will lead to the merge operation @@ -181,18 +179,11 @@ fi CHANGED=0 ###################################################################### - # -# When running on a Linux tree, we want to pick the latest tag of the -# Vanilla kernel, not the intermediate state of the Linux tree but a -# relatively stable version. +# The merge process can be greatly simplified by using the +# reuse-recorded-resolution (rerere), but this one must be enabled # -get_lastest_commit_id() { - git describe --abbrev=0 -} - -###################################################################### -do_git_rerere_enable() { +git_rerere_setup() { RES=$(git config --local --bool --get rerere.enabled) @@ -208,6 +199,70 @@ do_git_rerere_enable() { } ###################################################################### +# +# Check we have a configuration file before continuing +# +config_setup() { + if [ "$CONFIG" == "" ]; then + echo "No configuration file found, aborting." + exit 1 + fi +} + +###################################################################### +# +# Compute the remote branch name from the information we have from the +# config file and the BASELINE name +# +baseline_branch_setup() { + + while read LINE; do + + # Ignore commented line + echo $LINE | egrep -q '(^#|^\s*$|^\s*\t*#)' && continue + + REMOTE_NAME=$(echo $LINE | awk '{ print $1 }') + if [ "$REMOTE_NAME" = "$BASELINE" ]; then + + REMOTE_URL=$(git remote -v | grep "^$REMOTE_NAME\b" | grep fetch | awk '{ print $2 }') + REMOTE_BRANCH=$(echo $LINE | awk '{print $3}') + if [ "$REMOTE_BRANCH" != "" ]; then + BASELINE_BRANCH=remotes/$REMOTE_NAME/$REMOTE_BRANCH + break + fi + + fi + + done < $CONFIG +} + +###################################################################### +# +# This is the global setup entry calling the different setup functions. +# It ensures they are called in the right order. +# !! Make sure to not change the order without double checking the !! +# !! initialized variables dependencies !! +# +do_setup() { + + git_rerere_setup + + config_setup + + baseline_branch_setup +} + +###################################################################### +# +# When running on a Linux tree, we want to pick the latest tag of the +# Vanilla kernel, not the intermediate state of the Linux tree but a +# relatively stable version. +# +get_lastest_commit_id() { + git describe --abbrev=0 $BASELINE_BRANCH +} + +###################################################################### do_remove_old() { echo "Removing old remotes ..." @@ -342,9 +397,9 @@ do_update_remote() { ###################################################################### -# The merge process can be greatly simplified by using the -# reuse-recorded-resolution (rerere), but this one must be enabled -do_git_rerere_enable +# Do the entire setup, the function makes sure the setup functions are +# called in the right order for variable dependencies +do_setup # Remove all branches present in the git tree but no longer tracked in # the CONFIG file |