From 9b6e587c266935d781f1a4ed8ea6f28a1732c990 Mon Sep 17 00:00:00 2001 From: Jacksgong Date: Thu, 18 Oct 2018 20:09:03 +0800 Subject: [PATCH] fix: fix ArrayIndexOutOfBoundsException issue when need-remove-commit-id count larger than 20 --- .../groovy/com/liulishuo/okcheck/util/ChangeFile.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/com/liulishuo/okcheck/util/ChangeFile.groovy b/src/main/groovy/com/liulishuo/okcheck/util/ChangeFile.groovy index eca8714..9d1e468 100644 --- a/src/main/groovy/com/liulishuo/okcheck/util/ChangeFile.groovy +++ b/src/main/groovy/com/liulishuo/okcheck/util/ChangeFile.groovy @@ -187,8 +187,10 @@ class ChangeFile { backupFile.createNewFile() - if (backupCommitIdList.size() + newCommitIds.size() >= 20) { - int needRemoveSize = backupCommitIdList.size() + newCommitIds.size() - 20 + int maxRemainCount = Math.max(30, newCommitIds.size()) + + if (backupCommitIdList.size() + newCommitIds.size() >= maxRemainCount) { + int needRemoveSize = backupCommitIdList.size() + newCommitIds.size() - maxRemainCount Util.printLog("will delete $needRemoveSize from origin count ${backupCommitIdList.size()} because count of new insert ${newCommitIds.size()}")