Open henrik242 opened 7 months ago
@n0mer Is there a way to exclude .git/fsmonitor--daemon.ipc
in the current implementation?
I have worked around this by ditching this plugin and using an Exec task with a bash script instead.
Bash script:
#!/usr/bin/env bash
# Replacement for the gradle-git-properties plugin since it clashes with git.fsmonitor,
# see https://github.com/n0mer/gradle-git-properties/issues/230
branch=$(git branch --show-current)
host=$(hostname)
user_email=$(git config user.email)
user_name=$(git config user.name)
version="1.0.0-SNAPSHOT"
describe=$(git describe --tags --long)
closest_tag_name=$(git describe --tags)
closest_tag_commit_count=$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count)
commit_id=$(git rev-parse HEAD)
commit_id_abbrev=$(git rev-parse --short HEAD)
commit_message_full=$(git log -1 --pretty=%B | cut -c1-100 | jq -Rsa)
commit_message_short=$(git log -1 --pretty=%s)
commit_time=$(git log -1 --date=format-local:%Y-%m-%dT%H:%M:%S%z --pretty=format:%cd)
commit_user_email=$(git log -1 --pretty=%ce)
commit_user_name=$(git log -1 --pretty=%cn)
dirty=$(git diff-index --quiet HEAD -- || echo "true")
[ -z "$dirty" ] && dirty="false"
remote_origin_url=$(git config --get remote.origin.url)
tags=$(git tag --points-at HEAD)
total_commit_count=$(git rev-list --count HEAD)
cat <<EOL > git.properties
git.branch=${branch}
git.build.host=${host}
git.build.user.email=${user_email}
git.build.user.name=${user_name}
git.build.version=${version}
git.closest.tag.commit.count=${closest_tag_commit_count}
git.closest.tag.name=${closest_tag_name}
git.commit.id=${commit_id}
git.commit.id.abbrev=${commit_id_abbrev}
git.commit.id.describe=${describe}
git.commit.message.full=${commit_message_full}
git.commit.message.short=${commit_message_short}
git.commit.time=${commit_time}
git.commit.user.email=${commit_user_email}
git.commit.user.name=${commit_user_name}
git.dirty=${dirty}
git.remote.origin.url=${remote_origin_url}
git.tags=${tags}
git.total.commit.count=${total_commit_count}
EOL
Gradle task:
val generateGitProperties by tasks.registering(Exec::class) {
description = "Generates git.properties file with git information"
group = "Build"
workingDir = project.layout.buildDirectory.dir("resources/main").get().asFile
outputs.file(project.layout.buildDirectory.file("resources/main/git.properties"))
commandLine("$rootDir/tools/utils/generate-git-properties.sh")
}
named("assemble") { dependsOn(generateGitProperties) }
The
generateGitProperties
task will fail if.git/config
containscore.fsmonitor = true
:The error is:
Should be solved by ignoring
.git/fsmonitor--daemon.ipc
(or generally all sockets) by default.