Skip to content

Commit aedbb98

Browse files
committed
Fix debug message
1 parent 6d264ce commit aedbb98

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>javiergs</groupId>
88
<artifactId>tulip</artifactId>
9-
<version>v2.0</version>
9+
<version>v2.2</version>
1010

1111
<name>TULIP</name>
1212
<description>Teaching Utilities for Learning Individual Practices</description>

src/main/java/javiergs/tulip/GitHubHandler.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,25 @@ public List<String> listFolders(String owner, String repo, String branch, String
196196
* @throws IOException if the API call fails or the response cannot be decoded
197197
* @throws IllegalArgumentException if the URL does not point to a directory
198198
*/
199+
//public List<String> listFilesRecursive(String startDirUrl) throws IOException {
200+
// URLHelper u = URLHelper.parseGitHubUrl(startDirUrl);
201+
// if (u.isBlob) throw new IllegalArgumentException("URL points to a file, not a directory: " + startDirUrl);
202+
// return listFilesRecursive(u.owner, u.repo, u.ref, u.path);
203+
//}
204+
199205
public List<String> listFilesRecursive(String startDirUrl) throws IOException {
200206
URLHelper u = URLHelper.parseGitHubUrl(startDirUrl);
201-
if (u.isBlob) throw new IllegalArgumentException("URL points to a file, not a directory: " + startDirUrl);
207+
208+
// If the user just gave "https://github.com/owner/repo" (no /tree/ or /blob/)
209+
// assume branch "main" at repo root.
210+
if (!u.isBlob && (u.ref == null || u.ref.isBlank())) {
211+
return listFilesRecursive(u.owner, u.repo, "main", "");
212+
}
213+
214+
if (u.isBlob) {
215+
throw new IllegalArgumentException("URL points to a file, not a directory: " + startDirUrl);
216+
}
217+
202218
return listFilesRecursive(u.owner, u.repo, u.ref, u.path);
203219
}
204220

0 commit comments

Comments
 (0)