Modified behavior: score persists through replies
Comment requests to ChatGPT and their replies may not always pertain to
voting. As a result, the score is no longer automatically cleared after
each reply from ChatGPT. Instead, it will only be reset if the ChatGPT
response includes a `score` field.
Change-Id: I9b1a571726f3e066c4ad7f010d7c9b3ea82a27a2
Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java
index 47715d5..383ad68 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java
@@ -78,7 +78,7 @@
retrieveReviewBatches(reviewReply, change);
}
- clientReviewProvider.get().setReview(change, reviewBatches, changeSetData, getReviewScore());
+ clientReviewProvider.get().setReview(change, reviewBatches, changeSetData, getReviewScore(change));
}
private void setCommentBatchMap(ReviewBatch batchMap, Integer batchID) {
@@ -121,6 +121,7 @@
boolean isIrrelevant = isIrrelevantReply(replyItem);
boolean isHidden = replyItem.isRepeated() || replyItem.isConflicting() || isIrrelevant || isNotNegative;
if (!replyItem.isConflicting() && !isIrrelevant && score != null) {
+ log.debug("Score added: {}", score);
reviewScores.add(score);
}
if (changeSetData.getReplyFilterEnabled() && isHidden) {
@@ -150,9 +151,11 @@
return chatGptClient.ask(changeSetData, change, patchSet);
}
- private Integer getReviewScore() {
+ private Integer getReviewScore(GerritChange change) {
if (config.isVotingEnabled()) {
- return reviewScores.isEmpty() ? 0 : Collections.min(reviewScores);
+ return reviewScores.isEmpty() ?
+ (change.getIsCommentEvent() ? null : 0) :
+ Collections.min(reviewScores);
}
else {
return null;