import { Release } from "./ReleaseChangelogInterfaces" ; export default class WorkItemUpdater { constructor ( private latestRelease , private workItemFilter ) { } /**
     * Generate work items in latest release
     */ update ( ) { let workItemFilter = RegExp ( this . workItemFilter , 'gi' ) ; for ( let artifact of this . latestRelease [ "artifacts" ] ) { for ( let commit of artifact [ "commits" ] ) { let commitMessage = commit [ "message" ] + "\n" + commit [ "body" ] ; let workItems = commitMessage . match ( workItemFilter ) ; if ( workItems ) { for ( let item of workItems ) { if ( this . latestRelease [ "workItems" ] [ item ] == null ) { this . latestRelease [ "workItems" ] [ item ] = new Set < string > ( ) ; this . latestRelease [ "workItems" ] [ item ] . add ( commit [ "commitId" ] . slice ( 0 , 8 ) ) ; } else { this . latestRelease [ "workItems" ] [ item ] . add ( commit [ "commitId" ] . slice ( 0 , 8 ) ) ; } } } } } for ( let key in this . latestRelease [ "workItems" ] ) { this . latestRelease . workItems [ key ] = Array . from ( this . latestRelease . workItems [ key ] ) ; } } }