feat: Add patch support for git dependencies

Implement patch application for git-based dependencies after checkout.
This ensures that patches specified in patchedDependencies are applied
to git dependencies just like they are for npm registry dependencies.

- Pass patch_name_and_version_hash through to GitCommandRunner
- Create PatchTask when patches are needed after git checkout
- Set apply_patch_task on the result task so patches are applied

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2025-08-12 04:31:01 +02:00
parent bcebf4e663
commit bb07da19a7
2 changed files with 10 additions and 1 deletions

View File

@@ -1257,7 +1257,6 @@ pub fn enqueueGitCheckout(
/// if patched then we need to do apply step after network task is done
patch_name_and_version_hash: ?u64,
) void {
_ = patch_name_and_version_hash; // TODO: handle patches
const folder_name = PackageManager.cachedGitFolderNamePrint(&git_folder_name_buf, resolved, null);
const target = Path.joinAbsString(this.cache_directory_path, &.{folder_name}, .auto);
@@ -1335,6 +1334,7 @@ pub fn enqueueGitCheckout(
) catch unreachable,
.resolution = resolution,
.target_dir = bun.default_allocator.dupe(u8, target) catch unreachable,
.patch_name_and_version_hash = patch_name_and_version_hash,
},
},
);

View File

@@ -31,6 +31,7 @@ pub const GitCommandRunner = struct {
resolved: strings.StringOrTinyString,
resolution: Resolution,
target_dir: []const u8,
patch_name_and_version_hash: ?u64,
},
};
@@ -671,6 +672,12 @@ pub const GitCommandRunner = struct {
.data = undefined,
.status = undefined,
.err = null,
.apply_patch_task = if (checkout.patch_name_and_version_hash) |h| brk: {
const patch_hash = this.manager.lockfile.patched_dependencies.get(h).?.patchfileHash().?;
const ptask = PatchTask.newApplyPatchHash(this.manager, checkout.dependency_id, patch_hash, h);
ptask.callback.apply.task_id = this.task_id;
break :brk ptask;
} else null,
};
switch (status) {
@@ -848,6 +855,7 @@ pub const GitCommandRunner = struct {
.data = .{ .git_checkout = .{} },
.status = .fail,
.err = err,
.apply_patch_task = null, // Don't apply patches on error
};
this.manager.resolve_tasks.push(task);
@@ -864,6 +872,7 @@ const Repository = @import("./repository.zig").Repository;
const DependencyID = @import("./install.zig").DependencyID;
const ExtractData = @import("./install.zig").ExtractData;
const PackageManager = @import("./install.zig").PackageManager;
const PatchTask = @import("./install.zig").PatchTask;
const Resolution = @import("./install.zig").Resolution;
const Task = @import("./install.zig").Task;