check submodule updates when task.subupdates is set
This commit is contained in:
parent
d41c474275
commit
fcb60d97b9
101
forgebuild.sh
101
forgebuild.sh
|
@ -87,10 +87,10 @@ if [ ! -z $LOG ] && [ "$LOG" != "" ]; then
|
|||
fi
|
||||
|
||||
run() {
|
||||
p_name="$1"
|
||||
p_name="$1"
|
||||
i18n_task="$p_name" info run
|
||||
# Run in background and redirect output to $p_name.log
|
||||
#(GITBUILDCONF="$CONFDIR" GITBUILDDIR="$BASEDIR" nohup $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2>&1) &
|
||||
# Run in background and redirect output to $p_name.log
|
||||
#(GITBUILDCONF="$CONFDIR" GITBUILDDIR="$BASEDIR" nohup $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2>&1) &
|
||||
GITBUILDCONF="$CONFDIR" GITBUILDDIR="$BASEDIR" $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2>&1
|
||||
}
|
||||
|
||||
|
@ -111,15 +111,15 @@ for arg in "$@"; do
|
|||
FOUND_BASEDIR=0
|
||||
elif [[ "$arg" = "-f" ]] || [[ "$arg" = "--force" ]]; then
|
||||
info force_flag
|
||||
FORCE=1
|
||||
FORCE=1
|
||||
elif [[ "$arg" = "-b" ]] || [[ "$arg" = "--basedir" ]]; then
|
||||
FOUND_BASEDIR=1
|
||||
# Maybe it's a task name and we find a corresponding source?
|
||||
# TODO: Support source-less tasks https://tildegit.org/southerntofu/git-build.sh/issues/8
|
||||
elif [ -f $BASEDIR/$arg.source ]; then
|
||||
elif [ -f $BASEDIR/$arg.source ]; then
|
||||
export i18n_task="$arg"
|
||||
debug found_task
|
||||
PROJECTS+=("$arg")
|
||||
PROJECTS+=("$arg")
|
||||
# Maybe it's a repo URL and we find a corresponding task?
|
||||
elif matches="$(grep --files-with-matches --word-regexp "$arg" $BASEDIR/*.source)"; then
|
||||
# Iterate over the files found to extract the task name
|
||||
|
@ -136,7 +136,7 @@ for arg in "$@"; do
|
|||
export i18n_arg="$arg"
|
||||
error unknown_arg
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Still the default BASEDIR, if it doesn't exist we create it as a convenience
|
||||
|
@ -152,13 +152,13 @@ echo "$BASHPID" > $BASEDIR/.LOCK
|
|||
if [[ ${#PROJECTS[*]} = 0 ]]; then
|
||||
info no_task
|
||||
# TODO: sourceless tasks
|
||||
for file in $BASEDIR/*.source; do
|
||||
# Extract the project name from path
|
||||
for file in $BASEDIR/*.source; do
|
||||
# Extract the project name from path
|
||||
task="$(basename $file .source)"
|
||||
export i18n_task="$task"
|
||||
debug found_task
|
||||
PROJECTS+=("$task")
|
||||
done
|
||||
PROJECTS+=("$task")
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
|
@ -175,7 +175,7 @@ for p_name in ${PROJECTS[*]}; do
|
|||
# For translations
|
||||
export i18n_task="$p_name"
|
||||
debug start_proc
|
||||
# Check if task should run on host
|
||||
# Check if task should run on host
|
||||
if [ -f $BASEDIR/$p_name.hosts ]; then
|
||||
if ! grep "^\s*$HOSTNAME\s*$" $BASEDIR/$p_name.hosts > /dev/null; then
|
||||
# The task is specifically configured for different hosts, ignore
|
||||
|
@ -189,9 +189,9 @@ for p_name in ${PROJECTS[*]}; do
|
|||
info host_ignored
|
||||
continue
|
||||
fi
|
||||
info process
|
||||
info process
|
||||
# checkout a specific branch/commit
|
||||
if [ -f $BASEDIR/$p_name.checkout ]; then
|
||||
if [ -f $BASEDIR/$p_name.checkout ]; then
|
||||
p_branch="$(cat $BASEDIR/$p_name.checkout)"
|
||||
export i18n_branch="$p_branch"
|
||||
info to_branch
|
||||
|
@ -201,48 +201,67 @@ for p_name in ${PROJECTS[*]}; do
|
|||
export i18n_branch="$p_branch"
|
||||
debug default_branch
|
||||
fi
|
||||
p_dir="$BASEDIR/.$p_name"
|
||||
if [ ! -d $p_dir ]; then
|
||||
source="$(cat $BASEDIR/$p_name.source)"
|
||||
p_dir="$BASEDIR/.$p_name"
|
||||
if [ ! -d $p_dir ]; then
|
||||
source="$(cat $BASEDIR/$p_name.source)"
|
||||
export i18n_source="$source"
|
||||
info clone
|
||||
# Don't forget the git submodules!
|
||||
if ! git clone --recursive "$source" "$p_dir"; then
|
||||
info clone
|
||||
# Don't forget the git submodules!
|
||||
if ! git clone --recursive "$source" "$p_dir"; then
|
||||
error clone_failed
|
||||
exit 1
|
||||
fi
|
||||
cd $p_dir
|
||||
if [[ "$p_branch" != "master" ]]; then
|
||||
debug checkout
|
||||
if ! git checkout "$p_branch"; then
|
||||
cd $p_dir
|
||||
if [[ "$p_branch" != "master" ]]; then
|
||||
debug checkout
|
||||
if ! git checkout "$p_branch"; then
|
||||
error checkout_failed
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
run $p_name
|
||||
fi
|
||||
run $p_name
|
||||
# Skip to the next task!
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
debug already_cloned
|
||||
cd "$p_dir"
|
||||
# Refresh remote before comparing with local
|
||||
git fetch --quiet origin
|
||||
git diff --quiet remotes/origin/$p_branch
|
||||
if [[ $? != 0 ]]; then
|
||||
info pull
|
||||
# Update all submodules, for now only when the main repo changed (TODO)
|
||||
if ! git pull --quiet --recurse-submodules; then
|
||||
cd "$p_dir"
|
||||
# Refresh remote before comparing with local
|
||||
if ! git fetch --quiet origin; then
|
||||
error pull_failed
|
||||
exit 1
|
||||
fi
|
||||
git diff --quiet remotes/origin/$p_branch
|
||||
if [[ $? != 0 ]]; then
|
||||
info pull
|
||||
if ! git pull --quiet; then #--recurse-submodules; then
|
||||
error pull_failed
|
||||
exit 1
|
||||
fi
|
||||
run $p_name
|
||||
# If no update was found, we can still force rebuild with -f/--force
|
||||
elif [[ $FORCE = 1 ]]; then
|
||||
run $p_name
|
||||
# If no update was found, we can still force rebuild with -f/--force
|
||||
elif [[ $FORCE = 1 ]]; then
|
||||
debug forcing
|
||||
run $p_name
|
||||
run $p_name
|
||||
else
|
||||
debug no_update
|
||||
fi
|
||||
# No update on the primary branch, but maybe there's a submodule update?
|
||||
if [ -f $BASEDIR/$p_name.subupdates ]; then
|
||||
git submodule foreach --recursive 'if ! git fetch --quiet origin; then\
|
||||
error pull_failed\
|
||||
exit 1\
|
||||
fi\
|
||||
git diff --quiet remotes/origin/$(git rev-parse --abbrev-ref HEAD)\
|
||||
if [[ $? != 0 ]]; then\
|
||||
info pull\
|
||||
if ! git pull --quiet; then\
|
||||
error pull_failed\
|
||||
exit 1\
|
||||
fi\
|
||||
fi'
|
||||
run $p_name
|
||||
else
|
||||
debug no_update
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Check the PID in lockfile is still ours, we don't want
|
||||
|
|
Loading…
Reference in New Issue