Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitBundleRepository._ship: fix behaviour after history rewriting #478

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

elikoga
Copy link
Member

@elikoga elikoga commented Oct 29, 2024

bundle everything and ignore remote head if current head is not in local branch

Tried writing a test_git_remote_bundle_can_handle_removed_head_commit similiar to test_git_remote_init_pull but due to deficiencies in the remote test suite this presented too difficult.

This change cleanly appllies the local state to the remote repository in case of a rewrite. Due to host.rpc.git_update_working_copy running git reset --hard

def update(self, host):
self._ship(host)
remote_id = host.rpc.git_update_working_copy(self.branch)
# This can theoretically fail if we have a fresh repository, but
# that doesn't make sense at this point anyway.
local_id, _ = cmd("git rev-parse HEAD")
local_id = local_id.strip()
if remote_id != local_id:
raise RepositoryDifferentError.from_context(local_id, remote_id)
def git_update_working_copy(branch):
cmd(
"git reset --hard {origin}/{branch}".format(
origin=git_origin, branch=branch
)
)
id, _ = cmd("git rev-parse HEAD")
return id.strip().decode("ascii")

@elikoga elikoga requested a review from zagy as a code owner October 29, 2024 08:49
@elikoga
Copy link
Member Author

elikoga commented Oct 29, 2024

This PR also removes the test_git_remote_bundle_fails_if_needed, which was previously added because of the misconception that #290 was caused by corrupted repostories.

@elikoga elikoga force-pushed the git-bundle-do-not-fail-after-rebase branch from 2122407 to f123764 Compare October 29, 2024 09:25
@elikoga
Copy link
Member Author

elikoga commented Oct 29, 2024

Rebased on top of #479 and moved the changelog to a scriv changelog file in order to avoid Merge conflicts

zagy
zagy previously approved these changes Oct 29, 2024
@elikoga elikoga dismissed zagy’s stale review October 29, 2024 10:36

The merge-base changed after approval.

zagy
zagy previously approved these changes Oct 29, 2024
@elikoga elikoga dismissed zagy’s stale review October 29, 2024 10:38

The merge-base changed after approval.

@zagy zagy merged commit a5f68fc into main Oct 29, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants