gcs.py 391 B

123456789101112131415
  1. #!/usr/bin/python3
  2. # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  3. import tempfile
  4. from google.cloud import storage
  5. from dulwich.cloud.gcs import GcsObjectStore
  6. from dulwich.repo import Repo
  7. client = storage.Client()
  8. bucket = client.get_bucket("mybucket")
  9. gcs_object_store = GcsObjectStore(bucket, "path")
  10. r = Repo.init_bare(tempfile.mkdtemp(), object_store=gcs_object_store)