mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
@@ -2251,11 +2251,12 @@ const bun = @import("bun");
|
||||
const Environment = bun.Environment;
|
||||
const Output = bun.Output;
|
||||
const PosixSpawn = bun.spawn;
|
||||
const LifecycleScriptSubprocess = bun.install.LifecycleScriptSubprocess;
|
||||
const GitCommandRunner = bun.install.GitCommandRunner;
|
||||
const Maybe = bun.sys.Maybe;
|
||||
const ShellSubprocess = bun.shell.ShellSubprocess;
|
||||
const uv = bun.windows.libuv;
|
||||
|
||||
const GitCommandRunner = bun.install.GitCommandRunner;
|
||||
const LifecycleScriptSubprocess = bun.install.LifecycleScriptSubprocess;
|
||||
|
||||
const jsc = bun.jsc;
|
||||
const Subprocess = jsc.Subprocess;
|
||||
|
||||
@@ -1298,9 +1298,9 @@ const Dependency = bun.install.Dependency;
|
||||
const DependencyID = bun.install.DependencyID;
|
||||
const Features = bun.install.Features;
|
||||
const FolderResolution = bun.install.FolderResolution;
|
||||
const GitCommandRunner = bun.install.GitCommandRunner;
|
||||
const IdentityContext = bun.install.IdentityContext;
|
||||
const LifecycleScriptSubprocess = bun.install.LifecycleScriptSubprocess;
|
||||
const GitCommandRunner = bun.install.GitCommandRunner;
|
||||
const NetworkTask = bun.install.NetworkTask;
|
||||
const PackageID = bun.install.PackageID;
|
||||
const PackageManager = bun.install.PackageManager;
|
||||
|
||||
@@ -1143,16 +1143,16 @@ fn enqueueGitClone(
|
||||
) void {
|
||||
_ = patch_name_and_version_hash; // TODO: handle patches
|
||||
_ = dependency; // Currently unused
|
||||
|
||||
|
||||
const url = this.lockfile.str(&repository.repo);
|
||||
// Enqueue git clone for url
|
||||
const folder_name = std.fmt.bufPrintZ(&git_folder_name_buf, "{any}.git", .{
|
||||
bun.fmt.hexIntLower(task_id.get()),
|
||||
}) catch unreachable;
|
||||
|
||||
|
||||
// Build git command arguments
|
||||
var argc: usize = 0;
|
||||
|
||||
|
||||
// Try HTTPS first
|
||||
const argv = if (Repository.tryHTTPS(url)) |https| blk: {
|
||||
const args: [10]?[*:0]const u8 = .{
|
||||
@@ -1212,7 +1212,7 @@ fn enqueueGitClone(
|
||||
this.wake();
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
// Spawn GitCommandRunner
|
||||
// Increment pending tasks so the event loop knows to wait for this
|
||||
this.incrementPendingTasks(1);
|
||||
@@ -1258,7 +1258,7 @@ pub fn enqueueGitCheckout(
|
||||
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);
|
||||
const repo_path = bun.getFdPath(dir, &git_path_buf) catch |err| {
|
||||
@@ -1291,7 +1291,7 @@ pub fn enqueueGitCheckout(
|
||||
this.wake();
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
// Build git command arguments for clone --no-checkout
|
||||
const argv: [10]?[*:0]const u8 = .{
|
||||
"git",
|
||||
@@ -1306,7 +1306,7 @@ pub fn enqueueGitCheckout(
|
||||
null,
|
||||
};
|
||||
const argc: usize = 8;
|
||||
|
||||
|
||||
// Spawn GitCommandRunner
|
||||
// Increment pending tasks so the event loop knows to wait for this
|
||||
this.incrementPendingTasks(1);
|
||||
@@ -1874,6 +1874,7 @@ const string = []const u8;
|
||||
const std = @import("std");
|
||||
|
||||
const bun = @import("bun");
|
||||
const DotEnv = bun.DotEnv;
|
||||
const Environment = bun.Environment;
|
||||
const Output = bun.Output;
|
||||
const Path = bun.path;
|
||||
@@ -1893,13 +1894,12 @@ const DependencyID = bun.install.DependencyID;
|
||||
const ExtractTarball = bun.install.ExtractTarball;
|
||||
const Features = bun.install.Features;
|
||||
const FolderResolution = bun.install.FolderResolution;
|
||||
const GitCommandRunner = bun.install.GitCommandRunner;
|
||||
const Npm = bun.install.Npm;
|
||||
const PackageID = bun.install.PackageID;
|
||||
const PackageNameHash = bun.install.PackageNameHash;
|
||||
const PatchTask = bun.install.PatchTask;
|
||||
const Repository = bun.install.Repository;
|
||||
const GitCommandRunner = bun.install.GitCommandRunner;
|
||||
const DotEnv = bun.DotEnv;
|
||||
const Resolution = bun.install.Resolution;
|
||||
const Task = bun.install.Task;
|
||||
const TaskCallbackContext = bun.install.TaskCallbackContext;
|
||||
|
||||
@@ -298,7 +298,6 @@ const Npm = install.Npm;
|
||||
const PackageID = install.PackageID;
|
||||
const PackageManager = install.PackageManager;
|
||||
const PatchTask = install.PatchTask;
|
||||
const Repository = install.Repository;
|
||||
const Resolution = install.Resolution;
|
||||
const Task = install.Task;
|
||||
const invalid_package_id = install.invalid_package_id;
|
||||
|
||||
@@ -7,14 +7,14 @@ pub const GitCommandRunner = struct {
|
||||
stderr: OutputReader = OutputReader.init(@This()),
|
||||
has_called_process_exit: bool = false,
|
||||
remaining_fds: i8 = 0,
|
||||
|
||||
|
||||
task_id: Task.Id,
|
||||
operation: Operation,
|
||||
// For checkout, we need to run two commands
|
||||
checkout_phase: enum { clone, checkout } = .clone,
|
||||
|
||||
|
||||
heap: bun.io.heap.IntrusiveField(GitCommandRunner) = .{},
|
||||
|
||||
|
||||
pub const Operation = union(enum) {
|
||||
clone: struct {
|
||||
name: strings.StringOrTinyString,
|
||||
@@ -33,18 +33,18 @@ pub const GitCommandRunner = struct {
|
||||
target_dir: []const u8,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
pub const List = bun.io.heap.Intrusive(GitCommandRunner, *PackageManager, sortByTaskId);
|
||||
|
||||
|
||||
fn sortByTaskId(_: *PackageManager, a: *GitCommandRunner, b: *GitCommandRunner) bool {
|
||||
return a.task_id.get() < b.task_id.get();
|
||||
}
|
||||
|
||||
|
||||
pub const new = bun.TrivialNew(@This());
|
||||
|
||||
|
||||
pub const OutputReader = bun.io.BufferedReader;
|
||||
const uv = bun.windows.libuv;
|
||||
|
||||
|
||||
fn resetOutputFlags(output: *OutputReader, fd: bun.FileDescriptor) void {
|
||||
output.flags.nonblocking = true;
|
||||
output.flags.socket = true;
|
||||
@@ -55,30 +55,30 @@ pub const GitCommandRunner = struct {
|
||||
if (comptime Environment.allow_assert) {
|
||||
const flags = bun.sys.getFcntlFlags(fd).unwrap() catch @panic("Failed to get fcntl flags");
|
||||
bun.assertWithLocation(flags & bun.O.NONBLOCK != 0, @src());
|
||||
|
||||
|
||||
const stat = bun.sys.fstat(fd).unwrap() catch @panic("Failed to fstat");
|
||||
bun.assertWithLocation(std.posix.S.ISSOCK(stat.mode), @src());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn loop(this: *const GitCommandRunner) *bun.uws.Loop {
|
||||
return this.manager.event_loop.loop();
|
||||
}
|
||||
|
||||
|
||||
pub fn eventLoop(this: *const GitCommandRunner) *jsc.AnyEventLoop {
|
||||
return &this.manager.event_loop;
|
||||
}
|
||||
|
||||
|
||||
pub fn onReaderDone(this: *GitCommandRunner) void {
|
||||
bun.assert(this.remaining_fds > 0);
|
||||
this.remaining_fds -= 1;
|
||||
this.maybeFinished();
|
||||
}
|
||||
|
||||
|
||||
pub fn onReaderError(this: *GitCommandRunner, err: bun.sys.Error) void {
|
||||
bun.assert(this.remaining_fds > 0);
|
||||
this.remaining_fds -= 1;
|
||||
|
||||
|
||||
Output.prettyErrorln("<r><red>error<r>: Failed to read git output due to error <b>{d} {s}<r>", .{
|
||||
err.errno,
|
||||
@tagName(err.getErrno()),
|
||||
@@ -86,21 +86,21 @@ pub const GitCommandRunner = struct {
|
||||
Output.flush();
|
||||
this.maybeFinished();
|
||||
}
|
||||
|
||||
|
||||
fn maybeFinished(this: *GitCommandRunner) void {
|
||||
if (!this.has_called_process_exit or this.remaining_fds != 0)
|
||||
return;
|
||||
|
||||
|
||||
const process = this.process orelse return;
|
||||
this.handleExit(process.status);
|
||||
}
|
||||
|
||||
|
||||
fn ensureNotInHeap(this: *GitCommandRunner) void {
|
||||
if (this.heap.child != null or this.heap.next != null or this.heap.prev != null or this.manager.active_git_commands.root == this) {
|
||||
this.manager.active_git_commands.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn spawn(
|
||||
manager: *PackageManager,
|
||||
task_id: Task.Id,
|
||||
@@ -108,15 +108,15 @@ pub const GitCommandRunner = struct {
|
||||
operation: Operation,
|
||||
) void {
|
||||
// GitCommandRunner.spawn called
|
||||
|
||||
|
||||
const runner = bun.new(GitCommandRunner, .{
|
||||
.manager = manager,
|
||||
.task_id = task_id,
|
||||
.operation = operation,
|
||||
});
|
||||
|
||||
|
||||
runner.manager.active_git_commands.insert(runner);
|
||||
|
||||
|
||||
// Copy argv to a local array to avoid const issues
|
||||
var argv: [16]?[*:0]const u8 = undefined;
|
||||
var argc: usize = 0;
|
||||
@@ -126,9 +126,9 @@ pub const GitCommandRunner = struct {
|
||||
argc += 1;
|
||||
}
|
||||
argv[argc] = null; // Ensure null termination
|
||||
|
||||
|
||||
// Cache directory is manager.cache_directory_path
|
||||
|
||||
|
||||
runner.remaining_fds = 0;
|
||||
var env_map = Repository.shared_env.get(manager.allocator, manager.env);
|
||||
const envp = env_map.createNullDelimitedEnvMap(manager.allocator) catch |err| {
|
||||
@@ -159,12 +159,12 @@ pub const GitCommandRunner = struct {
|
||||
runner.deinit();
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
if (Environment.isWindows) {
|
||||
runner.stdout.source = .{ .pipe = bun.default_allocator.create(uv.Pipe) catch bun.outOfMemory() };
|
||||
runner.stderr.source = .{ .pipe = bun.default_allocator.create(uv.Pipe) catch bun.outOfMemory() };
|
||||
}
|
||||
|
||||
|
||||
const spawn_options = bun.spawn.SpawnOptions{
|
||||
.stdin = .ignore,
|
||||
.stdout = if (Environment.isPosix) .buffer else .{ .buffer = runner.stdout.source.?.pipe },
|
||||
@@ -175,7 +175,7 @@ pub const GitCommandRunner = struct {
|
||||
},
|
||||
.stream = false,
|
||||
};
|
||||
|
||||
|
||||
// About to spawn git process with argv[0]="{s}"
|
||||
if (comptime Environment.allow_assert) {
|
||||
log("Spawning git with argv[0]={s}, cwd={s}", .{ argv[0].?, manager.cache_directory_path });
|
||||
@@ -236,16 +236,16 @@ pub const GitCommandRunner = struct {
|
||||
runner.deinit();
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
// Git process spawned
|
||||
|
||||
|
||||
if (comptime Environment.isPosix) {
|
||||
if (spawned.stdout) |stdout| {
|
||||
if (!spawned.memfds[1]) {
|
||||
runner.stdout.setParent(runner);
|
||||
_ = bun.sys.setNonblocking(stdout);
|
||||
runner.remaining_fds += 1;
|
||||
|
||||
|
||||
resetOutputFlags(&runner.stdout, stdout);
|
||||
runner.stdout.start(stdout, true).unwrap() catch |err| {
|
||||
log("Failed to start stdout reader: {}", .{err});
|
||||
@@ -288,7 +288,7 @@ pub const GitCommandRunner = struct {
|
||||
runner.stderr.setParent(runner);
|
||||
_ = bun.sys.setNonblocking(stderr);
|
||||
runner.remaining_fds += 1;
|
||||
|
||||
|
||||
resetOutputFlags(&runner.stderr, stderr);
|
||||
runner.stderr.start(stderr, true).unwrap() catch |err| {
|
||||
log("Failed to start stderr reader: {}", .{err});
|
||||
@@ -392,14 +392,14 @@ pub const GitCommandRunner = struct {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const event_loop = &manager.event_loop;
|
||||
var process = spawned.toProcess(event_loop, false);
|
||||
|
||||
|
||||
bun.assertf(runner.process == null, "forgot to call `resetPolls`", .{});
|
||||
runner.process = process;
|
||||
process.setExitHandler(runner);
|
||||
|
||||
|
||||
switch (process.watchOrReap()) {
|
||||
.err => |err| {
|
||||
if (!process.hasExited())
|
||||
@@ -408,17 +408,17 @@ pub const GitCommandRunner = struct {
|
||||
.result => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn handleExit(this: *GitCommandRunner, status: bun.spawn.Status) void {
|
||||
log("Git command finished: task_id={d}, status={}", .{ this.task_id.get(), status });
|
||||
|
||||
|
||||
const stderr_text = this.stderr.finalBuffer().items;
|
||||
|
||||
|
||||
this.ensureNotInHeap();
|
||||
|
||||
|
||||
// Create a task with the result
|
||||
const task = this.manager.preallocated_resolve_tasks.get();
|
||||
|
||||
|
||||
switch (this.operation) {
|
||||
.clone => |clone| {
|
||||
task.* = Task{
|
||||
@@ -440,7 +440,7 @@ pub const GitCommandRunner = struct {
|
||||
.status = undefined,
|
||||
.err = null,
|
||||
};
|
||||
|
||||
|
||||
switch (status) {
|
||||
.exited => |exit| {
|
||||
if (exit.code == 0) {
|
||||
@@ -460,7 +460,7 @@ pub const GitCommandRunner = struct {
|
||||
task.err = error.GitCloneFailed;
|
||||
task.status = .fail;
|
||||
task.data = .{ .git_clone = bun.invalid_fd };
|
||||
|
||||
|
||||
if (stderr_text.len > 0) {
|
||||
task.log.addErrorFmt(null, logger.Loc.Empty, this.manager.allocator, "git clone failed: {s}", .{stderr_text}) catch {};
|
||||
}
|
||||
@@ -470,7 +470,7 @@ pub const GitCommandRunner = struct {
|
||||
task.err = error.GitCloneSignaled;
|
||||
task.status = .fail;
|
||||
task.data = .{ .git_clone = bun.invalid_fd };
|
||||
|
||||
|
||||
const signal_code = bun.SignalCode.from(signal);
|
||||
task.log.addErrorFmt(null, logger.Loc.Empty, this.manager.allocator, "git clone terminated by {}", .{
|
||||
signal_code.fmt(Output.enable_ansi_colors_stderr),
|
||||
@@ -495,7 +495,7 @@ pub const GitCommandRunner = struct {
|
||||
if (status == .exited and status.exited.code == 0) {
|
||||
// Now run the actual checkout command
|
||||
this.checkout_phase = .checkout;
|
||||
|
||||
|
||||
// Build checkout command: git -C <folder> checkout --quiet <resolved>
|
||||
const argv: [7]?[*:0]const u8 = .{
|
||||
"git",
|
||||
@@ -506,24 +506,24 @@ pub const GitCommandRunner = struct {
|
||||
bun.default_allocator.dupeZ(u8, checkout.resolved.slice()) catch unreachable,
|
||||
null,
|
||||
};
|
||||
|
||||
|
||||
// Spawn the checkout command
|
||||
this.has_called_process_exit = false;
|
||||
this.remaining_fds = 0;
|
||||
this.resetPolls();
|
||||
|
||||
|
||||
var env_map = Repository.shared_env.get(this.manager.allocator, this.manager.env);
|
||||
const envp = env_map.createNullDelimitedEnvMap(this.manager.allocator) catch |err| {
|
||||
log("Failed to create env map for checkout: {}", .{err});
|
||||
this.handleCheckoutError(error.EnvMapFailed);
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
if (Environment.isWindows) {
|
||||
this.stdout.source = .{ .pipe = bun.default_allocator.create(uv.Pipe) catch bun.outOfMemory() };
|
||||
this.stderr.source = .{ .pipe = bun.default_allocator.create(uv.Pipe) catch bun.outOfMemory() };
|
||||
}
|
||||
|
||||
|
||||
const spawn_options = bun.spawn.SpawnOptions{
|
||||
.stdin = .ignore,
|
||||
.stdout = if (Environment.isPosix) .buffer else .{ .buffer = this.stdout.source.?.pipe },
|
||||
@@ -534,19 +534,19 @@ pub const GitCommandRunner = struct {
|
||||
},
|
||||
.stream = false,
|
||||
};
|
||||
|
||||
|
||||
var spawn_result = bun.spawn.spawnProcess(&spawn_options, @constCast(@ptrCast(&argv)), envp) catch |err| {
|
||||
log("Failed to spawn git checkout: {}", .{err});
|
||||
this.handleCheckoutError(err);
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
var spawned = spawn_result.unwrap() catch |err| {
|
||||
log("Failed to unwrap git checkout spawn: {}", .{err});
|
||||
this.handleCheckoutError(err);
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
// Set up process monitoring
|
||||
if (comptime Environment.isPosix) {
|
||||
if (spawned.stdout) |stdout| {
|
||||
@@ -554,7 +554,7 @@ pub const GitCommandRunner = struct {
|
||||
this.stdout.setParent(this);
|
||||
_ = bun.sys.setNonblocking(stdout);
|
||||
this.remaining_fds += 1;
|
||||
|
||||
|
||||
resetOutputFlags(&this.stdout, stdout);
|
||||
this.stdout.start(stdout, true).unwrap() catch |err| {
|
||||
log("Failed to start stdout reader: {}", .{err});
|
||||
@@ -571,7 +571,7 @@ pub const GitCommandRunner = struct {
|
||||
this.stderr.setParent(this);
|
||||
_ = bun.sys.setNonblocking(stderr);
|
||||
this.remaining_fds += 1;
|
||||
|
||||
|
||||
resetOutputFlags(&this.stderr, stderr);
|
||||
this.stderr.start(stderr, true).unwrap() catch |err| {
|
||||
log("Failed to start stderr reader: {}", .{err});
|
||||
@@ -584,13 +584,13 @@ pub const GitCommandRunner = struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const event_loop = &this.manager.event_loop;
|
||||
var process = spawned.toProcess(event_loop, false);
|
||||
|
||||
|
||||
this.process = process;
|
||||
process.setExitHandler(this);
|
||||
|
||||
|
||||
switch (process.watchOrReap()) {
|
||||
.err => |err| {
|
||||
if (!process.hasExited())
|
||||
@@ -598,7 +598,7 @@ pub const GitCommandRunner = struct {
|
||||
},
|
||||
.result => {},
|
||||
}
|
||||
|
||||
|
||||
// Don't continue to the task creation yet
|
||||
return;
|
||||
} else {
|
||||
@@ -607,7 +607,7 @@ pub const GitCommandRunner = struct {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Second phase (actual checkout) completed
|
||||
task.* = Task{
|
||||
.package_manager = this.manager,
|
||||
@@ -630,7 +630,7 @@ pub const GitCommandRunner = struct {
|
||||
.status = undefined,
|
||||
.err = null,
|
||||
};
|
||||
|
||||
|
||||
switch (status) {
|
||||
.exited => |exit| {
|
||||
if (exit.code == 0) {
|
||||
@@ -639,10 +639,10 @@ pub const GitCommandRunner = struct {
|
||||
if (this.manager.getCacheDirectory().openDir(folder_name, .{})) |package_dir_const| {
|
||||
var package_dir = package_dir_const;
|
||||
defer package_dir.close();
|
||||
|
||||
|
||||
// Delete .git directory
|
||||
package_dir.deleteTree(".git") catch {};
|
||||
|
||||
|
||||
// Create .bun-tag file with resolved commit
|
||||
if (checkout.resolved.slice().len > 0) insert_tag: {
|
||||
const git_tag = package_dir.createFileZ(".bun-tag", .{ .truncate = true }) catch break :insert_tag;
|
||||
@@ -651,26 +651,24 @@ pub const GitCommandRunner = struct {
|
||||
package_dir.deleteFileZ(".bun-tag") catch {};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Read package.json if it exists
|
||||
if (bun.sys.File.readFileFrom(package_dir, "package.json", this.manager.allocator).unwrap()) |result| {
|
||||
const json_file, const json_buf = result;
|
||||
defer json_file.close();
|
||||
|
||||
|
||||
var json_path_buf: bun.PathBuffer = undefined;
|
||||
if (json_file.getPath(&json_path_buf).unwrap()) |json_path| {
|
||||
const FileSystem = @import("../fs.zig").FileSystem;
|
||||
if (FileSystem.instance.dirname_store.append(@TypeOf(json_path), json_path)) |ret_json_path| {
|
||||
task.data = .{
|
||||
.git_checkout = .{
|
||||
.url = checkout.url.slice(),
|
||||
.resolved = checkout.resolved.slice(),
|
||||
.json = .{
|
||||
.path = ret_json_path,
|
||||
.buf = json_buf,
|
||||
},
|
||||
}
|
||||
};
|
||||
task.data = .{ .git_checkout = .{
|
||||
.url = checkout.url.slice(),
|
||||
.resolved = checkout.resolved.slice(),
|
||||
.json = .{
|
||||
.path = ret_json_path,
|
||||
.buf = json_buf,
|
||||
},
|
||||
} };
|
||||
task.status = .success;
|
||||
} else |err| {
|
||||
task.err = err;
|
||||
@@ -685,12 +683,10 @@ pub const GitCommandRunner = struct {
|
||||
} else |err| {
|
||||
if (err == error.ENOENT) {
|
||||
// Allow git dependencies without package.json
|
||||
task.data = .{
|
||||
.git_checkout = .{
|
||||
.url = checkout.url.slice(),
|
||||
.resolved = checkout.resolved.slice(),
|
||||
}
|
||||
};
|
||||
task.data = .{ .git_checkout = .{
|
||||
.url = checkout.url.slice(),
|
||||
.resolved = checkout.resolved.slice(),
|
||||
} };
|
||||
task.status = .success;
|
||||
} else {
|
||||
task.err = err;
|
||||
@@ -707,7 +703,7 @@ pub const GitCommandRunner = struct {
|
||||
task.err = error.GitCheckoutFailed;
|
||||
task.status = .fail;
|
||||
task.data = .{ .git_checkout = .{} };
|
||||
|
||||
|
||||
if (stderr_text.len > 0) {
|
||||
task.log.addErrorFmt(null, logger.Loc.Empty, this.manager.allocator, "git checkout failed: {s}", .{stderr_text}) catch {};
|
||||
}
|
||||
@@ -717,7 +713,7 @@ pub const GitCommandRunner = struct {
|
||||
task.err = error.GitCheckoutSignaled;
|
||||
task.status = .fail;
|
||||
task.data = .{ .git_checkout = .{} };
|
||||
|
||||
|
||||
const signal_code = bun.SignalCode.from(signal);
|
||||
task.log.addErrorFmt(null, logger.Loc.Empty, this.manager.allocator, "git checkout terminated by {}", .{
|
||||
signal_code.fmt(Output.enable_ansi_colors_stderr),
|
||||
@@ -736,15 +732,15 @@ pub const GitCommandRunner = struct {
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
// Push the task to the resolve queue
|
||||
this.manager.resolve_tasks.push(task);
|
||||
// Don't decrement pending tasks here - runTasks will do it when processing the task
|
||||
this.manager.wake();
|
||||
|
||||
|
||||
this.deinit();
|
||||
}
|
||||
|
||||
|
||||
pub fn onProcessExit(this: *GitCommandRunner, proc: *Process, _: bun.spawn.Status, _: *const bun.spawn.Rusage) void {
|
||||
// onProcessExit called
|
||||
if (this.process != proc) {
|
||||
@@ -754,40 +750,40 @@ pub const GitCommandRunner = struct {
|
||||
this.has_called_process_exit = true;
|
||||
this.maybeFinished();
|
||||
}
|
||||
|
||||
|
||||
pub fn resetPolls(this: *GitCommandRunner) void {
|
||||
if (comptime Environment.allow_assert) {
|
||||
bun.assert(this.remaining_fds == 0);
|
||||
}
|
||||
|
||||
|
||||
if (this.process) |process| {
|
||||
this.process = null;
|
||||
process.close();
|
||||
process.deref();
|
||||
}
|
||||
|
||||
|
||||
this.stdout.deinit();
|
||||
this.stderr.deinit();
|
||||
this.stdout = OutputReader.init(@This());
|
||||
this.stderr = OutputReader.init(@This());
|
||||
}
|
||||
|
||||
|
||||
pub fn deinit(this: *GitCommandRunner) void {
|
||||
this.resetPolls();
|
||||
this.ensureNotInHeap();
|
||||
|
||||
|
||||
this.stdout.deinit();
|
||||
this.stderr.deinit();
|
||||
|
||||
|
||||
this.* = undefined;
|
||||
bun.destroy(this);
|
||||
}
|
||||
|
||||
|
||||
// Dummy callback for the task - we never actually call this
|
||||
fn dummyCallback(_: *ThreadPool.Task) void {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
|
||||
fn handleCheckoutError(this: *GitCommandRunner, err: anyerror) void {
|
||||
const task = this.manager.preallocated_resolve_tasks.get();
|
||||
task.* = Task{
|
||||
@@ -811,7 +807,7 @@ pub const GitCommandRunner = struct {
|
||||
.status = .fail,
|
||||
.err = err,
|
||||
};
|
||||
|
||||
|
||||
this.manager.resolve_tasks.push(task);
|
||||
this.manager.wake();
|
||||
this.deinit();
|
||||
@@ -820,21 +816,21 @@ pub const GitCommandRunner = struct {
|
||||
|
||||
var folder_name_buf: [1024]u8 = undefined;
|
||||
|
||||
const string = []const u8;
|
||||
const std = @import("std");
|
||||
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 Resolution = @import("./install.zig").Resolution;
|
||||
const Task = @import("./install.zig").Task;
|
||||
|
||||
const bun = @import("bun");
|
||||
const DotEnv = bun.DotEnv;
|
||||
const Environment = bun.Environment;
|
||||
const Output = bun.Output;
|
||||
const ThreadPool = bun.ThreadPool;
|
||||
const jsc = bun.jsc;
|
||||
const logger = bun.logger;
|
||||
const strings = bun.strings;
|
||||
const DotEnv = bun.DotEnv;
|
||||
const jsc = bun.jsc;
|
||||
const Process = bun.spawn.Process;
|
||||
const PackageManager = @import("./install.zig").PackageManager;
|
||||
const Task = @import("./install.zig").Task;
|
||||
const ThreadPool = bun.ThreadPool;
|
||||
const DependencyID = @import("./install.zig").DependencyID;
|
||||
const Resolution = @import("./install.zig").Resolution;
|
||||
const ExtractData = @import("./install.zig").ExtractData;
|
||||
const Path = bun.path;
|
||||
const Repository = @import("./repository.zig").Repository;
|
||||
@@ -720,7 +720,6 @@ const Path = bun.path;
|
||||
const logger = bun.logger;
|
||||
const strings = bun.strings;
|
||||
const File = bun.sys.File;
|
||||
const Output = bun.Output;
|
||||
|
||||
const Semver = bun.Semver;
|
||||
const GitSHA = String;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { spawnSync } from "bun";
|
||||
import { expect, test } from "bun:test";
|
||||
import { existsSync } from "fs";
|
||||
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
|
||||
import { join } from "path";
|
||||
import { existsSync } from "fs";
|
||||
|
||||
test("install github dependency", async () => {
|
||||
const dir = tempDirWithFiles("test-github-install", {
|
||||
@@ -25,11 +25,11 @@ test("install github dependency", async () => {
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stderr.toString()).not.toContain("error");
|
||||
|
||||
|
||||
// Check that the package was installed
|
||||
const packagePath = join(dir, "node_modules", "awesome-bun");
|
||||
expect(existsSync(packagePath)).toBe(true);
|
||||
|
||||
|
||||
// Should have README.md
|
||||
const readmePath = join(packagePath, "README.md");
|
||||
expect(existsSync(readmePath)).toBe(true);
|
||||
@@ -56,7 +56,7 @@ test("install git+https URL dependency", async () => {
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stderr.toString()).not.toContain("error");
|
||||
|
||||
|
||||
// Check that the package was installed
|
||||
const packagePath = join(dir, "node_modules", "awesome-bun");
|
||||
expect(existsSync(packagePath)).toBe(true);
|
||||
@@ -83,8 +83,8 @@ test("install git URL without commit hash", async () => {
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stderr.toString()).not.toContain("error");
|
||||
|
||||
|
||||
// Check that the package was installed
|
||||
const packagePath = join(dir, "node_modules", "awesome-bun-2");
|
||||
expect(existsSync(packagePath)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"!= alloc.ptr": 0,
|
||||
"!= allocator.ptr": 0,
|
||||
".arguments_old(": 279,
|
||||
".stdDir()": 40,
|
||||
".stdDir()": 39,
|
||||
".stdFile()": 18,
|
||||
"// autofix": 168,
|
||||
": [a-zA-Z0-9_\\.\\*\\?\\[\\]\\(\\)]+ = undefined,": 228,
|
||||
|
||||
Reference in New Issue
Block a user