Skip to content

[Suggestion] Make running "git" command in build.gradle support composite build #10122

@tmvkrpxl0

Description

@tmvkrpxl0

Hello. I recently tried to include Create mod's source using includeBuild with configuration cache enabled. but it failed to configure Create project because it was trying to run git command. but my root project does not have git configured.
I think the git command was launched from my project, not from Create.
Below is my suggestion for tweaking build.gradle so that git command always runs from create's directory:

--- a/build.gradle	(revision 0a17a7243c3e5e6e3ceb34450d9c6df240af1b83)
+++ b/build.gradle	(date 1775295971648)
@@ -313,6 +313,7 @@
 String calculateGitHash() {
     try {
         ExecOutput output = providers.exec {
+            it.workingDir(project.projectDir)
             commandLine("git", "rev-parse", "HEAD")
         }
         return output.standardOutput.asText.get().trim()
@@ -323,7 +324,9 @@
 
 boolean hasUnstaged() {
     try {
+        var projectDir = project.projectDir
         ExecOutput output = providers.exec {
+            it.workingDir(projectDir.path)
             commandLine("git", "status", "--porcelain")
         }
         String result = output.standardOutput.asText.get().replace("/M gradlew(\\.bat)?/", "").trim()

Above change indeed fixed the issue for me now.
This could be PR on my end but seeing that this only changes 3 lines I figured maintainers doing it manually would've be more easy

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