Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix shell glob in assets svn propset commands #99

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ svn cp "trunk" "tags/$VERSION"
# Fix screenshots getting force downloaded when clicking them
# https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/
if test -d "$SVN_DIR/assets" && test -n "$(find "$SVN_DIR/assets" -maxdepth 1 -name "*.png" -print -quit)"; then
svn propset svn:mime-type "image/png" "$SVN_DIR/assets/*.png" || true
svn propset svn:mime-type "image/png" "$SVN_DIR/assets/"*.png || true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the quote entirely instead of partial quoting the file path glob.

Suggested change
svn propset svn:mime-type "image/png" "$SVN_DIR/assets/"*.png || true
svn propset svn:mime-type "image/png" $SVN_DIR/assets/*.png || true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for other file types.

Copy link
Contributor Author

@lucyllewy lucyllewy Jul 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's best to leave it quoted as the variable $SVN_DIR is not guaranteed to never have spaces in its value. If GitHub change their setup, then the $HOME directory, which is used to generate the $SVN_DIR variable, might change to a location that includes a space. Therefore defensive programming suggests that we should retain the quotes to mitigate potential future breakage caused by platform changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me! Thanks so much for explanation!

fi
if test -d "$SVN_DIR/assets" && test -n "$(find "$SVN_DIR/assets" -maxdepth 1 -name "*.jpg" -print -quit)"; then
svn propset svn:mime-type "image/jpeg" "$SVN_DIR/assets/*.jpg" || true
svn propset svn:mime-type "image/jpeg" "$SVN_DIR/assets/"*.jpg || true
fi
if test -d "$SVN_DIR/assets" && test -n "$(find "$SVN_DIR/assets" -maxdepth 1 -name "*.gif" -print -quit)"; then
svn propset svn:mime-type "image/gif" "$SVN_DIR/assets/*.gif" || true
svn propset svn:mime-type "image/gif" "$SVN_DIR/assets/"*.gif || true
fi
if test -d "$SVN_DIR/assets" && test -n "$(find "$SVN_DIR/assets" -maxdepth 1 -name "*.svg" -print -quit)"; then
svn propset svn:mime-type "image/svg+xml" "$SVN_DIR/assets/*.svg" || true
svn propset svn:mime-type "image/svg+xml" "$SVN_DIR/assets/"*.svg || true
fi

#Resolves => SVN commit failed: Directory out of date
Expand Down