google / google/copybara

How to preserve private lines of code

Open
#304 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
3.8k
Forks
345
PR merge metrics
No merged PRs in 30d

Description

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 "),
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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.