@@ -28,6 +28,8 @@ import * as fs from "fs";
28
28
import * as os from "os" ;
29
29
import * as path from "path" ;
30
30
31
+ import { camelize } from "../lib/utils" ;
32
+
31
33
const github = new GitHubApi ( {
32
34
host : "api.github.com" ,
33
35
protocol : "https" ,
@@ -89,7 +91,7 @@ github.repos.getLatestRelease(repoInfo).then((value) => {
89
91
if ( fieldMatch ) {
90
92
commit . fields . push ( {
91
93
tag : fieldMatch [ 1 ] ,
92
- text : line + " (#" + commit . pushRequestNum + ")" ,
94
+ text : addLinks ( line ) + " (#" + commit . pushRequestNum + ")" ,
93
95
} ) ;
94
96
}
95
97
}
@@ -105,7 +107,9 @@ github.repos.getLatestRelease(repoInfo).then((value) => {
105
107
for ( const commit of commits ) {
106
108
if ( commit . fields . length > 0 ) {
107
109
for ( const field of commit . fields ) {
108
- entries . push ( field ) ;
110
+ if ( field . tag !== "[no-log]" ) {
111
+ entries . push ( field ) ;
112
+ }
109
113
}
110
114
} else {
111
115
noFields . push ( commit . title ) ;
@@ -135,6 +139,34 @@ github.repos.getLatestRelease(repoInfo).then((value) => {
135
139
console . log ( "Error:" + error ) ;
136
140
} ) ;
137
141
142
+ const cache = new Map < string , boolean > ( ) ;
143
+
144
+ function isRule ( ruleName : string ) : boolean {
145
+ let result = cache . get ( ruleName ) ;
146
+ if ( result === undefined ) {
147
+ result = fs . existsSync ( `./src/rules/${ camelize ( ruleName ) } Rule.ts` ) ;
148
+ cache . set ( ruleName , result ) ;
149
+ }
150
+ return result ;
151
+ }
152
+
153
+ /** Replace rule names with links to the docs website */
154
+ function addLinks ( text : string ) : string {
155
+ let result = "" ;
156
+ let lastIndex = 0 ;
157
+ // match everything that looks like a rule name and is enclosed in backticks
158
+ const regex = / ` ( [ a - z ] [ - a - z ] * [ a - z ] ) + ` / g;
159
+ let match = regex . exec ( text ) ;
160
+ while ( match !== null ) {
161
+ if ( isRule ( match [ 1 ] ) ) {
162
+ result += text . slice ( lastIndex , match . index ) + `[${ match [ 0 ] } ](https://palantir.github.io/tslint/rules/${ match [ 1 ] } /)` ;
163
+ lastIndex = regex . lastIndex ;
164
+ }
165
+ match = regex . exec ( text ) ;
166
+ }
167
+ return result + text . slice ( lastIndex ) ;
168
+ }
169
+
138
170
interface IField {
139
171
tag : string ;
140
172
text : string ;
0 commit comments