Repo: add commit_map_name to specify which mapping to look up (bug 2050335)#1322
Repo: add commit_map_name to specify which mapping to look up (bug 2050335)#1322shtrom wants to merge 14 commits into
Conversation
|
View this pull request in Lando to land it once approved. |
7483eb3 to
4f7dc0d
Compare
zzzeid
left a comment
There was a problem hiding this comment.
r+ but with a "nit+" that would be good to implement before this is deployed. Also a comment/question.
There was a problem hiding this comment.
Could we not achieve a similar outcome by changing this to "try-comm-central": "thunderbird-desktop"?
There was a problem hiding this comment.
That's the approach I took initially, in #1271, but we thought that migrating the existing CommitMap data to change all the columns may not be desirable #1271 (comment).
Instead, this PR works around removal of some hard-coded stuff, which I think is more desirable.
But happy to discuss if you'd prefer to go the way of #1271 instead.
| commit_map_name = models.CharField( | ||
| blank=True, | ||
| help_text="Name of the CommitMap to use (matches the git_repo_name of the entries)", | ||
| ) |
There was a problem hiding this comment.
nit+: It would be cleaner to use git_repo_name here, turn it into an actual DB field that is set automatically upon first save (maybe rename the existing one to get_git_repo_name). This will eliminate the need for most of the functionality in the data migration script.
This also needs a default ("").
There was a problem hiding this comment.
We could do that as a default, that we could override. The main thing of having a separate field is that we don't need the TRY_REPO_MAPPING... which makes me realise I forgot to remove...
There was a problem hiding this comment.
One issue in using a generic such as git_repo_name rather than making it obvious that's it's for commit mapping is that it may turn into a footgun where most of the time you'll have the git_repo_name you want, and every now and then (try repos), you'll have a different one.
There was a problem hiding this comment.
Also, even Hg repos need a commit-mapping name, and git_repo_name rightfully raises an exception there.
There was a problem hiding this comment.
I think naming aside, it would still make sense to set something on save, especially since as it is, we'll need to set this explicitly every time we create a new repo. So maybe middle ground is: keep naming as-is, but have a default set on first save, if not set already?
commit_map_name is fine, maybe commit_map_repo_name to be more explicit but both are OK.
There was a problem hiding this comment.
We don't need to set something explicitly, as we have defaulting behaviour in try_api.get_commit_map https://github.com/mozilla-conduit/lando/pull/1322/changes#diff-af456f968caba867ca1e61b5693012347b03c6912c7cc03dd3d86277ee410091R53-R59
However, this no longer look like the right place for this method, so I'm going to move it to the CommitMap, as it's also used by other things (such as Try Uplifts).
I don't think we can avoid the manual step here, if we want it to be meaningful: any repo that we create that really needs that info, e.g., try repos, will be using an arbitrary name that cannot be determined by looking at the current repo name (try -> firefox, try-comm-central -> thunderbird, try-nss -> nss).
With the get_commit_map logic (name liable to change after I attack this), we don't have a default written in the DB that's incorrect, though we have a defaulting behaviour that will use the git_repo_name if the repo is git, or fail if not (because we can't guess what the mapping name would be). This is with the note that, really, we would only be using this
- for Hg target_repos
- for which we would have manually recorded a commit_map
because with git-to-git, we don't need commit-mapping, and I doubt we'll do hg-to-git anytime soon (really, I hope never 😅).lando/src/lando/try_api/api.py
Lines 177 to 179 in c42e45b
dcc0767 to
c92a7b0
Compare
zzzeid
left a comment
There was a problem hiding this comment.
Rest of the changes look OK.
| commit_map_name = models.CharField( | ||
| blank=True, | ||
| help_text="Name of the CommitMap to use (matches the git_repo_name of the entries)", | ||
| ) |
There was a problem hiding this comment.
I think naming aside, it would still make sense to set something on save, especially since as it is, we'll need to set this explicitly every time we create a new repo. So maybe middle ground is: keep naming as-is, but have a default set on first save, if not set already?
commit_map_name is fine, maybe commit_map_repo_name to be more explicit but both are OK.
|
Ok, good for yet another look. I think I went in the exact opposite way than what you were describing, but I think it puts more of the related logic together. My running assumption is that the With this assumption in place, we now have logic in the So this doesn't rename the field, nor gives it a non-empty default. Instead, it encapsulates the resolution logic within the The only time when we'd need to explicitly set the |
This will require a data migration to be run after deployment:
Lando: link
Bugzilla: bug 2050335
🚫 This pull request has 1 blocker.