@@ -36,7 +36,7 @@ function tagToNumber(tag: string, maxLength: number): number {
3636 * @param tags
3737 * @returns
3838 */
39- function getCommitLatestTag ( tags : string [ ] ) : string {
39+ export function getCommitLatestTag ( tags : string [ ] ) : string {
4040 if ( ! Array . isArray ( tags ) || tags . length === 0 ) return "" ;
4141
4242 const validTags = tags . filter ( ( tag ) => isValidReleaseTag ( tag ) ) ;
@@ -66,37 +66,52 @@ export function getInitData(data: GlobalProps["data"]): Cluster[] {
6666 const clusters : Cluster [ ] = [ ] ;
6767
6868 data . map ( ( clusterNode ) => {
69- const { commit : clusterFirstCommit , clusterId } = clusterNode . commitNodeList [ 0 ] ;
70- const { message } = clusterFirstCommit ;
69+ const { message } = clusterNode . commitNodeList [ 0 ] . commit ;
70+ const resultMsg = message . split ( "/n/n" ) [ 0 ] ;
71+ const cluster : Cluster = {
72+ clusterId : clusterNode . commitNodeList [ 0 ] . clusterId ,
73+ summary : {
74+ authorNames : [ ] ,
75+ content : {
76+ message : resultMsg ,
77+ count : clusterNode . commitNodeList . length - 1 ,
78+ } ,
79+ } ,
80+ clusterTags : [ ] ,
81+ } ;
82+
7183 const clusterTags : string [ ] = [ ] ;
72- const authorSet : Set < string > = new Set ( ) ;
84+ const authorNameSet : Set < string > = new Set ( ) ;
7385
7486 clusterNode . commitNodeList . forEach ( ( commitNode : CommitNode ) => {
7587 // set names
7688 commitNode . commit . author . names . forEach ( ( name ) => {
77- authorSet . add ( name . trim ( ) ) ;
89+ authorNameSet . add ( name . trim ( ) ) ;
7890 } ) ;
7991
8092 // get releaseTags in cluster commitNodeList
81- commitNode . commit . releaseTags ?. forEach ( ( tag ) => {
82- clusterTags . push ( tag ) ;
93+ commitNode . commit . releaseTags ?. map ( ( tag ) => {
94+ if ( clusterTags . indexOf ( tag ) === - 1 ) {
95+ clusterTags . push ( tag ) ;
96+ }
97+ return clusterTags ;
8398 } ) ;
8499 } ) ;
100+ cluster . summary . authorNames . push ( Array . from ( authorNameSet ) as string [ ] ) ;
85101
86- // set latset release tag
87- const latestReleaseTag = getCommitLatestTag ( clusterTags ) ;
102+ // set release tag in cluster
103+ cluster . clusterTags = clusterTags ;
88104
89- const cluster : Cluster = {
90- clusterId : clusterId ,
91- summary : {
92- authorNames : [ Array . from ( authorSet ) ] ,
93- content : {
94- message : message . split ( "/n/n" ) [ 0 ] ,
95- count : clusterNode . commitNodeList . length - 1 ,
96- } ,
97- } ,
98- latestReleaseTag : latestReleaseTag ,
99- } ;
105+ // remove name overlap
106+ const authorsSet = cluster . summary . authorNames . reduce ( ( set , authorArray ) => {
107+ authorArray . forEach ( ( author ) => {
108+ set . add ( author ) ;
109+ } ) ;
110+ return set ;
111+ } , new Set ( ) ) ;
112+
113+ cluster . summary . authorNames = [ ] ;
114+ cluster . summary . authorNames . push ( Array . from ( authorsSet ) as string [ ] ) ;
100115
101116 clusters . push ( cluster ) ;
102117 return cluster ;
0 commit comments