File tree Expand file tree Collapse file tree 2 files changed +43
-6
lines changed
Expand file tree Collapse file tree 2 files changed +43
-6
lines changed Original file line number Diff line number Diff line change @@ -362,5 +362,34 @@ describe('Handler Functions', () => {
362362 expect ( result . recentReleases [ 0 ] ) . toHaveProperty ( 'tag' ) ;
363363 expect ( result . recentReleases [ 0 ] ) . toHaveProperty ( 'date' ) ;
364364 } ) ;
365+
366+ it ( 'should filter releases by date range' , ( ) => {
367+ // Create a tag in the past (before testDate)
368+ const pastDate = new Date ( testDate ) ;
369+ pastDate . setFullYear ( pastDate . getFullYear ( ) - 2 ) ;
370+ const pastDateStr = pastDate . toISOString ( ) . split ( 'T' ) [ 0 ] ;
371+
372+ // Get current tags
373+ const beforeResult = handlers . handleGetConventionalCommits ( {
374+ repo_path : conventionalRepo ,
375+ since : testDate ,
376+ } ) ;
377+
378+ // Query with a future date range that shouldn't include current tags
379+ const futureDate = new Date ( ) ;
380+ futureDate . setFullYear ( futureDate . getFullYear ( ) + 1 ) ;
381+ const futureDateStr = futureDate . toISOString ( ) . split ( 'T' ) [ 0 ] ;
382+
383+ const futureResult = handlers . handleGetConventionalCommits ( {
384+ repo_path : conventionalRepo ,
385+ since : futureDateStr ,
386+ } ) ;
387+
388+ // Should have releases in current date range
389+ expect ( beforeResult . recentReleases . length ) . toBeGreaterThan ( 0 ) ;
390+
391+ // Should have no releases in future date range
392+ expect ( futureResult . recentReleases . length ) . toBe ( 0 ) ;
393+ } ) ;
365394 } ) ;
366395} ) ;
Original file line number Diff line number Diff line change @@ -431,12 +431,20 @@ export function handleGetConventionalCommits(args: any) {
431431
432432 const tagsCmd = `git tag --sort=-creatordate --format="%(refname:short)|%(creatordate:short)"` ;
433433 const tagsOutput = runGitCommand ( repo_path , tagsCmd ) ;
434- const tags = tagsOutput . trim ( ) . split ( "\n" ) . filter ( t => t ) . slice ( 0 , 20 ) ;
435-
436- const releases = tags . map ( t => {
437- const [ tag , date ] = t . split ( "|" ) ;
438- return { tag, date } ;
439- } ) ;
434+ const tags = tagsOutput . trim ( ) . split ( "\n" ) . filter ( t => t ) ;
435+
436+ const releases = tags
437+ . map ( t => {
438+ const [ tag , date ] = t . split ( "|" ) ;
439+ return { tag, date } ;
440+ } )
441+ . filter ( r => {
442+ const releaseDate = new Date ( r . date ) ;
443+ const sinceDate = new Date ( since ) ;
444+ const untilDate = until ? new Date ( until ) : new Date ( ) ;
445+ return releaseDate >= sinceDate && releaseDate <= untilDate ;
446+ } )
447+ . slice ( 0 , 20 ) ;
440448
441449 return {
442450 totalCommits : lines . length ,
You can’t perform that action at this time.
0 commit comments