Skip to content

Issue in destination url parsing while creating open Gerrit change through Copybara #165

Open
@gayatri-kulkarni1

Description

@gayatri-kulkarni1

we want to mirror pending change from source to destination, here 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 = "ssh://
*******.git", ssh not working
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 [email protected]"),
transformations = [
metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
metadata.expose_label("GERRIT_CHANGE_NUMBER"),
]
)

Issue: url for gerrit_destination is not accepting ssh url format, and https format consists of /r or /r/a in the url which is giving error while parsing:
Here is the log:
Task: Querying Gerrit ('https://server/r/repo.git') for active changes with hashtag 'copybara_id_A434D590887C3F125B3383278F978F28_'
Executing [git init --bare]
Reinitialized existing Git repository in /tmp/cache/git_repos/just_for_github_api/
Command 'git' finished in 00:00.022. Process exited with status 0
Executing [git config --local credential.helper store]
Command 'git' finished in 00:00.007. Process exited with status 0
Executing [git '--git-dir=/tmp/cache/git_repos/just_for_github_api' config fetch.prune false --local]
Command 'git' finished in 00:00.007. Process exited with status 0
INFO: PROFILE: 341 //copybara/run/default/change_request/destination.write/gerrit_get_changes
INFO: PROFILE: 4391 //copybara/run/default/change_request/destination.write
INFO: PROFILE: 3 //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 running Gerrit API operation https://server/changes/?q=hashtag:%22copybara_id_A434D590887C3F125B3383278F978F28_%22%20AND%20project:r/repo.git%20AND%20status:NEW]}]}
INFO: PROFILE: 6985 //copybara/run/default/change_request
INFO: PROFILE: 1 //copybara/run/default/after_all_migration
INFO: PROFILE: 7657 //copybara/run/default
ERROR: Error running Gerrit API operation https://server/changes/?q=hashtag:%22copybara_id_A434D590887C3F125B3383278F978F28_%22%20AND%20project:r/repo.git%20AND%20status:NEW
CAUSED BY: stream is closed

Tried with below solution to avoid the issue:
If we make below changes in the url for finding active changes

  1. /r is removed in project path (git/GerritOptions.java : getProject)
  2. /r is added for get operation of the change (gerritapi/GerritApi.java)
    Then it is able to find the active change.
    i.e. https://server/r/changes/?q=hashtag:%22copybara_id_A434D590887C3F125B3383278F978F28_%22%20AND%20project:users/gkulkarni/tools.git%20AND%20status:NEW

Please let us know the correct approach to make https url with /r or /r/a work for gerrit_destination.

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