Open paulgibbs opened 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.
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
Brainstorming possible solutions per https://github.com/buddypress/bp-sync-to-wporg/blob/master/bp-sync-to-wporg#L39