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

Unexpected merge importing a pull request #104

Open
ob opened this issue Nov 9, 2019 · 6 comments
Open

Unexpected merge importing a pull request #104

ob opened this issue Nov 9, 2019 · 6 comments

Comments

@ob
Copy link

ob commented Nov 9, 2019

When trying to import a pull request using the workflow:

core.workflow(
    name = "import_pr",
    mode = "CHANGE_REQUEST",
    origin = git.github_pr_origin(
        url = github_public_url,
        branch = "master",
    ),
    destination = git.destination(
        url = github_sot_url,
        fetch = "master",
    ),
    origin_files = glob(["**"]),
    destination_files = glob(
        ["somedir/**"],
        exclude = [
            "somedir/bfile",
        ],
    ),
    authoring = authoring.pass_thru("Default email <default@defatult.com>"),
    transformations = [
        core.move("", "somedir"),
        metadata.save_author(),
        metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
        metadata.expose_label("GITHUB_PR_NUMBER", new_name = "Closes", separator = " #"),
    ],
)

I get:

% copybara copy.bara.sky import_pr 1
Nov 09, 2019 2:51:27 PM com.google.copybara.Main configureLog
INFO: Setting up LogManager
Copybara source mover (Version: Unknown version)
Task: Integrating change from https://github.com/ob/cb-sot-public/pull/1 from ob:ob-patch-1 21171d13a57703bae681c45dd57b2e76bffb1ab5
ERROR: Conflict detected while rebasing /Users/obonilla/copybara/temp/workdir109556842962639907/checkout to d0b3be83ebc842c8dd6feae051391d7a82adf9b8. Please sync or update the change in the origin and retry. Git output was:
First, rewinding head to replay your work on top of it...
Applying: Project import generated by Copybara.
Applying: Project import generated by Copybara.
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
CONFLICT (add/add): Merge conflict in .gitignore
Auto-merging .gitignore
Patch failed at 0002 Project import generated by Copybara.
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

However, that pull request didn't change the .gitignore file so I didn't expect this to be a problem.

SoT repo: https://github.com/ob/cb-sot, exported repo: https://github.com/ob/cb-sot-public, PR that I'm trying to import: https://github.com/ob/cb-sot-public/pull/1

I don't see why Copybara is trying to merge the two .gitignore files, are they treated specially by globs?

@ob
Copy link
Author

ob commented Nov 12, 2019

Looking at the git history for the generated project, I see

% git log --oneline --graph
*   af64a61 (HEAD) Merge pull request #1 from ob:ob-patch-1
|\
| * 21171d1 (refs/copybara_fetch/refs/pull/1/head) Update afile
| * 55cc1e4 Project import generated by Copybara.
| * 80b7e76 Project import generated by Copybara.
* d0b3be8 (copybara/resolvedPush-dacca1cc-cf6b-45dc-976c-189a5df3f5aa, refs/copybara_fetch/master) add somedir/.gitignore
* b4e91bd add some files
* 36eb4a9 Initial commit

Looking at the two tips of the commit history:

% git ls-tree -r d0b3be8
100644 blob 82f3a88e17b409ae206b19e55f5c5b23eb83bcc1	.gitignore
100644 blob 261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64	LICENSE
100644 blob 0f19791fc0d465f4226ee44b07a50dbad869e493	README.md
100644 blob 86e041dad66a19b9518b83b78865015f62662f75	somedir/.gitignore
100644 blob 257cc5642cb1a054f08cc83f2d943e56fd3ebe99	somedir/afile
100644 blob 257cc5642cb1a054f08cc83f2d943e56fd3ebe99	somedir/bfile

which is the state of my SoT, and

% git ls-tree -r 21171d1
100644 blob 86e041dad66a19b9518b83b78865015f62662f75	.gitignore
100644 blob 3bd1f0e29744a1f32b08d5650e62e2e62afb177c	afile

and the merge:

% git ls-tree -r af64a61
100644 blob 86e041dad66a19b9518b83b78865015f62662f75	.gitignore
100644 blob 3bd1f0e29744a1f32b08d5650e62e2e62afb177c	afile
100644 blob 86e041dad66a19b9518b83b78865015f62662f75	somedir/.gitignore
100644 blob 3bd1f0e29744a1f32b08d5650e62e2e62afb177c	somedir/afile

It's almost like the core.move() operation here is not removing the source files.

@ob
Copy link
Author

ob commented Nov 14, 2019

One thing to note when running this again with -v and reading the logs is this:

Executing [git '--git-dir=/Users/obonilla/copybara/cache/git_repos/https%3A%2F%2Fgithub%2Ecom%2Fob%2Fcb-sot%2Egit' '--work-tree=/Users/obonilla/copybara/temp/workdir606592250108702709/checkout' merge-base d0b3be83ebc842c8dd6feae051391d7a82adf9b8 21171d13a57703bae681c45dd57b2e76bffb1ab5]
Command 'git' finished in 00:00.011. Process exited with status 1

Not sure if that's related though...

@mikelalcon
Copy link
Collaborator

mikelalcon commented Nov 15, 2019 via email

@ob
Copy link
Author

ob commented Nov 15, 2019 via email

@mikelalcon
Copy link
Collaborator

mikelalcon commented Nov 26, 2019 via email

@mikelalcon
Copy link
Collaborator

Hi Oscar, did it work for you?

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