12

I use Unison to sync website projects across my machines, in one of my machines I would like to avoid sycning (both ways)some folders contained with in the folders I watch:

/vendor
/node_modules
/storage/debugbar
/staroge/framework

This is the profile I use to .prf file I use to execute the sync, you can see that the folders are there in the ignore path lines.

# Roots of the synchronization
root = /Volumes/Data HD
root = ssh://Server//volume1/My Files

# Paths
path = Sites

# Some regexps specifying names and paths to ignore
ignore = Name */@eaDir
ignore = Name */_notes
ignore = Name .DS_Store
ignore = Name SyncToy_*.dat
ignore = Path */Archives
ignore = Path */tools
ignore = Name *.sublime*

# Ignore laravel composer and npm folders
ignore = Path {Sites/CRMJobs/node_modules}
ignore = Path {Sites/Loot/node_modules}
ignore = Path {Sites/Pompous/node_modules}
ignore = Path */vendor
ignore = Path */node_modules
ignore = Path */storage/debugbar
ignore = Path */storage/framework

log = true
times = true
auto = true

You can see that in some cases I've even explicitly mentioned full patches to ignore yet they are still synchronised.

Can someone tell me what I am doing wrong?

Imran
  • 455

2 Answers2

15

See this bit on Path Specification in the Unison manual. Instead of Path you should use Name.

ignore = Name vendor
ignore = Name node_modules
ignore = Name storage/debugbar
ignore = Name storage/framework
Sebastian
  • 105
1

I used one big ignore regex to do this because all other approaches didn't work. If unison would support negative lookaheads, this would have been so much simple, but I had to use an emulation through negative character classes as described here:

https://clusterise.com/articles/regex-negative-lookahead/

If I want only 2 subfolders e.g. "abc" and "def" to be included, I use something like the following:

Regex ^([^ad].*|a[^b].*|ab[^c].*|d[^e].*|de[^f].*)

which kind emulates the negative lookahead ^(?!abc|def)