feat: enable comment filtering

This commit is contained in:
Ben Force 2024-03-15 12:43:33 -05:00
parent f0ad750d6c
commit 471ca9eae5
6 changed files with 27 additions and 0 deletions

View file

@ -186,6 +186,13 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider {
locations[filename].push(comment);
}
if (extras.selectedCode.length && this.options.filterComments) {
const toRemove = Object.keys(locations).filter(filename => !extras.selectedCode.find(selection => selection.filepath.endsWith(filename)) && filename !== "general");
for (const filepath of toRemove) {
delete locations[filepath];
}
}
const commentFormatter = async (comment: GitLabComment) => {
const commentLabel = comment.body.includes("```suggestion") ? 'Code Suggestion' : 'Comment';

View file

@ -151,6 +151,10 @@ You can specify the domain to communicate with by setting the `domain` parameter
}
```
#### Filtering Comments
If you select some code to be edited, you can have the context provider filter out comments for other files. To enable this feature, set `filterComments` to `true`.
### Jira Issues
Type '@jira' to reference the conversation in a Jira issue. Make sure to include your own [Atlassian API Token](https://id.atlassian.com/manage-profile/security/api-tokens).

View file

@ -1260,6 +1260,10 @@
"token": {
"type": "string",
"description": "Your private access token."
},
"filterComments": {
"type": "boolean",
"description": "If you have code selected, filters out comments that aren't related to the selection."
}
},
"required": ["token"]

View file

@ -1260,6 +1260,10 @@
"token": {
"type": "string",
"description": "Your private access token."
},
"filterComments": {
"type": "boolean",
"description": "If you have code selected, filters out comments that aren't related to the selection."
}
},
"required": ["token"]

View file

@ -1260,6 +1260,10 @@
"token": {
"type": "string",
"description": "Your private access token."
},
"filterComments": {
"type": "boolean",
"description": "If you have code selected, filters out comments that aren't related to the selection."
}
},
"required": ["token"]

View file

@ -1411,6 +1411,10 @@
"token": {
"type": "string",
"description": "Your private access token."
},
"filterComments": {
"type": "boolean",
"description": "If you have code selected, filters out comments that aren't related to the selection."
}
},
"required": [