Introduce `inlineCommentsAsResolved` option
Added the `inlineCommentsAsResolved` configuration setting to determine
if ChatGPT's inline comments should default to being marked as resolved.
Jira-Id: IT-103
Change-Id: I7f8bcff514697abca3cd3bc3fa992649fe019869
Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/README.md b/README.md
index 7902b8a..4a858e7 100644
--- a/README.md
+++ b/README.md
@@ -149,6 +149,8 @@
.sh, .vb, .bat".
- `enabledVoting`: Initially disabled (false). If set to true, allows ChatGPT to cast a vote on each reviewed Patch Set
by assigning a score.
+- `inlineCommentsAsResolved`: By default, this is set to false, meaning ChatGPT inline comments will be marked as
+ unresolved, inviting further discussion. When enabled, comments made by ChatGPT will be marked as resolved.
- `votingMinScore`: The lowest possible score that can be given to a Patch Set (Default value: -1).
- `votingMaxScore`: The highest possible score that can be given to a Patch Set (Default value: +1).
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/client/gerrit/GerritClientReview.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/client/gerrit/GerritClientReview.java
index c97cdfc..cb4bb7a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/client/gerrit/GerritClientReview.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/client/gerrit/GerritClientReview.java
@@ -83,6 +83,7 @@
filenameComment.setLine(reviewBatch.getLine());
filenameComment.setRange(reviewBatch.getRange());
filenameComment.setInReplyTo(reviewBatch.getId());
+ filenameComment.setUnresolved(!config.getInlineCommentsAsResolved());
filenameComments.add(filenameComment);
comments.putIfAbsent(filename, filenameComments);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
index b22aa2c..8c1df8f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
@@ -65,6 +65,7 @@
private static final boolean DEFAULT_ENABLED_VOTING = false;
private static final int DEFAULT_VOTING_MIN_SCORE = -1;
private static final int DEFAULT_VOTING_MAX_SCORE = 1;
+ private static final boolean DEFAULT_INLINE_COMMENTS_AS_RESOLVED = false;
// Config setting keys
public static final String KEY_GPT_SYSTEM_PROMPT = "gptSystemPrompt";
@@ -95,6 +96,7 @@
private static final String KEY_MAX_REVIEW_FILE_SIZE = "maxReviewFileSize";
private static final String KEY_ENABLED_FILE_EXTENSIONS = "enabledFileExtensions";
private static final String KEY_ENABLED_VOTING = "enabledVoting";
+ private static final String KEY_INLINE_COMMENTS_AS_RESOLVED = "inlineCommentsAsResolved";
@Getter
private final PluginConfig globalConfig;
@@ -206,6 +208,10 @@
return getInt(KEY_VOTING_MAX_SCORE, DEFAULT_VOTING_MAX_SCORE);
}
+ public boolean getInlineCommentsAsResolved() {
+ return getBoolean(KEY_INLINE_COMMENTS_AS_RESOLVED, DEFAULT_INLINE_COMMENTS_AS_RESOLVED);
+ }
+
public String getString(String key, String defaultValue) {
String value = projectConfig.getString(key);
if (value != null) {
diff --git a/src/test/resources/__files/chatGptExpectedResponseStreamed.json b/src/test/resources/__files/chatGptExpectedResponseStreamed.json
index 820a351..b7fd25c 100644
--- a/src/test/resources/__files/chatGptExpectedResponseStreamed.json
+++ b/src/test/resources/__files/chatGptExpectedResponseStreamed.json
@@ -1 +1 @@
-{"comments":{"test_file.py":[{"line":29,"range":{"start_line":29,"end_line":29,"start_character":4,"end_character":43},"message":"The change from unpacking kwargs as position arguments (\\*kwargs) to passing them as a single dictionary might cause issues if the receiving function expects individual keyword arguments rather than a single dictionary. Consider preserving the original method of passing \\**kwargs unless this behavior is intentional and the receiving function has been designed to accept a dictionary."}]},"message":"The commit message \u0027Minor Fixes\u0027 is too vague and does not provide enough context about the nature of the changes. A good commit message should explain what was changed and why. Consider specifying the components affected by the \u0027minor fixes\u0027 and briefly describe the nature of the fixes for clarity."}
\ No newline at end of file
+{"comments":{"test_file.py":[{"unresolved":true,"line":29,"range":{"start_line":29,"end_line":29,"start_character":4,"end_character":43},"message":"The change from unpacking kwargs as position arguments (\\*kwargs) to passing them as a single dictionary might cause issues if the receiving function expects individual keyword arguments rather than a single dictionary. Consider preserving the original method of passing \\**kwargs unless this behavior is intentional and the receiving function has been designed to accept a dictionary."}]},"message":"The commit message \u0027Minor Fixes\u0027 is too vague and does not provide enough context about the nature of the changes. A good commit message should explain what was changed and why. Consider specifying the components affected by the \u0027minor fixes\u0027 and briefly describe the nature of the fixes for clarity."}
\ No newline at end of file
diff --git a/src/test/resources/__files/gerritPatchSetReview.json b/src/test/resources/__files/gerritPatchSetReview.json
index 646f904..557da6f 100644
--- a/src/test/resources/__files/gerritPatchSetReview.json
+++ b/src/test/resources/__files/gerritPatchSetReview.json
@@ -1 +1 @@
-{"comments":{"test_file.py":[{"line":19,"range":{"start_line":19,"end_line":20,"start_character":4,"end_character":60},"message":"Confirm that the method \u0027importclass\u0027 is meant to change its behavior when \u0027class_name\u0027 is None. The new lines suggest \u0027class_name\u0027 will be derived from the \u0027module_name\u0027 in such cases, which can have unintended effects if not explicitly intended."},{"line":20,"range":{"start_line":20,"end_line":20,"start_character":8,"end_character":60},"message":"The added check to determine if \u0027class_name\u0027 is None seems to modify the \u0027module_name\u0027 by splitting it and taking the last element. There should be an assignment to \u0027class_name\u0027 since the class to be imported is meant to be the last part of \u0027module_name\u0027 after splitting. Additionally, it would be beneficial to include a comment like:\n\\# last element is..."},{"line":1,"range":{"start_line":1,"end_line":1,"start_character":0,"end_character":17},"message":"The code line \u0027from types import Any, Callable, ...\u0027 should use \u0027typing\u0027 for imports instead of \u0027types\u0027."},{"line":21,"range":{"start_line":21,"end_line":21,"start_character":4,"end_character":67},"message":"There is a typo in the import statement. The correct function should be \u0027\\__import\\__\u0027 from the \u0027importlib\u0027 module, not \u0027importclass\u0027 which does not exist. Correct code:\n\n```\nloaded_module \u003d import_module(module_name, fromlist\u003d[class_name])\n```\n"}]},"message":"The commit message \u0027Test Commit Message\u0027 is too vague and does not provide information about the specific changes made. A more detailed message is necessary to understand what has been fixed.","labels":{"Code-Review":-1}}
\ No newline at end of file
+{"comments":{"test_file.py":[{"unresolved":true,"line":19,"range":{"start_line":19,"end_line":20,"start_character":4,"end_character":60},"message":"Confirm that the method \u0027importclass\u0027 is meant to change its behavior when \u0027class_name\u0027 is None. The new lines suggest \u0027class_name\u0027 will be derived from the \u0027module_name\u0027 in such cases, which can have unintended effects if not explicitly intended."},{"unresolved":true,"line":20,"range":{"start_line":20,"end_line":20,"start_character":8,"end_character":60},"message":"The added check to determine if \u0027class_name\u0027 is None seems to modify the \u0027module_name\u0027 by splitting it and taking the last element. There should be an assignment to \u0027class_name\u0027 since the class to be imported is meant to be the last part of \u0027module_name\u0027 after splitting. Additionally, it would be beneficial to include a comment like:\n\\# last element is..."},{"unresolved":true,"line":1,"range":{"start_line":1,"end_line":1,"start_character":0,"end_character":17},"message":"The code line \u0027from types import Any, Callable, ...\u0027 should use \u0027typing\u0027 for imports instead of \u0027types\u0027."},{"unresolved":true,"line":21,"range":{"start_line":21,"end_line":21,"start_character":4,"end_character":67},"message":"There is a typo in the import statement. The correct function should be \u0027\\__import\\__\u0027 from the \u0027importlib\u0027 module, not \u0027importclass\u0027 which does not exist. Correct code:\n\n```\nloaded_module \u003d import_module(module_name, fromlist\u003d[class_name])\n```\n"}]},"message":"The commit message \u0027Test Commit Message\u0027 is too vague and does not provide information about the specific changes made. A more detailed message is necessary to understand what has been fixed.","labels":{"Code-Review":-1}}
\ No newline at end of file