guard-rsync
guard-rsync copied to clipboard
Stripping trailing slashes is breaking RSync
I'm having to do :input => 'www//' to bypass the @input = ensure_no_trailing_slash(options[:input]) code.
This is to ensure consistent behavior with delete (depends on recursing into a directory) and ignore paths (which have the directory when there is no trailing slash). With the trailing slash rsync isn't syncing the directory, just the files in the directory.
The ignore path code makes an assumption you are recursing into the top directory.
Can you explain a little more about your use case?
Sure. I'm being forced to work on a samba share for some web dev. I'm using guard-rsync to avoid the shares. My Guardfile looks like this:
guard('rsync', {
:input => 'www//',
:output => 'user@server:/var/www/website',
:excludes => {
/(.+)\.(php|html|css|js)$/ => ()
}
}) do
watch(%r{^www/(.+)\.(php|html|css|js)$})
end
Not sure if the guard file is correct sorry, found the excludes a little confusing if I'm honest but seems to be working.
In the example I gave, excludes was to ignore auto generated files and their sources in the sync. I don't think you actually want any exclude option. The arguments I choose was because I wanted to mirror a directory. That's why it uses -av --delete and no trailing slash (--delete doesn't work outside of directory recursion, so trailing slash would cause it not to work in the top level).
I think what you want is just to be able to run a shell task per batch of changes. Maybe you should request that of guard-shell to have an option to run once per batch rather than a shell per change, because you have a specific rsync command and are not using any of the other options.
Would it not be better to make guard-rsync more generic so it can be used for many kinds of rsync scenarios? It seems like it was written for a specific rsync scenario only.
I don't know when I'm going to have time to address these, I'd like to make excludes optional, and make the trailing slash just a warning if you combine it with --delete and give a chance to override options before the command is executed.
I am responsive to pull requests.