Skip to content

Commit

Permalink
don't push a change to container.yaml if SHA is blank
Browse files Browse the repository at this point in the history
Change-Id: I37efa3c54a8a6a4951008d3ea3e028c4bdc6c1f9
Signed-off-by: nickboldt <[email protected]>
  • Loading branch information
nickboldt committed Nov 21, 2023
1 parent 0fa3b72 commit feedaa4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions product/updateContainerYamlSHAs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ for yaml in $yamls; do

# Try branch (/heads/)
if [[ ! $SHA ]]; then
SHA=$(git ls-remote $repo refs/heads/$branchOrTag | sed -r -e "s@(.+)\\t.+@\\1@g")
SHA=$(git ls-remote $repo refs/heads/$branchOrTag | sed -r -e "s@(.+)\\t.+@\\1@g" | tr -d " ")
fi
# Use tag (/tags/) if branch does not exist
if [[ ! $SHA ]]; then
SHA=$(git ls-remote $repo refs/tags/$branchOrTag | sed -r -e "s@(.+)\\t.+@\\1@g")
SHA=$(git ls-remote $repo refs/tags/$branchOrTag | sed -r -e "s@(.+)\\t.+@\\1@g" | tr -d " ")
fi
# Or if there's a SHA in job-config.json, use that directly
if [[ ! $SHA ]]; then
Expand All @@ -102,7 +102,9 @@ for yaml in $yamls; do
# sed replacement (match a line, move *N*ext line and *S*ubstitute it) will only work for this 2-line pattern:
# repo: https://github.com/redhat-developer/devspaces-images.git
# ref: e8b28394b00f6d320ec7a9b758875c674595ed58
sed -r -i -e "/.+repo: .+${repo##*/}.*/{n;s/ref: .*/ref: $SHA/}" $yaml
if [[ $SHA ]]; then
sed -r -i -e "/.+repo: .+${repo##*/}.*/{n;s/ref: .*/ref: $SHA/}" $yaml
fi
done
else
echo "No 'remote_sources:' found in $yaml, nothing to do!"
Expand Down

0 comments on commit feedaa4

Please sign in to comment.