ppkarwasz commented on code in PR #422:
URL: 
https://github.com/apache/commons-release-plugin/pull/422#discussion_r3119361917


##########
src/main/java/org/apache/commons/release/plugin/internal/GitUtils.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.release.plugin.internal;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.codec.digest.GitIdentifiers;
+
+/**
+ * Utilities for Git operations.
+ */
+public final class GitUtils {
+
+    /** The SCM URI prefix for Git repositories. */
+    private static final String SCM_GIT_PREFIX = "scm:git:";
+
+    /**
+     * Walks up the directory tree from {@code path} to find the {@code .git} 
directory.
+     *
+     * @param path A path inside the Git repository.
+     * @return The path to the {@code .git} directory (or file for worktrees).
+     * @throws IOException If no {@code .git} directory is found.
+     */
+    private static Path findGitDir(final Path path) throws IOException {
+        Path current = path.toAbsolutePath();
+        while (current != null) {
+            final Path candidate = current.resolve(".git");
+            if (Files.isDirectory(candidate)) {
+                return candidate;
+            }
+            if (Files.isRegularFile(candidate)) {
+                // git worktree: .git is a file containing "gitdir: 
/path/to/real/.git"
+                final String content = new 
String(Files.readAllBytes(candidate), StandardCharsets.UTF_8).trim();
+                if (content.startsWith("gitdir: ")) {
+                    return Paths.get(content.substring("gitdir: ".length()));

Review Comment:
   Fixed in 
https://github.com/apache/commons-release-plugin/pull/422/commits/9b008bc1777e6aad68bfdc662682c70cd1f7dd32



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to