File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/main/java/pl/project13/core Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -102,9 +102,16 @@ public void prepareGitToExtractMoreDetailedRepoInformation() throws GitCommitIdE
102102 private RevCommit getCommitFromModuleDirectory (File moduleBaseDir ) throws GitAPIException , GitCommitIdExecutionException {
103103 //retrieve last commit in folder moduleBaseDir
104104 try (Git gitInstance = new Git (git )) {
105- String relativePath = git .getDirectory ().getParentFile ().toPath ().relativize (moduleBaseDir .getAbsoluteFile ().toPath ()).toString ();
106- Iterator <RevCommit > iterator = gitInstance .log ()
107- .addPath (relativePath ).call ().iterator ();
105+ String relativePath = git .getDirectory ().getParentFile ().getAbsoluteFile ().toPath ().relativize (moduleBaseDir .getAbsoluteFile ().toPath ()).toString ();
106+ Iterator <RevCommit > iterator ;
107+ if (relativePath .trim ().isEmpty ()) {
108+ // if the relative path is empty, we are in the root of the repository
109+ iterator = gitInstance .log ().call ().iterator ();
110+ } else {
111+ // otherwise, we need to specify the path to get commits for that specific directory
112+ iterator = gitInstance .log ()
113+ .addPath (relativePath ).call ().iterator ();
114+ }
108115 if (!iterator .hasNext ()) {
109116 throw new GitCommitIdExecutionException (
110117 "Could not get commit from folder " + relativePath + " , are you sure you have some " +
You can’t perform that action at this time.
0 commit comments