source: palm/trunk/SCRIPTS/document_changes @ 1804

Last change on this file since 1804 was 1804, checked in by maronga, 5 years ago

removed parameter file check. update of mrungui for compilation with qt5

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 6.5 KB
Line 
1#!/bin/ksh
2#------------------------------------------------------------------------------#
3# This file is part of PALM.
4#
5# PALM is free software: you can redistribute it and/or modify it under the
6# terms of the GNU General Public License as published by the Free Software
7# Foundation, either version 3 of the License, or (at your option) any later
8# version.
9#
10# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# PALM. If not, see <http://www.gnu.org/licenses/>.
16#
17# Copyright 1997-2014  Leibniz Universitaet Hannover
18#------------------------------------------------------------------------------#
19#
20# Current revisions:
21# -----------------
22# Removed printing of "this is an alpha version"
23#
24# Former revisions:
25# -----------------
26# $Id: document_changes 1804 2016-04-05 16:30:18Z maronga $
27#
28# 1326 2014-03-21 10:44:31Z maronga
29# Initial revision
30#
31# Description:
32# ------------
33# This tool moves text from "Current Revisions:" to "Former Revisions:" and
34# adds the svn timestamp. It works with the folders SOURCE and SCRIPTS
35#
36# Usage:
37# a) go to the source directory (e.g. current_version/trunk/SOURCE and
38#    perform "document_changes",
39# b) or call "document_changes" directly and add the path to the source code as
40#    argument
41#    (e.g. document_changes current_version/trunk/SOURCE)
42#
43# Note:
44# The script will only work properly if the two following conditions are met:
45# 1) the 2nd line after "Current Revisions:" must contain text,
46# 2) the last line before "Former Revisions:" must not contain text.
47#------------------------------------------------------------------------------#
48
49#
50#-- define variables
51    comments=""         #: variable contains the CR text
52    comment_char=="!"   #: comment character
53    count_changes=0     #: count the number of files with CR text
54    count_files=0       #: count the number of files
55    filename=""         #: current file name to be scanned
56    file_firstchar=""   #: first character of filename
57    file_lastchar=""    #: last character of filename
58    file_extension=""   #: filename extension
59    found_comment=false #: true/false if a CR text was found
60    IFS=''              #: set standard delimiter to empty string
61    input_dir=""        #: directory of the source code
62    line=""             #: containts the current line of filename
63    line_count=0        #: counter to the line no. of the file
64    line_start=9999999  #: line no. where CR text starts
65    line_stop=0         #: line no. where Cr text ends
66    line_tmp=""         #: first 19 characters of line
67    list_delete=""      #: contains the line no. that must be deleted from CR
68    timestamp=""        #: the svn timestamp of the file
69
70#
71#-- get input directory
72    input_dir=$1
73    if  [[ "$input_dir" == "" ]]
74    then
75       input_dir=`pwd`
76    fi
77    printf "\n  *** Checking files in $input_dir\n"
78
79    for filename in $input_dir/*; do
80
81#
82#--    exclude backup and invisible files
83       file_firstchar=${filename:0:1}
84       file_lastchar=`echo -n $filename| tail -c -1`
85       file_extension=${filename##*.}
86       if [[ "$file_firstchar" == "." || "$file_extension" == "x" || "$file_lastchar" == "~" || "$file_extension" == "tar" ]]
87       then
88          continue
89       fi
90
91       (( count_files = count_files + 1 ))
92
93       line_count=0
94       found_comment=false
95       list_delete=""
96       line_start=9999999
97       line_stop=0
98       comments=""
99
100#
101#--    read one line at a time
102       while read line
103       do
104
105          (( line_count = line_count + 1 ))
106          line_tmp=""
107          line_tmp=${line:2:17}
108
109#
110#--       check if stopping point is reached
111          if [[ $line_stop -eq 0 && "$line_tmp" == "Former revisions:" ]]
112          then
113             line_stop=$line_count
114          fi
115
116#
117#--       check if starting point is reached
118          if [[ $line_start -eq 9999999 && "$line_tmp" == "Current revisions" ]]
119          then
120             (( line_start = line_count + 2 ))
121             comment_char=${line:0:1}
122          fi
123
124#
125#--       read comment line
126          if [[ $line_count -ge $line_start && $line_stop -eq 0 ]]
127          then
128
129#
130#--          check for empty comments
131             line_no_space=`echo ${line:2:10} | sed -e 's/^[ \t]*//'`
132             if [[ $line_count -eq $line_start && "$line_no_space" != "" ]]
133             then
134                printf "\n  *** Revisions found in $filename\n"
135                found_comment=true
136                cp $filename $filename~
137             fi
138
139#
140#--          when comments are found, save comment lines to $comments
141             if [[ "$found_comment" == true ]]
142             then
143                comments="$comments\n$line"
144                list_delete="$list_delete;${line_count}d"
145             fi
146          fi
147
148#
149#--       get the timestamp from the current revision
150          if [[ "$comments" != "" && $line_count -eq $line_stop+2 ]]
151          then
152            timestamp=`echo $line | cut -d" " -s -f4-7`
153            comments="$comment_char $timestamp$comments"
154          fi
155
156       done <"$filename"
157
158#
159#--    move comments from current revisions to former revisions
160       if [[ "$found_comment" == true ]]
161       then
162
163          (( count_changes = count_changes + 1 ))
164
165#
166#--       insert comments to Former Revisions
167          (( line_stop = line_stop + 4 ))
168          sed -i "${line_stop}i$comments" $filename
169
170#
171#--       delete comments from current revisions and insert two blank lines
172          list_delete=${list_delete#?}
173          sed -i "$list_delete" $filename
174          sed -i "${line_start}i${comment_char} " $filename
175          sed -i "${line_start}i${comment_char} " $filename
176
177       fi
178
179    done
180
181#
182#-- inform the user about the changes
183    if  [[ $count_changes -gt 0 ]]
184    then
185       printf "\n  *** $count_files documents checked.\n"
186       printf "  *** $count_changes changed documents found.\n"
187       printf "\n"
188       printf "  *** All files in $input_dir were checked.\n"     
189       printf "  *** You can now proceed with checking other directories\n"
190       printf "      - or you might want to perform svn commit -m 'last commit documented' trunk\n"
191       printf "\n"     
192       printf "  *** Please do not forget to commit your changes in the changelog \n under https://palm.muk.uni-hannover.de/trac/wiki/doc/tec/changelog !"     
193    else
194       printf "\n  *** $count_files documents checked.\n"
195       printf "  *** No documented modifications found.\n"
196    fi
Note: See TracBrowser for help on using the repository browser.