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

uplift: port functionality (bug 1915695) #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zzzeid
Copy link
Collaborator

@zzzeid zzzeid commented Nov 22, 2024

  • port existing uplift functionality
  • adapt form to use new fields
  • update endpoints and connect them to legacy api

Note: This ports an early version of uplift functionality that was moved over as part of the initial repo migration.

@zzzeid zzzeid force-pushed the zeid/bug-1915695-uplift branch 2 times, most recently from 5f2ae0d to 5229676 Compare January 20, 2025 18:01
@zzzeid zzzeid force-pushed the zeid/bug-1915695-uplift branch from 5229676 to edf2cc1 Compare January 20, 2025 18:15
@zzzeid zzzeid requested review from cgsheeh and shtrom January 20, 2025 18:19
@zzzeid zzzeid marked this pull request as ready for review January 20, 2025 18:19
Copy link
Member

@shtrom shtrom left a comment

Choose a reason for hiding this comment

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

I think the error-handling is Uplift.post is in the wrong order.

Apart from that (and a few more nits), this looks pretty good.


repos = phab.expect(repos, "data")

def get_uplift_repositories() -> list:
Copy link
Member

Choose a reason for hiding this comment

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

Is there a type that we could make it a list[] of?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can add that.

Side note: this is an early version of uplift functionality, and as part of updating the repo with all the changes in the lando-api and lando-ui repos, this code will be affected.

revision_id = forms.RegexField(regex="D[0-9]+$")
repository = forms.CharField()
revision_id = forms.RegexField(
regex="D[0-9]+$",
Copy link
Member

Choose a reason for hiding this comment

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

We can make the RE stricter.

Suggested change
regex="D[0-9]+$",
regex="^D[0-9]+$",

Comment on lines +30 to +31
all_repos = Repo.get_mapping()
repository = all_repos.get(repo_name)
Copy link
Member

Choose a reason for hiding this comment

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

Does this only select upliftable repos?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it will just verify that the repo is in fact a repo. I will clean up this section a little, but I think in the long run we should probably sync an "uplift" flag that is on the Repo object itself, and that way we can query these repos directly without contacting phabricator.

Copy link
Member

Choose a reason for hiding this comment

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

Yep. It might be worth having a deliberate action or command to sync from Phabricator, but otherwise not do it, or do it periodically rather than on demand. Looking in suite, I saw that lando fires a large number of requests at Phabricator, and reducing them could potentially make the whole experience faster.

if not request.user.is_authenticated:
raise PermissionError()

if uplift_request_form.is_valid() and not errors:
Copy link
Member

Choose a reason for hiding this comment

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

errors will always be empty here, as it only gets set below on line 53. I'd suggest moving the error management LL52-64 up before this, and return early, and keep the happy case as the continuation of the method.

@shtrom
Copy link
Member

shtrom commented Jan 21, 2025

It might be worth adding some tests for the API bit, too.

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.

2 participants