@@ -137,8 +137,7 @@ interface CommitChangeProps {
137
137
}
138
138
139
139
function CommitChange ( props : CommitChangeProps ) : JSX . Element {
140
- const commit = props . commit
141
- const [ message , description ] = commit . message . split ( "\n\n" , 2 )
140
+ const [ message , ...description ] = props . commit . message . split ( / ( \r \n | \n | \r ) / g)
142
141
143
142
const [ hide , setHide ] = useState ( true )
144
143
@@ -148,8 +147,8 @@ function CommitChange(props: CommitChangeProps): JSX.Element {
148
147
149
148
return (
150
149
< span >
151
- < a href = { commit . htmlUrl } className = "gitploy-link" > < strong > { message . substring ( 0 , 50 ) } </ strong > </ a >
152
- { ( description ) ?
150
+ < a href = { props . commit . htmlUrl } className = "gitploy-link" > < strong > { message . substring ( 0 , 50 ) } </ strong > </ a >
151
+ { ( description . length ) ?
153
152
< Button size = "small" type = "text" onClick = { onClickHide } >
154
153
< Text className = "gitploy-code" code > ...</ Text >
155
154
</ Button > :
@@ -158,16 +157,14 @@ function CommitChange(props: CommitChangeProps): JSX.Element {
158
157
{ ( ! hide ) ?
159
158
< Paragraph style = { { margin : 0 } } >
160
159
< pre style = { { marginBottom : 0 , fontSize : 12 } } >
161
- { description . split ( / ( \r \n ) / g) . map ( ( line , idx ) => {
162
- return ( line !== "\r\n" ) ? < Text key = { idx } > { line } </ Text > : < br />
163
- } ) }
160
+ { description . join ( "" ) . trim ( ) }
164
161
</ pre >
165
162
</ Paragraph > :
166
163
null }
167
164
< br />
168
- { ( commit ?. author ) ?
165
+ { ( props . commit ?. author ) ?
169
166
< span >
170
- < Text > < Avatar size = "small" src = { commit . author . avatarUrl } /> { commit . author . login } </ Text > < Text > committed { moment ( commit . author ?. date ) . fromNow ( ) } </ Text >
167
+ < Text > < Avatar size = "small" src = { props . commit . author . avatarUrl } /> { props . commit . author . login } </ Text > < Text > committed { moment ( props . commit . author ?. date ) . fromNow ( ) } </ Text >
171
168
</ span > :
172
169
null }
173
170
</ span >
0 commit comments