forked from yardenshoham/gitea-backporter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor locking logic to check the last comment date
- Added `fetchLastComment` function to retrieve the last comment of an issue - Updated `run` function in `lock.ts` to use `fetchLastComment` to check the date of the last comment before adding a new comment - Improved logic to determine if there is an active discussion before adding a new comment Signed-off-by: Yarden Shoham <[email protected]>
- Loading branch information
1 parent
91b1ec2
commit 3094d3b
Showing
4 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { | ||
assertEquals, | ||
assertFalse, | ||
} from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { | ||
fetchBranch, | ||
fetchLastComment, | ||
fetchPr, | ||
fetchPrFileNames, | ||
getPrReviewers, | ||
|
@@ -117,3 +121,26 @@ Deno.test("fetchPrFileNames() can handle big PRs", async () => { | |
const aPrWith669Files = await fetchPrFileNames(24147); | ||
assertEquals(aPrWith669Files.size, 669); | ||
}); | ||
|
||
Deno.test("fetchLastComment() returns the appropriate comment", async () => { | ||
const prToLastComment = { | ||
10: "Closing as fixed by #199 ", | ||
29: null, | ||
1000: "LGTM", | ||
10000: | ||
"It is a feature of SQL databases. The repo id is stored in the database and uses auto increment:\r\nhttps://www.w3schools.com/sql/sql_autoincrement.asp", | ||
}; | ||
await Promise.all( | ||
Object.entries(prToLastComment).map( | ||
async ([issueNumber, comment]) => { | ||
const result = await fetchLastComment(Number(issueNumber)); | ||
if (comment === null) { | ||
assertFalse(result); | ||
return; | ||
} | ||
|
||
assertEquals(result.body, comment); | ||
}, | ||
), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters