@@ -42,88 +42,30 @@ module.exports = {
42
42
}
43
43
44
44
if ( typeof commit . subject === 'string' ) {
45
- const url = context . repository
46
- ? `${ context . host } /${ context . owner } /${ context . repository } `
47
- : context . repoUrl
48
- if ( url ) {
49
- // Issue URLs.
50
- const issuesUrl = `${ url } /issues/`
51
-
52
- commit . subject = commit . subject . replace ( / # ( [ 0 - 9 ] + ) / g, ( _ , issue ) => {
53
- issues . push ( issue )
54
-
55
- return `[#${ issue } ](${ issuesUrl } ${ issue } )`
56
- } )
57
-
58
- if ( context . host ) {
59
- // User URLs.
60
- commit . subject = commit . subject . replace ( / (?< ! [ ' ` ] ) @ ( [ a - z 0 - 9 ] (?: - ? [ a - z 0 - 9 ] ) { 0 , 38 } ) (?< ! [ ' ] ) / gi, ( _ , username ) => {
61
- if ( username . includes ( '/' ) ) {
62
- return `@${ username } `
45
+ if ( process . env . NODE_ENV !== 'test' ) {
46
+ // get author by commit hash
47
+ try {
48
+ const response = await new Promise < string > ( ( resolve ) => {
49
+ const url = `https://api.github.com/repos/${ context . owner } /${ context . repository } /commits/${ commit . hash } `
50
+ const headers = {
51
+ 'User-Agent' : context . owner
63
52
}
64
-
65
- return `[@${ username } ](${ context . host } /${ username } )`
66
- } )
67
- }
68
-
69
- if ( process . env . NODE_ENV !== 'test' ) {
70
- // get issuer by #issue
71
- for ( const eachIssue of issues ) {
72
- try {
73
- const response = await new Promise < string > ( ( resolve ) => {
74
- const url = `https://api.github.com/repos/${ context . owner } /${ context . repository } /issues/${ eachIssue } `
75
- const headers = {
76
- 'User-Agent' : context . owner
77
- }
78
- if ( process . env . GITHUB_TOKEN ) {
79
- headers [ 'Authorization' ] = `token ${ process . env . GITHUB_TOKEN } `
80
- }
81
- https . get ( url , { headers } ,
82
- response => {
83
- let data = ''
84
- response . on ( 'data' , ( chunk ) => data += chunk )
85
- response . on ( 'end' , async ( ) => {
86
- resolve ( data )
87
- } )
88
- }
89
- )
90
- } )
91
- const user = JSON . parse ( response ) . user
92
- if ( user ) {
93
- commit . subject += ` [@${ user . login } ](${ user . html_url } )`
94
- }
95
- } catch ( error ) {
96
- console . log ( new Error ( `Can't get issuer by #${ eachIssue } ` , { cause : error } ) )
53
+ if ( process . env . GITHUB_TOKEN ) {
54
+ headers [ 'Authorization' ] = `token ${ process . env . GITHUB_TOKEN } `
97
55
}
98
- }
99
-
100
- // get author by commit hash
101
- try {
102
- const response = await new Promise < string > ( ( resolve ) => {
103
- const url = `https://api.github.com/repos/${ context . owner } /${ context . repository } /commits/${ commit . hash } `
104
- const headers = {
105
- 'User-Agent' : context . owner
106
- }
107
- if ( process . env . GITHUB_TOKEN ) {
108
- headers [ 'Authorization' ] = `token ${ process . env . GITHUB_TOKEN } `
56
+ https . get ( url , { headers } ,
57
+ response => {
58
+ let data = ''
59
+ response . on ( 'data' , ( chunk ) => data += chunk )
60
+ response . on ( 'end' , async ( ) => {
61
+ resolve ( data )
62
+ } )
109
63
}
110
- https . get ( url , { headers } ,
111
- response => {
112
- let data = ''
113
- response . on ( 'data' , ( chunk ) => data += chunk )
114
- response . on ( 'end' , async ( ) => {
115
- resolve ( data )
116
- } )
117
- }
118
- )
119
- } )
120
- const author = JSON . parse ( response ) . author
121
- if ( author ) {
122
- commit . subject += ` [@${ author . login } ](${ author . html_url } )`
123
- }
124
- } catch ( error ) {
125
- console . log ( new Error ( `Can't get author by commit hash ${ commit . hash } ` , { cause : error } ) )
126
- }
64
+ )
65
+ } )
66
+ commit . author = JSON . parse ( response ) . author
67
+ } catch ( error ) {
68
+ console . log ( new Error ( `Can't get author by commit hash ${ commit . hash } ` , { cause : error } ) )
127
69
}
128
70
}
129
71
}
0 commit comments