-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
Conversation
5f2ae0d
to
5229676
Compare
5229676
to
edf2cc1
Compare
There was a problem hiding this 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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]+$", |
There was a problem hiding this comment.
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.
regex="D[0-9]+$", | |
regex="^D[0-9]+$", |
all_repos = Repo.get_mapping() | ||
repository = all_repos.get(repo_name) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
It might be worth adding some tests for the API bit, too. |
Note: This ports an early version of uplift functionality that was moved over as part of the initial repo migration.