Skip to content

Missing bazel-diff support for change executable bit of files #325

@lukasmi93

Description

@lukasmi93

I have noticed that the change of an executable bit for a file included in a filegroup is not detected by bazel-diff. This has made it a bit challenging to accurately track certain changes.

The simple change in the SourceFileHasher.kt file can fix this behavior:

val isExecutable =
    try {
            java.nio.file.Files.getPosixFilePermissions(absoluteFilePath).let { perms ->
            perms.contains(java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE) ||
            perms.contains(java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE) ||
            perms.contains(java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE)
          }
        } catch (_: Exception) {
          // Fallback for non-POSIX filesystems.
          file.canExecute()
        }
putBytes(byteArrayOf(if (isExecutable) 0x01 else 0x00))

I'm curious to know if there are any planned improvements or updates that might address this behavior in the near future.

Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions