Skip to content

How to preserve private lines of code #304

Open
@oldgiova

Description

@oldgiova

Hi, I have a private and a public repository that share part of the codebase. The workflow is one-way only: it syncs from the public to the private repository.

core.workflow(
  name = "pull",
  origin = git.github_origin(
    url = sourceUrl,
    ref = "main",
  ),
  destination = git.github_pr_destination(
    url = destUrl,
    destination_ref = "main",
    pr_branch = "copybara_from_public_repo",
    title = "Copybara - code sync from public repo",
    body = "This PR is auto-generated by Copybara.",
    integrates = [],
  ),

  origin_files = glob(
    include = filesToSync,
    exclude = excludedFiles
  ),

  destination_files = glob(
    include = filesToSync,
    exclude = excludedFiles
  ),

  authoring = authoring.pass_thru("author <[email protected]>"),
  transformations = [
    metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
    metadata.use_last_change(author=True, message=True, default_message=None),
  ],
  mode = ITERATIVE
)

The issue arises when a private function is added to the private codebase. Copybara tries to delete it because it is not present in the public codebase, and the file is included in the sync.

How can I preserve the private codebase while keeping the file in sync?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions