Closed Fryguy closed 2 months ago
When we refresh a repository, we should prune branches that no longer exist on the remote.
One thing we have to be careful of, however, is that if a branch is still in use by the product (in automate, or even in workflows, ansible, etc), that we don't remove that branch, but perhaps log a warning.
Steps Done for debugging
updated the git_repository_id with an existing git repository Initially, the git_repository_id in the newly created domain will be nil. Update the git_repository_id with the existing Git repository.
enabled the button from the classic-ui/miq_ae_git_refresh.rb https://github.com/ManageIQ/manageiq-ui-classic/blob/c3594da0fcb0d3b4b50c559bede02ec3199cc4be/app/helpers/application_helper/button/miq_ae_git_refresh.rb#L9
After this, we can see the “Refresh with a new branch or tag”
branch names are generated from https://github.com/ManageIQ/manageiq-ui-classic/blob/c3594da0fcb0d3b4b50c559bede02ec3199cc4be/app/views/miq_ae_class/_git_domain_refresh.html.haml
I assume this can be controlled from https://github.com/ManageIQ/manageiq/blob/2b57f9a42ad54a0255920c790c1f9dccce9ce26f/app/models/git_repository.rb by adding a instance method say "def branches
" and filtering them as active ones
We have another method named branch_info https://github.com/ManageIQ/manageiq/blob/2b57f9a42ad54a0255920c790c1f9dccce9ce26f/app/models/git_repository.rb#L61 , but we dont have enough information here
name: "origin/sa-hackathon", commit_sha: "058571308cacd92f1c4f4a11e9a62ced96a3fd54", commit_time: Thu, 28 Jul 2016 22:46:57.000000000 UTC +00:00, commit_message: "Merge pull request #161 from thisdavejohnson/master\n\nMoved AWS-specific bits to a sub-directory and added provisioning playbooks", type: "GitBranch", git_repository_id: 17,
Let me try to find more information on how to achieve this. @Fryguy do you know where this information is stored in our db?
@Fryguy I've made some code changes in this file to see the “Refresh with a new branch or tag” button. How can we view this button in the UI without modifying the code?
@jaisejose1123 the UI code you've linked to just displays what is in the repository, the issue here is that the local clone of the repo we have has out-of-date refs.
Here is where a GitRepository
refresh is done https://github.com/ManageIQ/manageiq/blob/2b57f9a42ad54a0255920c790c1f9dccce9ce26f/app/models/git_repository.rb#L51-L59 so I'm assuming that the fetch_and_merge
from GitWorktree
should also prune local refs that don't exist on the remote.
@jaisejose1123 Right - create a git branch, then refresh from the UI, then delete the git branch, then refresh from the UI again. The branch should go away, but the reported bug is that it doesn't
Created a PR please review https://github.com/ManageIQ/manageiq/pull/23115
Fixed in #23115
Discussed in https://github.com/orgs/ManageIQ/discussions/23085