Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to preserve private lines of code #304

Open
oldgiova opened this issue Oct 29, 2024 · 2 comments
Open

How to preserve private lines of code #304

oldgiova opened this issue Oct 29, 2024 · 2 comments

Comments

@oldgiova
Copy link

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!

@hsudhof
Copy link
Collaborator

hsudhof commented Oct 30, 2024

Generally: patches or transforms, but you can also use merge_mode

@oldgiova
Copy link
Author

Thanks @hsudhof ! Do you have some more information regarding the merge_mode? I can't find it in the reference.

About patches, I've already excluded them because we don't want to generate a diff file in advance for every files we're maintaining, since the drift between the private and the public repo is quite huge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants