Merge pull request #3753 from gitbutlerapp/Virtual-branch

enable the new oplog snapshotting by default
This commit is contained in:
Kiril Videlov 2024-05-12 23:54:38 +02:00 committed by GitHub
commit 1f01503657
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -64,7 +64,8 @@ pub trait Oplog {
impl Oplog for Project { impl Oplog for Project {
fn create_snapshot(&self, details: SnapshotDetails) -> Result<Option<String>> { fn create_snapshot(&self, details: SnapshotDetails) -> Result<Option<String>> {
if self.enable_snapshots.is_none() || self.enable_snapshots == Some(false) { // Default feature flag to true
if self.enable_snapshots.is_some() && self.enable_snapshots == Some(false) {
return Ok(None); return Ok(None);
} }
@ -136,6 +137,12 @@ impl Oplog for Project {
&[&oplog_head_commit], &[&oplog_head_commit],
)?; )?;
// NOTE: After creating a snapshot we are restoring to the state from the integration commit.
// If the integration commit has not been updated, after snapshot creation we may reset to an incorrect state.
// This can be fixed by invoking virtual_branches::integration::update_gitbutler_integration(&vb_state, project_repository)?;
// before the snapshot creation is initiated in the first place.
// However, there should be no conditions under which the integration commit is stale, and if there is, it should be fixed at the source.
// Reset the workdir to how it was // Reset the workdir to how it was
let integration_branch = repo let integration_branch = repo
.find_branch("gitbutler/integration", git2::BranchType::Local)? .find_branch("gitbutler/integration", git2::BranchType::Local)?

View File

@ -795,6 +795,9 @@ fn merge_vbranch_upstream_clean_rebase() -> Result<()> {
let file_path2 = Path::new("test2.txt"); let file_path2 = Path::new("test2.txt");
std::fs::write(Path::new(&project.path).join(file_path2), "file2\n")?; std::fs::write(Path::new(&project.path).join(file_path2), "file2\n")?;
// Update integration commit
virtual_branches::integration::update_gitbutler_integration(&vb_state, project_repository)?;
let remote_branch: git::RemoteRefname = "refs/remotes/origin/master".parse().unwrap(); let remote_branch: git::RemoteRefname = "refs/remotes/origin/master".parse().unwrap();
let mut branch = create_virtual_branch(project_repository, &BranchCreateRequest::default()) let mut branch = create_virtual_branch(project_repository, &BranchCreateRequest::default())
.expect("failed to create virtual branch"); .expect("failed to create virtual branch");