Skip to content

push command is not registering any changes. #166

@gayatri-kulkarni1

Description

@gayatri-kulkarni1

we want to mirror pending change from source to destination.
Below is the config we are using to achieve this:

core.workflow(
name = "default",
origin = git.origin(
url = "ssh://server/repo.git",
ref = "refs/changes//***/",
),
destination = git.gerrit_destination(
url = "https://server/r/repo.git",
fetch = "master",
push_to_refs_for = "master",
submit=False,
gerrit_submit=False,
),
mode= "CHANGE_REQUEST",
authoring = authoring.pass_thru("Default email default@default.com"),
transformations = [
metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
metadata.expose_label("GERRIT_CHANGE_NUMBER"),
]
)

Issue: commit created at detached head (later checked out to local/copybara branch) for mirror of source pending change.
But when we do the push, we switch to local branch ‘refs/for/master’ on which we have no new commits, so the push is not registering any changes.

Here is the log explaining the sequence of commands executed and the error at the time of push:

Executing [git '--git-dir=/tmp/gkulkarni/tools/.git' '--work-tree=/tmp/out/temp/workdir8703425570713085466/checkout' commit --author --date '2020-10-28 11:49:15-0700' -m '

GitOrigin-RevId: dc9cf4030943622670ca860bb62a8ff4fb335a6b
Change-Id: Ic1d06f7f78e7586ec116f6d63285b7e09320b3dd
']
[detached HEAD d3935b1]

Executing [git '--git-dir=/tmp/gkulkarni/tools/.git' '--work-tree=/tmp/out/temp/workdir8703425570713085466/checkout' checkout -B copybara/local d3935b1b7d3e155fb5272abd0cce01e45f413ab7]
Switched to a new branch 'copybara/local'
Command 'git' finished in 00:00.026. Process exited with status 0
Executing [git '--git-dir=/tmp/gkulkarni/tools/.git' '--work-tree=/tmp/gkulkarni/tools' checkout refs/for/master]
warning: refname 'refs/for/master' is ambiguous.
Switched to branch 'refs/for/master'
Command 'git' finished in 00:00.731. Process exited with status 0
Executing [git '--git-dir=/tmp/gkulkarni/tools/.git' '--work-tree=/tmp/gkulkarni/tools' rev-list -1 HEAD --]
3d85ca4bd49a1ea8609f3be730ed4249b073bfa1
Command 'git' finished in 00:00.007. Process exited with status 0
Task: Git Destination: Pushing to https://server/r/repo.git refs/for/master%hashtag=copybara_id_9101A8B80A6309EBE3D23EE8CBB8B060_
Executing [git '--git-dir=/tmp/gkulkarni/tools/.git' '--work-tree=/tmp/gkulkarni/tools' push --progress https://server/r/repo.git 'HEAD:refs/for/master%hashtag=copybara_id_9101A8B80A6309EBE3D23EE8CBB8B060_']
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Processing changes: refs: 1, done
To https://<>/r/repo.git
! [remote rejected] HEAD -> refs/for/master%hashtag=copybara_id_9101A8B80A6309EBE3D23EE8CBB8B060_ (no new changes)
error: failed to push some refs to 'https://server/r/repo.git'
Command 'git' finished in 00:00.252. Process exited with status 1
INFO: PROFILE: 262 //copybara/run/default/change_request/destination.write/push
INFO: PROFILE: 7436 //copybara/run/default/change_request/destination.write
INFO: PROFILE: 2 //copybara/run/default/change_request/after_migration
INFO: onChangeMigrationFinished(): ChangeMigrationFinishedEvent{destinationEffects=[DestinationEffect{type=TEMPORARY_ERROR, summary=Errors happened during the migration, originRefs=[Change{revision=dc9cf4030943622670ca860bb62a8ff4fb335a6b, author=, dateTime=2020-10-28T11:49:15-07:00, message=
, merge=false, parents=[GitRevision{sha1=ea5ee3ffe7e5e5f7ee620b09002a315171e8c1ed}]}], destinationRef=null, errors=[Error executing 'git --git-dir=/tmp/gkulkarni/tools/.git --work-tree=/tmp/gkulkarni/tools push --progress https://server/r/repo.git HEAD:refs/for/master%hashtag=copybara_id_9101A8B80A6309EBE3D23EE8CBB8B060_'(exit code 1). Stderr: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Processing changes: refs: 1, done
To https://server/r/repo.git
! [remote rejected] HEAD -> refs/for/master%hashtag=copybara_id_9101A8B80A6309EBE3D23EE8CBB8B060_ (no new changes)

Tried with below solution to avoid the issue:
After commenting line 565 in git/GitDestination.java , it is able to create new change on the destination.

Please help understand, if there is a bug where the commit should have happened on ‘refs/for/master’ instead of detached head, or if we should not be switching the branch before push and push from copybara/local to remote branch.

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