Merge lp:~rbalint/ubuntu-motd/check-news-format into lp:ubuntu-motd

Proposed by Balint Reczey
Status: Merged
Merged at revision: 63
Proposed branch: lp:~rbalint/ubuntu-motd/check-news-format
Merge into: lp:ubuntu-motd
Diff against target: 58 lines (+42/-1)
2 files modified
README (+1/-1)
check-format (+41/-0)
To merge this branch: bzr merge lp:~rbalint/ubuntu-motd/check-news-format
Reviewer Review Type Date Requested Status
Dean Henrichsmeyer Pending
Mark Shuttleworth Pending
Steve Langasek Pending
ubuntu-motd Pending
Review via email: mp+360195@code.launchpad.net

Description of the change

Add check to ensure creating nice motd news.

To post a comment you must log in.
Revision history for this message
Mark Shuttleworth (sabdfl) wrote :

Thanks for digging into this! Can you also make sure it handles cases like this one?

 * Ubuntu's Kubernetes 1.14 distributions can bypass Docker and use containerd
   directly, see https://bit.ly/ubuntu-containerd or try it now with

     snap install microk8s --classic

Revision history for this message
Balint Reczey (rbalint) wrote :

Done!

64. By Balint Reczey

Allow snap/apt command as news last line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2018-09-16 17:48:36 +0000
3+++ README 2019-04-08 10:13:48 +0000
4@@ -4,7 +4,7 @@
5 - The file, "index.txt" should contain no more than 10 lines.
6 - No line should contain more than 80 characters
7 - The first line should start with a white space, an asterisk, and a whitespace, followed by an informative header
8- - The last line should be a link to more information
9+ - The last line should be a HTTPS link to more information or a snap/apt command to paste
10
11 Example index.txt:
12
13
14=== added file 'check-format'
15--- check-format 1970-01-01 00:00:00 +0000
16+++ check-format 2019-04-08 10:13:48 +0000
17@@ -0,0 +1,41 @@
18+#!/bin/sh
19+
20+set -e
21+
22+dmotd="$1"
23+
24+ret=0
25+
26+if [ -z "$dmotd" ]; then
27+ echo "Usage:"
28+ echo " $0 <dynamic motd news file>"
29+ exit 1
30+fi
31+
32+lines=$(wc -l < "$dmotd")
33+if [ "$lines" -gt 10 ]; then
34+ echo "ERROR: $dmotd contains more than 10 lines ($lines)"
35+ ret=1
36+fi
37+
38+line_max_len=$(wc -L < "$dmotd")
39+if [ "$line_max_len" -gt 80 ]; then
40+ echo "ERROR: $dmotd contains longer than 80 character line ($line_max_len)"
41+ ret=1
42+fi
43+
44+first_line="$(head -n 1 "$dmotd")"
45+if ! echo "$first_line" | grep -q '^ \* '; then
46+ echo "ERROR: $dmotd first line does does not match recommended format, but is:"
47+ echo "\"$first_line\""
48+ ret=1
49+fi
50+
51+last_line="$(tail -n 1 "$dmotd")"
52+if ! echo "$last_line" | egrep -q '( https://| apt | snap )'; then
53+ echo "ERROR: $dmotd last line does does not match recommended format, but is:"
54+ echo "\"$last_line\""
55+ ret=1
56+fi
57+
58+exit $ret

Subscribers

People subscribed via source and target branches