Reputation: 12295
I am currently running the gsutil rsync cloud build command:
gcr.io/cloud-builders/gsutil
-m rsync -r -c -d -x "\.gitignore" . gs://mybucket/
I am using the -x "\.gitignore"
argument here to try and not copy over the .gitignore
file, as mentioned here:
https://cloud.google.com/storage/docs/gsutil/commands/rsync
However, when looking in the bucket and the logs, it still says:
2021-04-23T13:29:37.870382893Z Step #1: Copying file://./.gitignore [Content-Type=application/octet-stream]...
So rsync
is still copying over the file despite the -x "\.gitignore"
argument.
According to the docs -x
is a Python regexp, so //./.gitignore
should be captured by \.gitignore
Does anyone know why this isn't working and why the file is still being copied?
Upvotes: 2
Views: 159
Reputation: 627082
See the rsync.py
source code:
if cls.exclude_pattern.match(str_to_check):
In Python, re.match
only returns a match if it occurs at the start of string.
So, in order to find a match anywhere using the -x
parameter, you need to prepend the pattern you need to find with .*
or with (?s).*
:
gcr.io/cloud-builders/gsutil
-m rsync -r -c -d -x ".*\.gitignore" . gs://mybucket/
Note that to make sure .gitignore
appears at the end of string, you need to append $
, -x ".*\.gitignore$"
.
Upvotes: 2