From 915ea20c434cd318c2c91c6d8949d03c7db7abbe Mon Sep 17 00:00:00 2001 From: Joan Goyeau Date: Wed, 13 Aug 2025 00:59:11 -0400 Subject: [PATCH] Add ability to customize Git root dir Fixes #120 --- mill-git/src/com/goyeau/mill/git/GitVersionModule.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala b/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala index ee1ef7d..57ba21d 100644 --- a/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala +++ b/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala @@ -17,9 +17,13 @@ object GitVersionModule extends ExternalModule { /** Version derived from git. */ - def version(hashLength: Int = 7, withSnapshotSuffix: Boolean = false): Command[String] = + def version( + hashLength: Int = 7, + withSnapshotSuffix: Boolean = false, + gitRoot: Path = workspaceRoot + ): Command[String] = Task.Command { - val git = Git.open(workspaceRoot.toIO) + val git = Git.open(gitRoot.toIO) val status = git.status().call() val isDirty = status.hasUncommittedChanges || !status.getUntracked.isEmpty val snapshotSuffix = if (withSnapshotSuffix) "-SNAPSHOT" else ""