From d4afa36e11104f830970f4554b03b5f031a283d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 7 Jan 2025 15:07:37 +0100 Subject: [PATCH] Comment out the failure in find_objects_added_in --- .../data-liberation-static-files-editor/plugin.php | 1 + .../playground/data-liberation/src/git/WP_Git_Client.php | 2 +- .../data-liberation/src/git/WP_Git_Repository.php | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/playground/data-liberation-static-files-editor/plugin.php b/packages/playground/data-liberation-static-files-editor/plugin.php index 5432eef8fe..3681888d2a 100644 --- a/packages/playground/data-liberation-static-files-editor/plugin.php +++ b/packages/playground/data-liberation-static-files-editor/plugin.php @@ -57,6 +57,7 @@ static private function get_fs() { if(!is_dir(WP_STATIC_PAGES_DIR)) { mkdir(WP_STATIC_PAGES_DIR, 0777, true); } + // $local_fs = new WP_Local_Filesystem(WP_STATIC_PAGES_DIR); $local_fs = new WP_Local_Filesystem(WP_STATIC_PAGES_DIR); $repo = new WP_Git_Repository($local_fs); $repo->add_remote('origin', GIT_REPO_URL); diff --git a/packages/playground/data-liberation/src/git/WP_Git_Client.php b/packages/playground/data-liberation/src/git/WP_Git_Client.php index 6c85d63456..e9c6358d7d 100644 --- a/packages/playground/data-liberation/src/git/WP_Git_Client.php +++ b/packages/playground/data-liberation/src/git/WP_Git_Client.php @@ -160,6 +160,7 @@ public function force_pull($branch_name=null, $path = '/') { $path = '/' . ltrim($path, '/'); $remote_refs = $this->fetchRefs('refs/heads/' . $branch_name); $remote_head = $remote_refs['refs/heads/' . $branch_name]; + // @TODO: Support "want" and "have" here $remote_index = $this->list_objects($remote_head); $remote_branch_ref = 'refs/heads/' . $branch_name; @@ -179,7 +180,6 @@ public function force_pull($branch_name=null, $path = '/') { $all_path_related_oids[] = $remote_head; $all_path_related_oids = array_flip($all_path_related_oids); - // @TODO: Support "want" and "have" here $new_oids = $remote_index->find_objects_added_in($remote_head, $local_ref ?: null, [ 'old_commit_repository' => $local_index, ]); diff --git a/packages/playground/data-liberation/src/git/WP_Git_Repository.php b/packages/playground/data-liberation/src/git/WP_Git_Repository.php index 28a7fa1707..f6da16bba4 100644 --- a/packages/playground/data-liberation/src/git/WP_Git_Repository.php +++ b/packages/playground/data-liberation/src/git/WP_Git_Repository.php @@ -463,7 +463,12 @@ public function find_objects_added_in($new_commit_hash, $old_commit_hash=WP_Git_ while($new_commit_hash !== $old_commit_hash && !wp_git_is_null_oid($new_commit_hash)) { if(false === $this->read_object($new_commit_hash)) { - throw new Exception('Failed to read new commit object: ' . $new_commit_hash); + // @TODO: This is a fatal failure since we're not able to + // establish a path between the old and new commit, + // but it's commented out for now to record a demo. + // Let's restore the failure here. + // throw new Exception('Failed to read new commit object: ' . $new_commit_hash); + break; } $new_objects_oids[$new_commit_hash] = true; $parsed_commit = $this->get_parsed_commit();