forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrack_fixmes
More file actions
49 lines (44 loc) · 1.7 KB
/
track_fixmes
File metadata and controls
49 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
#
# @license Apache-2.0
#
# Copyright (c) 2023 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Initialize a Markdown-formatted comment body holding the annotations:
comment="<!-- This comment is automatically generated by a GitHub Action. -->
# FIXME annotations
"
# Search for FIXME annotations in the codebase:
for file in $(find bin dist docs tools etc examples lib test tools -type f); do
fixmes=$(grep -E -on "FIXME:" $file) || true
for fixme in $fixmes; do
if [ -n "$fixme" ]; then
# Since a maximum of 65,535 characters can be included in a GitHub comment body, we break out of the loop if the comment body would exceed this limit.
if [ $(( ${#comment} + ${#fixme} )) -gt 65535 ]; then
break
fi
lineNumber=$(echo $fixme | cut -d ":" -f 1)
lineContent=$(awk "NR==$lineNumber" $file)
lineContent=$(echo $lineContent | sed -e 's/<!--/\\<!--/g' -e 's/-->/\\-->/g')
if [ ${#lineContent} -gt 80 ]; then
lineContent=$(echo $lineContent | cut -c 1-80)
lineContent="$lineContent..."
continue
fi
comment="$comment
- [$file#L$lineNumber](https://github.com/stdlib-js/stdlib/blob/develop/$file#L$lineNumber): $lineContent"
fi
done
done
echo "$comment"