Skip to content

Instantly share code, notes, and snippets.

@cbandy
Last active November 13, 2023 10:17
Show Gist options
  • Save cbandy/b58d32fe44dcbaa91f35e821efb72066 to your computer and use it in GitHub Desktop.
Save cbandy/b58d32fe44dcbaa91f35e821efb72066 to your computer and use it in GitHub Desktop.
Ignore everything except allowed files in .gcloudignore
# Ignore everything
/[!.]*
/.?*
# Except the Cloud Function files we want to deploy
!/package.json
!/index.js
!/lib/**
#!include:.gitignore
import os
from googlecloudsdk.command_lib.util import gcloudignore
chooser = gcloudignore.GetFileChooserForDir('.')
predicate = chooser.IsIncluded
for root, _, filelist in os.walk('.'):
path = os.path.normpath(os.path.relpath(root, '.'))
if not predicate(path):
continue
for f in filelist:
filename = os.path.normpath(os.path.join(root, f))
if not predicate(filename):
continue
print(filename)
@cbandy
Copy link
Author

cbandy commented Mar 23, 2019

@jake-tulip this is late, and I don't know that you'll get a notification... I've tested the following with the above Python script:

!/dir/
!/dir/config/**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment