[clean-repository-handling] Clean repository handling#27
[clean-repository-handling] Clean repository handling#27jgerigmeyer merged 21 commits intomasterfrom
Conversation
|
@davisagli on the old PR, you mentioned:
|
|
@davisagli ready for you to look at that change if you want. |
jgerigmeyer
left a comment
There was a problem hiding this comment.
@wlonk Part of the purpose of this is to use IDs as the unique identifier when comparing repos. So I would expect it to be used in e.g. get_all_org_repos and the RepositoryViewSet.get_queryset view?
jgerigmeyer
left a comment
There was a problem hiding this comment.
@wlonk I have a number of ideas for cleanup here. At a high level view, I still think we only need admins to enter owner and name explicitly in the admin, then we use that to get the ID and only use the ID from there on out. I don't see a compelling reason to use (or store) the repo_url at all, since we're really only using it to parse out owner and name.
If you don't mind, I'd like to make a commit with my proposed cleanup here.
|
@wlonk Okay, I'm sure there's some ugly code/architecture in my latest commit, but I'd be happy to talk through it with you and let you do whatever cleanup (or reverting) you like. |
* master: Fix up tests to use current changes format Fix tests 📦 🛢 Various cleanup:
| and get it from the model if present, or query the GitHub API as | ||
| a fallback, assuming that the current user can access the | ||
| current repo via the repo URL. | ||
| """ |
There was a problem hiding this comment.
I don't love this deferring, but understand why it might be preferred. I wonder about (also?) trying to populate repo_id on every save?
| User, on_delete=models.CASCADE, related_name="repositories" | ||
| ) | ||
| repo_id = models.IntegerField(unique=True) | ||
| repo_url = models.URLField() |
There was a problem hiding this comment.
The only reasons to store this IMO are 1) it's trivial, and 2) for ease of DB sleuthing and admin browsing.
| ) | ||
|
|
||
| def get_repo_url(self, obj) -> Optional[str]: | ||
| return f"https://github.com/{obj.repo_owner}/{obj.repo_name}" |
There was a problem hiding this comment.
I don't love this. We could store it on the model and populate it lazily (like we're doing for repo_id).
| repo_name = repo.repo_name | ||
| branch = obj.branch_name | ||
| if repo_owner and repo_name and branch: | ||
| return f"https://github.com/{repo_owner}/{repo_name}/tree/{branch}" |
There was a problem hiding this comment.
I also don't love these two hard-coded URLs, but it's not a big deal.
| try: | ||
| repo.get_repo_id(self.request.user) | ||
| except ResponseError: | ||
| pass |
There was a problem hiding this comment.
So I'd guess this is probably frowned upon? It forces an external API call in-band for any repos which don't have IDs yet -- on every get_queryset... 😬
There was a problem hiding this comment.
Yeah, that's a little upsetting. Let's… see if it is a problem maybe?
There was a problem hiding this comment.
This should only happen once ever per repo in the DB. So I would think in practice it won't be an issue? But let's discuss.
wlonk
left a comment
There was a problem hiding this comment.
Generally 👍 on your changes, though I left a few comments to discuss. Detailed discussion tomorrow?
| try: | ||
| repo.get_repo_id(self.request.user) | ||
| except ResponseError: | ||
| pass |
There was a problem hiding this comment.
Yeah, that's a little upsetting. Let's… see if it is a problem maybe?
* master: Stick with 2 seconds. Copy semaphore logic from MetaDeploy. Use single Redis call to set expiry Rewrap some comments 🛢 Lint python. 📦 🧶 Combined dep upgrades. Bump pytest-django from 3.5.1 to 3.6.0 Add expire to semaphore 🛢 Delete new org from SF if initial flow run fails. Create orgs from latest task branch, not default repo branch.
|
@wlonk @davisagli I'm satisfied with this PR, and did functional testing. As far as I'm concerned it's ready for review/merge. |
wlonk
left a comment
There was a problem hiding this comment.
I can't formally approve, as I opened the PR, but I do approve. 💚
See https://trello.com/c/fsDdnJmD/101-chore-clean-up-repository-url-handling-in-admin
See also SFDO-Tooling#237