Commit 843027ab authored by Brad King's avatar Brad King

Merge branch 'lfs-permission-bit'

4071f41d check_executable_permissions: ignore LFS pointer files
f3c76884 Merge branch 'lfs-permission-bit-test' into lfs-permission-bit
58b48684 check_executable_permissions: add LFS files with +x permissions

Merge-request: !129
parents 1a304132 4071f41d
......@@ -14,6 +14,7 @@
* The `Changelog` check now supports looking for a set of files for entries.
* The `CheckExecutablePermissions` check now detects binaries using the same
logic as the `RejectBinaries` check.
* The `CheckExecutablePermissions` now ignore LFS-tracked files.
* The `Formatting` check now passes the value of the formatting attribute to
the formatter if set. Previously, a formatting attribute with a value was
ignored.
......
......@@ -63,6 +63,16 @@ impl ContentCheck for CheckExecutablePermissions {
_ => continue,
};
// LFS pointer files are defined as per its spec to have the same permission bit as the
// content it points to. Since this check can only access the pointer content, it is
// likely to be wrong here. Just ignore files specified to use the `lfs` filter.
let filter_attr = ctx.check_attr("filter", diff.name.as_path())?;
if let AttributeState::Value(filter_name) = filter_attr {
if filter_name == "lfs" {
continue;
}
}
let executable_ext =
self.extensions.iter().any(|ext| diff.name.as_str().ends_with(ext));
let looks_executable = if executable_ext {
......@@ -115,6 +125,7 @@ mod tests {
const BAD_TOPIC: &str = "6ad8d4932466efc57ecccd3c80def3737b5d7e9a";
const BINARY_TOPIC: &str = "f5fd493ca51556d6cd0c42dfc8003925d77441f3";
const FIX_TOPIC: &str = "bea46a67f75380f1c17c25c7f89ffa9f47b27c06";
const LFS_TOPIC: &str = "58b4868402bf3f2e6160af345052c812f4cbe36f";
#[test]
fn test_check_executable_permissions() {
......@@ -167,4 +178,12 @@ mod tests {
let check = CheckExecutablePermissions::new(&[".exe"]);
run_topic_check_ok("test_check_executable_permissions_topic_fixed", FIX_TOPIC, check);
}
#[test]
fn test_check_executable_permissions_lfs() {
let check = CheckExecutablePermissions::new(&[".lfs"]);
let conf = make_check_conf(&check);
let result = test_check_base("test_check_executable_permissions_lfs", LFS_TOPIC, BAD_TOPIC, &conf);
test_result_ok(result);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment