Skip to content

Commit

Permalink
tools: Fix svn status parsing (#34651)
Browse files Browse the repository at this point in the history
While `svn status` normally looks like it only outputs one flag followed
by 7 spaces then the filename, in fact six of those seven spaces can be
additional flags. Our current parsing breaks if we have any non-space
flags after a space flag.

Instead, extract the seven flags, log if any of the last six aren't
spaces, and then process as before.

Also it seems `tools/deploy-assets-to-svn.sh` missed the "peg revisions"
fix from #31695, add that in there too.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7212569534
  • Loading branch information
anomiex authored and matticbot committed Dec 14, 2023
1 parent 0035ac2 commit bc4ae39
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/files/wp-svn-autopublish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,16 @@ find trunk -type d -empty -print -delete
echo '::endgroup::'

echo "::group::Adding and removing SVN files"
while IFS=" " read -r FLAG FILE; do
while IFS= read -r LINE; do
FLAGS="${LINE:0:7}"
FILE="${LINE:8}"
if [[ "$FLAGS" != ?' ' ]]; then
echo "Unexpected svn flags: $LINE"
fi
# The appending of an `@` to the filename here avoids problems with filenames containing `@` being interpreted as "peg revisions".
if [[ "$FLAG" == '!' ]]; then
if [[ "${FLAGS:0:1}" == '!' ]]; then
svn rm "${FILE}@"
elif [[ "$FLAG" == "?" ]]; then
elif [[ "${FLAGS:0:1}" == "?" ]]; then
svn add "${FILE}@"
fi
done < <( svn status )
Expand Down

0 comments on commit bc4ae39

Please sign in to comment.