buddypress / bp-sync-to-wporg

Bash script to sync BuddyPress trunk from BP svn to plugins.svn.wordpress.org, for translate.wordpress.org string import.
GNU General Public License v3.0
3 stars 0 forks source link

SVN file deletions #1

Open paulgibbs opened 8 years ago

paulgibbs commented 8 years ago

Brainstorming possible solutions per https://github.com/buddypress/bp-sync-to-wporg/blob/master/bp-sync-to-wporg#L39

paulgibbs commented 8 years ago

Here's one approach. It uses the xmlstarlet package to parse XML (seems to be fairly popular -- it's on Ubuntu and Debian, at least, and on Mac OS X via brew)

svn status --xml | xmlstarlet sel -t -m '//entry[descendant::wc-status/@item="missing"]/@path' -v . -n | xargs svn rm

I did start by svn status | grep '?' | cut -c9- etc, but was worried about weird edge cases with whitespace in path names (that cut syntax is probably wrong, too, this is just an example from memory) so I wanted to use the XML output so we got the definite path to the removed files.

boonebgorges commented 8 years ago

xmlstarlet looks smart.

Here's another one-liner, which detects ! and uses awk {print $2}, similar to cut. This seems reasonably safe to me, but I suppose you're right that there could be edge cases.

svn status prints nothing but ! deleted/file.php, so this might be good enough:

svn status | sed -rn "s/^\!\s+(.*)/\2/p" | xargs svn rm

where /p prints the captured group (.*) instead of the whole matched line