Skip to content

Conversation

@jsommerville-untangle
Copy link
Contributor

No description provided.

Comment on lines +13 to +18
- **`default_repo_type`**: Set to `github` (default for all repositories)
- **`repo_type`**: Per-repository field to override the default

Currently migrated repositories:
- `discoverd` - set to `gerrit`
- `bctid` - set to `gerrit`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do a dynamic discovery of the system based on the reponame?

no auth required

curl -X 'GET' \
  'https://repometadata.infra.corp.arista.io/repos/code.arista.io%2Fefw%2Fbctid' \
  -H 'accept: application/json' 2>/dev/null | jq .Metadata.URL.HTTP
"https://github.com/untangle/bctid.git"

and gettit example

curl -X 'GET' \
  'https://repometadata.infra.corp.arista.io/repos/code.arista.io%2Fefw%2Fin-eos' \
  -H 'accept: application/json' 2>/dev/null | jq .Metadata.URL.HTTP
"https://gerrit.corp.arista.io/a/efw/in-eos"

it requires only curl and jq (can be ported to wget most likely)

if args.repositories:
repositories = args.repositories
# When repositories are specified directly, we need to get their info
# For now, assume they're all GitHub unless we can look them up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the MD doc, I described a way to determine the repo.

Copy link
Contributor

@kskrzypczyn-arista kskrzypczyn-arista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find the endpoint in the docs
It didn't work for me in the browser

Comment on lines 203 to 221
if repo_type == "gerrit":
# For Gerrit, create a change directly
success, change_id = create_pr(repository, branch_to, "", branch_from, repo_type)
if not success:
print("Unable to create Gerrit change - merge manually pls")
exit(1)
else:
print(f"Created Gerrit change: {change_id}")
else:
# For GitHub, create branch then PR
success, new_branch = create_branch(repository, branch_from, branch_to, repo_type)
if success is False:
print("Unable to create new branch - merge manually pls")
exit(1)
# Last, open a PR against the branch_to
success = create_pr(repository, branch_to, new_branch, branch_from, repo_type)
if success is False:
print("Unable to create PR - merge manually pls")
exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_pr has an arc for Gerrit already. It looks like we need handling logic here and in all the methods. It looks a bit redundant,

Could we do in alternative way?

  • create_branch for Gerrit always returns True, ""
  • then we keep the same old logic if not success (for Gerrit it will never trigger)
  • then we call create_pr which for Gerrit ignores the new_branch parameter so we can pass here the empty string from create_branch, and it will work

I think it would simplify the logic

project = repository.replace("/", "%2F")

# Get commits in branch_from not in branch_to (ahead)
url_ahead = f"{GERRIT_BASE_URL}/a/projects/{project}/branches/{branch_from}/commits?n=1000"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part of the link works for me

https://gerrit.corp.arista.io/a/projects/efw%2Fdiscoverd/branches/master/

but when I do

https://gerrit.corp.arista.io/a/projects/efw%2Fdiscoverd/branches/master/commits?n=1000

I'm getting

Not found: commits

Should we use
https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-reflog ?

return None, None, None

# Get commit IDs
commits_from_ids = {c.get('commit') for c in commits_from}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find the commits endpoint, if we use reflog endpoint there will be no "commit" member

) -> Tuple[bool, str]:
"""
Attempt to merge branch_from into branch_to.
TODO: implement this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically can be base on automerge being enabled?

auth = get_gerrit_auth()

post_data = {
"project": repository,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be using project here I think

post_data = {
"project": repository,
"subject": f"Merge {branch_from} into {branch_to}",
"branch": branch_to,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a topic here to enable RITS run?

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

Successfully merging this pull request may close these issues.

3 participants