bug-vc-dwim
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-vc-dwim] [PATCH] vc-dwim: warn when there is no one-line summary


From: Jim Meyering
Subject: [Bug-vc-dwim] [PATCH] vc-dwim: warn when there is no one-line summary
Date: Sun, 18 Dec 2011 16:46:19 +0100

Initially, it's too easy to forget to add a one-line summary,
so now vc-dwim warns you when the first line of a commit log
is "obviously" not a summary (i.e., when it starts with "* ").
Thanks to Reuben Thomas for the suggestion.

>From 231b79e0e57a08655855b1ea7f2bbceb8320995e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 18 Dec 2011 16:36:39 +0100
Subject: [PATCH] vc-dwim: warn when there is no one-line summary

* vc-dwim.pl (main): Emit a warning when the first line of the log
starts with "* ".  Suggested by Reuben Thomas.
* tests/subdir: Adapt to new behavior by adding a one-line summary.
* tests/subdir-middle: Likewise.
* tests/subdir-cvs: Test for the new diagnostic.
---
 tests/subdir        |    8 +++++---
 tests/subdir-cvs    |    7 +++++--
 tests/subdir-middle |    6 ++++--
 vc-dwim.pl          |    5 +++++
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/tests/subdir b/tests/subdir
index 5e252dd..3859dc9 100755
--- a/tests/subdir
+++ b/tests/subdir
@@ -19,14 +19,16 @@ fail=0
 cat <<EOF > s/ChangeLog || fail=1
 2006-09-04  Jim Meyering  <address@hidden>

+       1-line summary
        * f: X.
 EOF
 echo bow > s/f || fail=1
 cd s

-vc-dwim ChangeLog > out 2>&1 || fail=1
+vc-dwim ChangeLog > out 2>err || fail=1

 cat <<\EOF > exp || fail=1
+1-line summary
 * f: X.
 diff --git a/s/f b/s/f
 index e69de29..de03f25 100644
@@ -36,7 +38,7 @@ index e69de29..de03f25 100644
 +bow
 EOF

-compare out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare exp out || fail=1
+test $fail = 1 && diff exp out 2> /dev/null

 Exit $fail
diff --git a/tests/subdir-cvs b/tests/subdir-cvs
index aedabb1..382c987 100755
--- a/tests/subdir-cvs
+++ b/tests/subdir-cvs
@@ -37,7 +37,7 @@ if cvs diff ChangeLog > /dev/null; then
   touch -d '2 seconds' f ChangeLog 2> /dev/null || sleep 2
 fi

-vc-dwim ChangeLog > out 2>&1 || fail=1
+vc-dwim ChangeLog > out 2> err || fail=1

 sed 's/RCS file:.*//;s/^[-+][-+][-+] f.*//' out > k; mv k out
 cat <<\EOF > exp || fail=1
@@ -53,6 +53,9 @@ diff -u -p -r1.1.1.1 f
 +bow
 EOF

-compare out exp || fail=1
+compare exp out || fail=1
+
+echo vc-dwim: ChangeLog: no one-line summary > exp.err || fail=1
+compare exp.err err || fail=1

 Exit $fail
diff --git a/tests/subdir-middle b/tests/subdir-middle
index acf7525..e793f39 100755
--- a/tests/subdir-middle
+++ b/tests/subdir-middle
@@ -17,6 +17,7 @@ git commit -m m . > /dev/null || framework_failure_
 cat <<EOF > $ChangeLog || framework_failure_
 2006-09-04  Jim Meyering  <address@hidden>

+       1-line summary
        * f: X.
 EOF
 echo z > 2/3/f || framework_failure_
@@ -24,9 +25,10 @@ echo z > 2/3/f || framework_failure_
 fail=0
 cd 2

-vc-dwim 3/ChangeLog > out 2>&1 || fail=1
+vc-dwim 3/ChangeLog > out 2>err || fail=1

 cat <<\EOF > exp || fail=1
+1-line summary
 * f: X.
 diff --git a/2/3/f b/2/3/f
 index e69de29..b680253 100644
@@ -36,6 +38,6 @@ index e69de29..b680253 100644
 +z
 EOF

-compare out exp || fail=1
+compare exp out || fail=1

 Exit $fail
diff --git a/vc-dwim.pl b/vc-dwim.pl
index e5eb0e5..b716c49 100755
--- a/vc-dwim.pl
+++ b/vc-dwim.pl
@@ -1064,6 +1064,11 @@ sub main
             address@hidden, @affected_files];
         }
     }
+
+  # Warn if the first line of the log starts with "* ".
+  # That indicates a missing one-line summary.
+  $log_msg_lines[0] =~ /^\* /
+    and warn "$ME: $changelog_file_name[0]: no one-line summary\n";
 }

 main();
--
1.7.8.250.g900a1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]