google / google/copybara

CHANGE_REQUEST mode is showing additional files as changed in the destination as compared to origin

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

Description

Trying to mirror a change from gerrit-server-1 to gerrit-server-2 in CHANGE_REQUEST mode
New changes created on destination gerrit server (gerrit-server-2) has additional files shown as changed/added/deleted where even if only 1 file has been changed/added/deleted on the origin gerrit server (gerrit-server-1)

**Note**: This behavior is not consistent.

- There are cases when origin change just has one file changed/added/deleted on origin gerrit server (gerrit-server-1) and the mirror change as well shows the same file as changed/added/deleted on the destination gerrit server (gerrit-server-2) **[CORRECT BEHAVIOUR]**

- There is also a case when there is just one file changed/added/deleted on origin gerrit server (gerrit-server-1) but the mirror change shows **multiple** files changed/added/deleted on destination gerrit server (gerrit-server-2) **[WRONG BEHAVIOUR]**

Providing a specific scenario, copy.bara.sky and Logs below

**Source** change : file xyz/pqr/test.txt (Changed)
**Expected** destination change : xyz/pqr/test.txt (Changed)

**Actual** destination change:
```
1. xyz/pqr/test.txt (Changed)
2. xyz/pqr/abc.txt (Added)
3. xyz/pqr/def.txt (Deleted)
```

**copy.bara.sky**
```
core.workflow(
name = "gerrit_server_1_to_2",
origin = git.gerrit_origin(
url = "https:///r/a/.git",
ref = "main",
first_parent = False,
),
destination = git.gerrit_destination(
url = "https:///r/a/.git",
fetch = "main",
change_id_policy="REUSE",
),
mode = "CHANGE_REQUEST",
reversible_check = False,
origin_files=glob(["**"]),
destination_files = glob(['xyz/pqr/**']),
authoring = authoring.pass_thru(""),
transformations = [
metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
metadata.expose_label("GERRIT_CHANGE_NUMBER"),
]
)

```

Logs
```shell
copybara copy.bara.sky gerrit_server_1_to_2 http:///r/ --change_request_parent= --output-root=/tmp

Jul 25, 2021 8:20:01 AM com.google.copybara.Main configureLog
INFO: Setting up LogManager
Copybara source mover (Version: Unknown version)
Task: Loading config copy.bara.sky
WARN: 'ref' field detected in configuration. git.gerrit_origin is deprecating its usage for submitted changes. Use git.origin instead.
WARN: 'ref' field detected in configuration. git.gerrit_origin is deprecating its usage for submitted changes. Use git.origin instead.
WARN: 'ref' field detected in configuration. git.gerrit_origin is deprecating its usage for submitted changes. Use git.origin instead.
Task: Git Origin: Initializing local repo
WARN: Assuming repository 'https:///r/a/.git' for looking for review 'http:///r/'
Task: Checking out the change
Task: Removing excluded origin files
Task: Git Destination: Fetching: https:///r/a/.git refs/heads/main
Task: Git Destination: Checking out main
Task: Git Destination: Excluding files
Task: Querying Gerrit ('https:///r/a/.git') for active changes with hashtag 'copybara_id_'
--------------------------gerrit_get_changes----------------------------r/changes/?q=hashtag%3A%22copybara_id_%22+AND+project%3Aa%2F.git+AND+status%3ANEW
[]
WARN: --------------------------GerritMessageInfo------------------- true
WARN: ------------------------allowEmptyDiffPatchSet--------------------- true
Task: Querying Gerrit ('https:///r/a/.git') for change ''
--------------------------gerrit_get_changes----------------------------r/changes/?q=change%3A++AND+project%3Aa%2F.git&o=CURRENT_REVISION
[]
WARN: ------------------------changeInfo--------------------- null
Task: Git Destination: Pushing to https:///r/a/.git refs/for/main%hashtag=copybara_id_
INFO: New Gerrit review created at https:///r/c//+/
```

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.