fix extention update when not on main branch #15797
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
issue
currently if a user is using a branch of extension that is not the main branch
there will be an issue when they try to update the extension
in the
check_updates code()
it checks for
origin = repo.rev_parse('origin')
whitch is the commit hash of the main branch and not the hash of the branch where the user is onand later on when confirming the update
fetch_and_reset_hard()
will reset the extention repo to the commit of the main branch and Not the branch the usere is onfor normal users who never switches branches this is fine they should never encounter this issue
but for advanced users who knows how to use git that are deliberately on a different branch this would cause their extension to be hard reste the the master branch
or in development phase, where devs are working on a separate branch the could have there code accidentally hard reset (data loss) to
in the future is possible some extensions might decide to maintain different version compatibility in different branches
if user is using a branch of extension that is not the main branch
the user will be reseted to the main branch
this will also prevent extensions from maintaining compatibility for different versions on different branches
as it will be reset the the main branch
fix solution
repo.rev_parse(f'{repo.remote().name}/{self.branch}')
when checking for updateand
repo.git.reset(f'{repo.remote().name}/{self.branch}', hard=True)
when applying the updateI have done my test and seems to work correctly
but if someone should probably verify again that I haven't screwed up
Checklist: