Skip to content

Commit

Permalink
Added labels to comment of duplicated issues (#52)
Browse files Browse the repository at this point in the history
* ADded labels to duplicated issues

* Added maxDuplicatedReports parameter for control max duplicated reports

* Fixed max reports issue

* updated changelog

* minor fix

* updated changelog
  • Loading branch information
M97Chahboun authored Apr 1, 2024
1 parent 04ec259 commit 03fdbc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@
* handled duplicated issues by add (+1) as comment on duplicated issues

## 0.0.16
* Added onReport callback for handle api integrations
* Fixed duplicated issues caused by pagination with using search api

## 0.0.17
* Fixed report manually issue (hotfix)

## 0.0.17
## 0.0.18
* Added maxDuplicatedReports parameter for over control on duplicated reports count
* Added labels to duplicated reports comment
* Added onReport callback parameter for handle api integrations
11 changes: 8 additions & 3 deletions lib/src/utils/github_snitch_instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GhSnitchInstance {
ConnectivityResult connectivity = await Connectivity().checkConnectivity();
if (!(connectivity == ConnectivityResult.none)) {
String issueEndpoint = "$owner/$repo/issues";
bool alreadyReported = await isAlreadyReported(body);
bool alreadyReported = await isAlreadyReported(body, labels);
if (alreadyReported) {
log("✅ Issue Already Reported");
return true;
Expand Down Expand Up @@ -216,7 +216,7 @@ class GhSnitchInstance {

/// Checks if an issue with a similar `body` has already been reported in the repository.
/// It takes the `body` as required parametes.
Future<bool> isAlreadyReported(String body) async {
Future<bool> isAlreadyReported(String body, List<String>? labels) async {
bool isDuplicated = false;
body = body
.replaceAll("```", "")
Expand All @@ -231,8 +231,13 @@ class GhSnitchInstance {
if (isDuplicated) {
final comments = ghResponse.response["items"].first["comments"];
if (comments < maxDuplicatedReports) {
String labelsContent = "";
if (labels != null) {
labelsContent = "Labels: ${labels.join(", ")}";
}
await submitComment(
ghResponse.response['items'][0][issueNumber].toString(), "+1");
ghResponse.response['items'][0][issueNumber].toString(),
"+1\n$labelsContent");
}
}
}
Expand Down

0 comments on commit 03fdbc1

Please sign in to comment.