Skip to content

Commit

Permalink
Maintenance: Stabilize stack update
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaefer committed Dec 5, 2024
1 parent ae33a53 commit 86d2553
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions app/jobs/stack_job/templates/update.sh.tt
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,34 @@ __compose_includes() {
printf "%s" "${includes}"
}

__resolve_path() {
local file="$1"
if [ ! -L "$file" ]; then
echo "$file"
return
fi

local resolved_file
resolved_file=$(readlink -m "$file")
local relative_file
relative_file=$(realpath --relative-to="<%= assets.git_dir %>" "$resolved_file")
echo "$relative_file"
}

fetch_diff_stack() {
cd "<%= assets.git_dir %>" >/dev/null
git fetch origin "<%= stack.git_reference %>"
git diff --quiet FETCH_HEAD && exit 254
git diff --name-only FETCH_HEAD || exit 254
cd - >/dev/null
}

has_changed_stack() {
cd "<%= assets.git_dir %>" >/dev/null

local has_changes="false"
for file in $(git diff --name-only origin); do
if [ "$file" = "<%= stack.compose_file %>" ]; then
for file in $(git diff --name-only FETCH_HEAD); do
resolved=$(__resolve_path "<%= stack.compose_file %>")
if [ "$file" = "$resolved" ]; then
has_changes="true"
break
fi
Expand All @@ -37,7 +52,8 @@ has_changed_stack() {
OIFS=$IFS
IFS=' '
for include in $include_files; do
if [ "$file" = "$include" ]; then
resolved=$(__resolve_path "$include")
if [ "$file" = "$resolved" ]; then
has_changes="true"
break
fi
Expand Down

0 comments on commit 86d2553

Please sign in to comment.