diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig index 96018851ce47e19ede2a6855eb6dad6a07745527..a9cc86b398ef5ee6d3d83835f41f556ade34782e 100644 --- a/src/Package/Fetch.zig +++ b/src/Package/Fetch.zig @@ -60,8 +60,6 @@ omit_missing_hash_error: bool, /// which specifies inclusion rules. This is intended to be true for the first /// fetch task and false for the recursive dependencies. allow_missing_paths_field: bool, -allow_missing_fingerprint: bool, -allow_name_string: bool, /// If true and URL points to a Git repository, will use the latest commit. use_latest_commit: bool, @@ -675,8 +673,6 @@ fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void { f.manifest = try Manifest.parse(arena, ast.*, rng.interface(), .{ .allow_missing_paths_field = f.allow_missing_paths_field, - .allow_missing_fingerprint = f.allow_missing_fingerprint, - .allow_name_string = f.allow_name_string, }); const manifest = &f.manifest.?; @@ -794,8 +790,6 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { .job_queue = f.job_queue, .omit_missing_hash_error = false, .allow_missing_paths_field = true, - .allow_missing_fingerprint = true, - .allow_name_string = true, .use_latest_commit = false, .package_root = undefined, @@ -2049,130 +2043,6 @@ const UnpackResult = struct { } }; -test "tarball with duplicate paths" { - // This tarball has duplicate path 'dir1/file1' to simulate case sensitve - // file system on any file sytstem. - // - // duplicate_paths/ - // duplicate_paths/dir1/ - // duplicate_paths/dir1/file1 - // duplicate_paths/dir1/file1 - // duplicate_paths/build.zig.zon - // duplicate_paths/src/ - // duplicate_paths/src/main.zig - // duplicate_paths/src/root.zig - // duplicate_paths/build.zig - // - - const gpa = std.testing.allocator; - const io = std.testing.io; - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - - const tarball_name = "duplicate_paths.tar.gz"; - try saveEmbedFile(io, tarball_name, tmp.dir); - const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name }); - defer gpa.free(tarball_path); - - // Run tarball fetch, expect to fail - var fb: TestFetchBuilder = undefined; - var fetch = try fb.build(gpa, io, tmp.dir, tarball_path); - defer fb.deinit(); - try std.testing.expectError(error.FetchFailed, fetch.run()); - - try fb.expectFetchErrors(1, - \\error: unable to unpack tarball - \\ note: unable to create file 'dir1/file1': PathAlreadyExists - \\ - ); -} - -test "tarball with excluded duplicate paths" { - // Same as previous tarball but has build.zig.zon wich excludes 'dir1'. - // - // .paths = .{ - // "build.zig", - // "build.zig.zon", - // "src", - // } - // - - const gpa = std.testing.allocator; - const io = std.testing.io; - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - - const tarball_name = "duplicate_paths_excluded.tar.gz"; - try saveEmbedFile(io, tarball_name, tmp.dir); - const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name }); - defer gpa.free(tarball_path); - - // Run tarball fetch, should succeed - var fb: TestFetchBuilder = undefined; - var fetch = try fb.build(gpa, io, tmp.dir, tarball_path); - defer fb.deinit(); - try fetch.run(); - - const hex_digest = Package.multiHashHexDigest(fetch.computed_hash.digest); - try std.testing.expectEqualStrings( - "12200bafe035cbb453dd717741b66e9f9d1e6c674069d06121dafa1b2e62eb6b22da", - &hex_digest, - ); - - const expected_files: []const []const u8 = &.{ - "build.zig", - "build.zig.zon", - "src/main.zig", - "src/root.zig", - }; - try fb.expectPackageFiles(expected_files); -} - -test "tarball without root folder" { - // Tarball with root folder. Manifest excludes dir1 and dir2. - // - // build.zig - // build.zig.zon - // dir1/ - // dir1/file2 - // dir1/file1 - // dir2/ - // dir2/file2 - // src/ - // src/main.zig - // - - const gpa = std.testing.allocator; - const io = std.testing.io; - - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - - const tarball_name = "no_root.tar.gz"; - try saveEmbedFile(io, tarball_name, tmp.dir); - const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name }); - defer gpa.free(tarball_path); - - // Run tarball fetch, should succeed - var fb: TestFetchBuilder = undefined; - var fetch = try fb.build(gpa, io, tmp.dir, tarball_path); - defer fb.deinit(); - try fetch.run(); - - const hex_digest = Package.multiHashHexDigest(fetch.computed_hash.digest); - try std.testing.expectEqualStrings( - "12209f939bfdcb8b501a61bb4a43124dfa1b2848adc60eec1e4624c560357562b793", - &hex_digest, - ); - - const expected_files: []const []const u8 = &.{ - "build.zig", - "build.zig.zon", - "src/main.zig", - }; - try fb.expectPackageFiles(expected_files); -} - test "set executable bit based on file content" { if (!Io.File.Permissions.has_executable_bit) return error.SkipZigTest; const gpa = std.testing.allocator; @@ -2288,8 +2158,6 @@ const TestFetchBuilder = struct { .job_queue = &self.job_queue, .omit_missing_hash_error = true, .allow_missing_paths_field = false, - .allow_missing_fingerprint = true, // so we can keep using the old testdata .tar.gz - .allow_name_string = true, // so we can keep using the old testdata .tar.gz .use_latest_commit = true, .package_root = undefined, diff --git a/src/Package/Fetch/testdata/duplicate_paths.tar.gz b/src/Package/Fetch/testdata/duplicate_paths.tar.gz deleted file mode 100644 index 118a934c1b03d764e4854f9aeb60ed684467caad..0000000000000000000000000000000000000000 Binary files a/src/Package/Fetch/testdata/duplicate_paths.tar.gz and /dev/null differ diff --git a/src/Package/Fetch/testdata/duplicate_paths_excluded.tar.gz b/src/Package/Fetch/testdata/duplicate_paths_excluded.tar.gz deleted file mode 100644 index 760b37cd40fe43e0907f14943a33ae8341f2f649..0000000000000000000000000000000000000000 Binary files a/src/Package/Fetch/testdata/duplicate_paths_excluded.tar.gz and /dev/null differ diff --git a/src/Package/Fetch/testdata/no_root.tar.gz b/src/Package/Fetch/testdata/no_root.tar.gz deleted file mode 100644 index a3a4baf40fd1d6b2bd101ee59f27f88c6a61f97f..0000000000000000000000000000000000000000 Binary files a/src/Package/Fetch/testdata/no_root.tar.gz and /dev/null differ diff --git a/src/Package/Manifest.zig b/src/Package/Manifest.zig index a8bc8b501384a01c782719602c321bb7d4525818..e66a78ae14b7c93bd233fe9327e6631b82702170 100644 --- a/src/Package/Manifest.zig +++ b/src/Package/Manifest.zig @@ -49,10 +49,6 @@ arena_state: std.heap.ArenaAllocator.State, pub const ParseOptions = struct { allow_missing_paths_field: bool = false, - /// Deprecated, to be removed after 0.14.0 is tagged. - allow_name_string: bool = true, - /// Deprecated, to be removed after 0.14.0 is tagged. - allow_missing_fingerprint: bool = true, }; pub const Error = Allocator.Error; @@ -77,8 +73,6 @@ pub fn parse(gpa: Allocator, ast: Ast, rng: std.Random, options: ParseOptions) E .dependencies_node = .none, .paths = .{}, .allow_missing_paths_field = options.allow_missing_paths_field, - .allow_name_string = options.allow_name_string, - .allow_missing_fingerprint = options.allow_missing_fingerprint, .minimum_zig_version = null, .buf = .{}, }; @@ -151,8 +145,6 @@ const Parse = struct { dependencies_node: Ast.Node.OptionalIndex, paths: std.StringArrayHashMapUnmanaged(void), allow_missing_paths_field: bool, - allow_name_string: bool, - allow_missing_fingerprint: bool, minimum_zig_version: ?std.SemanticVersion, const InnerError = error{ ParseFailure, OutOfMemory }; @@ -221,12 +213,10 @@ const Parse = struct { }); } p.id = n.id; - } else if (!p.allow_missing_fingerprint) { + } else { try appendError(p, main_token, "missing top-level 'fingerprint' field; suggested value: 0x{x}", .{ Package.Fingerprint.generate(rng, p.name).int(), }); - } else { - p.id = 0; } } @@ -395,19 +385,6 @@ const Parse = struct { const ast = p.ast; const main_token = ast.nodeMainToken(node); - if (p.allow_name_string and ast.nodeTag(node) == .string_literal) { - const name = try parseString(p, node); - if (!std.zig.isValidId(name)) - return fail(p, main_token, "name must be a valid bare zig identifier (hint: switch from string to enum literal)", .{}); - - if (name.len > max_name_len) - return fail(p, main_token, "name '{f}' exceeds max length of {d}", .{ - std.zig.fmtId(name), max_name_len, - }); - - return name; - } - if (ast.nodeTag(node) != .enum_literal) return fail(p, main_token, "expected enum literal", .{}); @@ -606,7 +583,8 @@ test "basic" { const example = \\.{ - \\ .name = "foo", + \\ .name = .foo, + \\ .fingerprint = 0x8c736521490b23df, \\ .version = "3.2.1", \\ .paths = .{""}, \\ .dependencies = .{ @@ -656,7 +634,8 @@ test "minimum_zig_version" { const example = \\.{ - \\ .name = "foo", + \\ .name = .foo, + \\ .fingerprint = 0x8c736521490b23df, \\ .version = "3.2.1", \\ .paths = .{""}, \\ .minimum_zig_version = "0.11.1", @@ -690,7 +669,8 @@ test "minimum_zig_version - invalid version" { const example = \\.{ - \\ .name = "foo", + \\ .name = .foo, + \\ .fingerprint = 0x8c736521490b23df, \\ .version = "3.2.1", \\ .minimum_zig_version = "X.11.1", \\ .paths = .{""}, diff --git a/src/main.zig b/src/main.zig index 02a49ef3e04aab0c27981d373dc3924192387927..4ef99de0aee390d513ca7cea2948aeaf8e163645 100644 --- a/src/main.zig +++ b/src/main.zig @@ -5285,8 +5285,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, .job_queue = &job_queue, .omit_missing_hash_error = true, .allow_missing_paths_field = false, - .allow_missing_fingerprint = false, - .allow_name_string = false, .use_latest_commit = false, .package_root = undefined, @@ -7044,8 +7042,6 @@ fn cmdFetch( .job_queue = &job_queue, .omit_missing_hash_error = true, .allow_missing_paths_field = false, - .allow_missing_fingerprint = true, - .allow_name_string = true, .use_latest_commit = true, .package_root = undefined,