Skip to content

Commit

Permalink
Fix IndexOutOfBoundsException when the commit is the initial
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Apr 4, 2024
1 parent 6d6b7eb commit 1cc7eea
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ private ChangedFileInfo populateWithGitHubAPI(File projectFolder, String cloneUR
GHRepository repository = getGitHubRepository(cloneURL);
List<GHCommit.File> commitFiles = new ArrayList<>();
GHCommit commit = new GHRepositoryWrapper(repository).getCommit(currentCommitId, commitFiles);
String parentCommitId = commit.getParents().get(0).getSHA1();
//if parents.size() == 0 then currentCommit is the initial commit of the repository, but then all files will have an ADDED status
String parentCommitId = commit.getParents().size() > 0 ? commit.getParents().get(0).getSHA1() : null;
List<String> filesBefore = new ArrayList<String>();
List<String> filesCurrent = new ArrayList<String>();
Map<String, String> renamedFilesHint = new HashMap<String, String>();
Expand Down Expand Up @@ -896,7 +897,8 @@ private void populateWithGitHubAPI(String cloneURL, String currentCommitId, List
logger.info("Processing {} {} ...", cloneURL, commitId);
List<GHCommit.File> commitFiles = new ArrayList<>();
GHCommit currentCommit = new GHRepositoryWrapper(repository).getCommit(commitId, commitFiles);
final String parentCommitId = currentCommit.getParents().get(0).getSHA1();
//if parents.size() == 0 then currentCommit is the initial commit of the repository, but then all files will have an ADDED status
final String parentCommitId = currentCommit.getParents().size() > 0 ? currentCommit.getParents().get(0).getSHA1() : null;
Set<String> deletedAndRenamedFileParentDirectories = ConcurrentHashMap.newKeySet();
ExecutorService pool = Executors.newFixedThreadPool(commitFiles.size());
for (GHCommit.File commitFile : commitFiles) {
Expand Down Expand Up @@ -1182,7 +1184,8 @@ public ChangedFileInfo populateWithGitHubAPIAndSaveFiles(String cloneURL, String
final String commitId = repository.queryCommits().from(currentCommitId).list().iterator().next().getSHA1();
List<GHCommit.File> commitFiles = new ArrayList<>();
GHCommit currentCommit = new GHRepositoryWrapper(repository).getCommit(commitId, commitFiles);
final String parentCommitId = currentCommit.getParents().get(0).getSHA1();
//if parents.size() == 0 then currentCommit is the initial commit of the repository, but then all files will have an ADDED status
final String parentCommitId = currentCommit.getParents().size() > 0 ? currentCommit.getParents().get(0).getSHA1() : null;
Set<String> deletedAndRenamedFileParentDirectories = ConcurrentHashMap.newKeySet();
List<String> commitFileNames = new ArrayList<>();
ExecutorService pool = Executors.newFixedThreadPool(commitFiles.size());
Expand Down

0 comments on commit 1cc7eea

Please sign in to comment.