question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

First time importing pull request from public to private

See original GitHub issue

Hello!

I’m stuck on importing PRs.

  • I have private and public repositories.
  • Before release I need to import some PRs from public to private repository. There have been zero migrations using Copybara before and repositories have zero commits in common.
  • Copybara obviously cannot find parent commit. I tell it to use latest master commit as parent and it replaces new code in private with the old one from public which is not the part of the PR.

But I need to migrate only PR changes. I think I can use something like patch. Is there any solutions for doing it using Copybara?

Here’s my current config:

core.workflow(
  name = "import_pr_from_oss",

  origin = git.github_pr_origin(
    url = publicRepoUrl,
    state = "ALL",
    use_merge = True,
  ),
  destination = git.github_pr_destination(
    url = internalRepoUrl,
    destination_ref = "master-internal", # TODO: Update to master after test
    integrates = [],
  ),
  mode = "CHANGE_REQUEST",
  set_rev_id = False,

  authoring = authoring.pass_thru("**authoring here**"),

  # Including/excluding files
  origin_files = glob(["**"], exclude = [

    # exclude hidden files
    ".**",
    "**/.**",

    # exclude all private sources
    "private/**",

    # exclude helper scripts and related
    "**.sh",
    "**.log",
    "**.rc",
    "revision.txt",

    # exclude generated bits
    "**/target/**",
    "**/node_modules/**",

  ]) + glob([

    # keep some specified files
    ".circleci/config.yml",
    "**/.placeholder",
    ".mvn/**",
  ]),

  destination_files = glob(["**"], exclude = [

    # exclude hidden files
    ".**",
    "**/.**",

    # exclude all private sources
    "private/**",

    # exclude helper scripts and related
    "**.sh",
    "**.log",
    "**.rc",
    "revision.txt",

    # exclude generated bits
    "**/target/**",
    "**/node_modules/**",
  ]) + glob([

    # keep some specified files
    ".circleci/config.yml",
    "**/.placeholder",
    ".mvn/**",
  ]),

  transformations = [
    metadata.save_author(),
    metadata.expose_label("COPYBARA_INTEGRATE_REVIEW")
    metadata.replace_message("${GITHUB_PR_TITLE}\n\n${GITHUB_PR_BODY}\n\nSubmitted by: @${GITHUB_PR_USER}\n\nExternal PR number: #${GITHUB_PR_NUMBER}"),
  ],

Thank you!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
armooocommented, Feb 12, 2020

I took a shot at adding smart_prune support in #112. At least for my use case it has allowed importing PRs from github when scrubbing was used in the export process.

1reaction
mikelalconcommented, Dec 3, 2019

We don’t have. Here is an example:

Assuming you have this file structure:

copy.bara.sky
patches/patch1.patch
patches/patch2.patch

You would add:

origin = git.github_pr_origin(
   ...
   patch = patch.apply(["patches/patch1.patch", "patches/patch2.patch"]),
   ...
)

or

transformations = [
   ...
   patch.apply(["patches/patch1.patch", "patches/patch2.patch"]),
   ...
]

The advantage of the git origin version is that if you generate the patch from the origin repo ( maybe do an initial temporary and local git apply of the internal patch to the external repo and then save that patch) it will use 3way merge when applying the patch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selectively importing other people's pull requests in your own ...
First make a fork. Then clone the fork locally. Apply patches from Pull Request's. So for instance if your pull requests is on...
Read more >
How to Use a Private Go Module in Your Own Project
Many Go modules are open-source, which means they can be freely accessed and used. However, sometimes you need to make a module private....
Read more >
Use pull requests for code review - Bitbucket - Atlassian Support
After you've added files and made updates to existing code, it's time to merge that code into your Bitbucket Cloud repository. Before you...
Read more >
Getting started with merge requests - GitLab Docs
Delete feature branches on merge or after merging them to keep your repository clean. Take one thing at a time and ship the...
Read more >
Import a Git repo into your project - Azure - Microsoft Learn
User name to specify when the git repository is private. Example. The following command imports the public repo fabrikam-open-source to the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found