feedback icon indicating copy to clipboard operation
feedback copied to clipboard

We aren’t reflecting the new name of a branch after a rename, (And possibly not showing the commits on tge brach after the rename either)

Open drazisil-codecov opened this issue 1 year ago • 4 comments

Ah, that's explicitly a UI issue. This one is more a case of "We aren’t reflecting the new name of a branch after a rename, (And possibly not showing the commits on tge brach after the rename either)

This would be a good write-up for the bug sync today. I'll see if I can get to it by then, but if someone else could write it up sooner, that would be :pray:

Slack Message

drazisil-codecov avatar May 30 '24 13:05 drazisil-codecov

Hypothesis:

There is no webhook that fires when a branch name is changed, so we likely have to sync branch names some other way. We likely need to determine when/how branch names update/sync and see what changes may need to be made to support this branch renaming behavior.

Let's treat this as more of an investigation first, to try and understand the work involved. Then we can determine what to do next.

eliatcodecov avatar May 30 '24 16:05 eliatcodecov

https://github.com/codecov/engineering-team/issues/135

matt-codecov avatar May 30 '24 16:05 matt-codecov

I can't win with codecov-hooky

thomasrockhu-codecov avatar Sep 19 '24 15:09 thomasrockhu-codecov

Looking at this + Trent's ticket above, I can indeed confirm there's no direct webhook that we can listen to for branch renames, but what Trent highlighted there is also true, there is a webhook we can listen to, "Push", that can have a ref: <branch_name> with a variable "created": True and "after": some_sha, or "deleted": True and "before": some_sha

Steps to reproduce:

  1. set a tunnel bw local and GH w/ an App installed, like Matt points out in the ticket above
  2. go to github repo, branch dropdown, scroll till bottom, view all branches
  3. select branch, 3 dots, rename
  4. check webhook_handlers/views/github.py, def push method, log things to confirm

I think we could go 2 ways:

  1. we listen to the created:true/after:sha or deleted:true/before:sha to identify this branch creation/deletion pattern, and in each log something on redis that we will read in a subsequent push listener and fully confirm the branch was created and deleted -> more correct but potentially unnecessary
  2. just listen to either/or and do the logic - actually I don't think you could do it just on delete = true cause you still need the new branch name (which you don't have in that webhook), so you could only do it in the created=true

Logic Likely in a batch or potentially a worker task

  1. Find the commit in our DB based on the SHA we have
  2. Find all the commits in our DB that have branch = old_branch
  3. Rename all of those commits from old_branch to new_branch 3.1) Do a followup check if the renamed branch repo.branch (the main branch) and change that - but that will happen rarely and we would most likely do an extra query every time, but it is more correct.
  4. Query the branch table for old_branch + replace it with new_branch -> I don't think the head/authors field should change (I would have to double check if there are some DB triggers that take care of this magic, but I doubt it)

Would there be anything else? And @trent-codecov, is this ticket to investigate or to execute? Confused by Eli's comment but seems like an investigation was done already. Will resume after clarification

adrian-codecov avatar Sep 27 '24 01:09 adrian-codecov

Closing this investigation and designating the work here https://github.com/codecov/feedback/issues/552

adrian-codecov avatar Oct 22 '24 19:10 adrian-codecov