Closed devcrocod closed 3 months ago
Probably, setting the permissions is done differently on MacOS.
This is the function that creates the pre-commit file:
// This task installs the pre-commit hook to the local machine the first time the project is built
// The pre-commit hook contains the command to run processKDocsMain before each commit
val installGitPreCommitHook by tasks.creating(Copy::class) {
doNotTrackState(/* reasonNotToTrackState = */ "Fails on TeamCity otherwise.")
val gitHooksDir = File(rootProject.rootDir, ".git/hooks")
if (gitHooksDir.exists()) {
from(File(rootProject.rootDir, "gradle/scripts/pre-commit"))
into(gitHooksDir)
fileMode = 755
} else {
logger.lifecycle("'.git/hooks' directory not found. Skipping installation of pre-commit hook.")
}
}
Could you try setting the permissions manually? Then maybe we can create a special case for MacOS.
To commit, I manually call chmod 755 .git/hooks/pre-commit
Even if I run .gradlew
through the terminal with sudo
, I still get a file like this: --wxrw--wx 1 Pavel.Gorgulov staff 156B Mar 4 13:51 pre-commit
so... looks like fileMode
doesn't work as expected on MacOS
@devcrocod can you try fileMode = 0b1011110011
It didn't help(
@devcrocod Okay, then we'll have to go manual:
val installGitPreCommitHook by tasks.creating(Copy::class) {
doNotTrackState(/* reasonNotToTrackState = */ "Fails on TeamCity otherwise.")
val gitHooksDir = File(rootProject.rootDir, ".git/hooks")
if (gitHooksDir.exists()) {
from(File(rootProject.rootDir, "gradle/scripts/pre-commit"))
into(gitHooksDir)
fileMode = 755
if (OSType.identify() == OSType.Mac) exec {
workingDir(gitHooksDir)
commandLine("chmod", "755", "pre-commit")
}
} else {
logger.lifecycle("'.git/hooks' directory not found. Skipping installation of pre-commit hook.")
}
}
Oh, if I remove fileMode
then the following permissions are set: -rw-r--r-- 1 Pavel.Gorgulov staff 156B Mar 5 14:23 pre-commit
yeah, it needs execute permission, so something like -rwx-r-xr-x, which, if my math is correct is 755
Can be reproduced on Linux sometimes too.
It didn't help( @Jolanrensen
@devcrocod can you try
fileMode = 0b1011110011
For us 0b111101101
worked :) so a literal translation of 7-5-5
In our case the rights were not correctly assigned for the start scripts to our projects.
After cloning the repository and trying to make local changes, I encountered a problem executing a commit due to limited access rights to the pre-commit file. This results in a
Permission denied
error and I can't commit:IDEA: IU-242.1737 macOS: 14.2.1 (23C71) git version 2.39.3 (Apple Git-145)