Skip to content

Commit ad56951

Browse files
authored
Add script for checking possibly outdated pages (#1774)
* Add script for checking possibly outdated pages * Add command-line options * Update CONTRIBUTING.md * clarify * Only include .md files * Instructions for updating timestamp * typo
1 parent eca98b8 commit ad56951

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [Previewing the website using MkDocs](#previewing-the-website-using-mkdocs)
1616
- [Building the website using the included Dockerfile](#building-the-website-using-the-included-dockerfile)
1717
- [Hosting the website on OpenShift](#hosting-the-website-on-openshift)
18+
- [Finding pages that might be outdated](#finding-pages-that-might-be-outdated)
1819

1920
## Starting as a writer
2021

@@ -256,3 +257,39 @@ delete your project or clean it with `oc delete`:
256257
```bash
257258
oc delete all -l app=csc-user-guide-feature-a
258259
```
260+
261+
## Finding pages that might be outdated
262+
263+
Each page in Docs CSC shows a "Last update" timestamp. To ensure that content
264+
stays up to date and valid, it is good practice to search for and check pages
265+
that have not been updated in a long time. A script `scripts/last_update.sh`
266+
is provided for this purpose that goes through the git log and prints for each
267+
`.md` file its last update timestamp and who made the most recent commit.
268+
Consider using the script from time to time to check pages that have not been
269+
touched in a while, say, 1-2 years.
270+
271+
Run the script in the root of the repository as
272+
273+
```bash
274+
bash scripts/last_update.sh
275+
```
276+
277+
You can also filter out pages that no one has touched after you using the `-u`
278+
option. The search pattern used here corresponds to your git username as
279+
defined in your git config (see `git config user.name`).
280+
281+
```bash
282+
bash scripts/last_update.sh -u
283+
```
284+
285+
Note that if you've changed your git username recently, the results may be
286+
incomplete and you might need to manually grep for your commits.
287+
288+
If you find something worth updating, please do so and create a PR to help us
289+
maintain Docs. If nothing needs to be modified, one way to update the timestamp
290+
without actually making any visible changes is to add a comment in the file
291+
using HTML tags, e.g.
292+
293+
```
294+
<!-- Page OK, add comment to update timestamp -->
295+
```

scripts/last_update.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
set -e
3+
4+
usage="Usage: $(basename "$0") [-h] [-u]
5+
Print last update timestamp and most recent committer for each Docs page.
6+
7+
Options:
8+
-h show this help text
9+
-u only show pages no one has touched after you"
10+
11+
while getopts "hu" option; do
12+
case "$option" in
13+
u) name="$(git config user.name)";;
14+
h) echo "$usage"; exit;;
15+
*) echo "$usage"; exit;;
16+
esac
17+
done
18+
19+
declare -A seen
20+
21+
while read -r line ; do
22+
if [[ "$line" = /* ]] ; then
23+
date="${line#* }"
24+
date="${date:0:25}"
25+
committer="${line#* }"
26+
committer="${committer:26}"
27+
elif [[ "$line" && -z "${seen[$line]}" ]] ; then
28+
seen["$line"]="$date, $committer"
29+
fi
30+
done < <(git log --format="/%H %ai %an" --name-only)
31+
32+
git ls-files "*.md" | while read f ; do
33+
f="${f#./}"
34+
printf "%s %s\n" "${seen[$f]}" "$f"
35+
done | sort -r | grep "$name"

0 commit comments

Comments
 (0)