[Checkins] SVN: Sandbox/ctheune/foundation/fix-copyright.sh Improve messages, improve fixing errors once found by allowing to re-run with

Christian Theune ct at gocept.com
Tue Oct 20 03:12:20 EDT 2009


Log message for revision 105168:
  Improve messages, improve fixing errors once found by allowing to re-run with
  existing working directories.
  

Changed:
  U   Sandbox/ctheune/foundation/fix-copyright.sh

-=-
Modified: Sandbox/ctheune/foundation/fix-copyright.sh
===================================================================
--- Sandbox/ctheune/foundation/fix-copyright.sh	2009-10-20 06:45:40 UTC (rev 105167)
+++ Sandbox/ctheune/foundation/fix-copyright.sh	2009-10-20 07:12:19 UTC (rev 105168)
@@ -1,33 +1,59 @@
 #!/bin/bash
-#
-# The `fix-copyright` can be obtained by easy_installing `gocept.devtools`.
-#
 set -e
 
+# XXX Do we really want to check in?
+# What happens if we run the fix script but no changes are there? (E.g. due to
+# a re-run? IN this case we should also  not commit (check output of svn
+# stat?)
+
 PROJECT="$1"
 BASEURL="svn+ssh://svn.zope.org/repos/main/${PROJECT}"
 FIXSCRIPT="fix-copyright"
+EXIT=""
 
 usage() {
     cat <<__EOT__
-Usage: $0 projectname
+Usage: $0 <projectname>
+Set the copyright owner for a zope.org project to the Zope Foundation by
+updating the trunk and the two most recent release branches.
 
-Fixes the copyright owner for a zope.org project.
-Updates the trunk and the two most recent release branches.
+Checks out the branches that are recommended to update and commits
+automatically if all changes applied cleanly.
+
+If any anomalies are detected the checkout remains in the current working
+directory. You can then fix the reported errors and re-run the script which
+will cause the existing checkouts to be re-used.
+
+<project> is the name of the project as found in the zope.org repository
+(e.g. zope.publisher)
+
 __EOT__
 }
 
+require_devtools() {
+    cat <<__EOT__
+    ERROR: The 'fix-copyright' script is missing. It can be obtained by
+    easy_installing the egg 'gocept.devtools'.
+__EOT__
+}
+
 function fix_one() {
     local url="$1"
-    local workdir="${PROJECT}-copyrightfix"
+    local tag="$2"
+    local workdir="${PROJECT}-${tag}-copyrightfix"
+    echo
     echo "Fixing ${url}"
-    svn -q co ${url} ${workdir}
+    if [[ -a ${workdir} ]]; then
+        echo "Working directory already exists, skipping checkout."
+    else
+        svn -q co ${url} ${workdir}
+    fi
     ${FIXSCRIPT} --owner "Zope Foundation and Contributors." ${workdir}
     local remaining=$(egrep -niIr "Copyright \(c\).*Zope Corporation" ${workdir} | wc -l)
     if [[ ${remaining} != 0 ]]; then
-        echo "ERROR: ${remaining} unfixed copyright lines remaining for ${url}"
-        egrep -niIr "Copyright \(c\).*Zope Corporation" ${workdir}
-        exit
+        echo "ERROR: ${remaining} unfixed copyright line(s) remaining for ${url}"
+        egrep --color=never -niIr "Copyright \(c\).*Zope Corporation" ${workdir}
+        return
     fi
     svn -q commit ${workdir} \
         -m "Updating copyright header after transfer of ownership to the Zope Foundation"
@@ -37,7 +63,8 @@
 function list_release_branches() {
     for branch in $(svn ls "${BASEURL}/branches"); do
         if [[ ${branch} =~ ^[0-9\.]+/$ ]]; then
-            echo "${BASEURL}/branches/${branch}"
+            # Remove trailing slash in branch name
+            echo "${branch/\//}"
         fi
     done
 }
@@ -46,11 +73,21 @@
     list_release_branches | sort -n | tail -n 2
 }
 
-if [[ -n ${project} ]]; then
+if [[ -z ${PROJECT} ]]; then
     usage
-else
-    fix_one "${BASEURL}/trunk"
-    for branch in $(choose_branches); do
-        fix_one ${branch}
-    done
+    EXIT=1
 fi
+
+if [[ -z `which fix-copyright` ]]; then
+    require_devtools
+    EXIT=1
+fi
+
+if [[ -n $EXIT ]]; then
+    exit $EXIT
+fi
+
+fix_one "${BASEURL}/trunk" "trunk"
+for branch in $(choose_branches); do
+    fix_one "${BASEURL}/branches/${branch}" "${branch}"
+done



More information about the checkins mailing list