Annotation of freem/scripts/fmd-changelog, revision 1.3

1.1       snw         1: #!/usr/bin/env bash
                      2: 
                      3: #
1.3     ! snw         4: #   $Id: fmd-changelog,v 1.2 2025/04/06 03:38:05 snw Exp $
1.1       snw         5: #    Gets the changelog for a specific version
                      6: #
                      7: #  
                      8: #   Author: Serena Willis <snw@coherent-logic.com>
                      9: #    Copyright (C) 2025 Coherent Logic Development LLC
                     10: #
                     11: #
                     12: #   This file is part of FreeM.
                     13: #
                     14: #   FreeM is free software: you can redistribute it and/or modify
                     15: #   it under the terms of the GNU Affero Public License as published by
                     16: #   the Free Software Foundation, either version 3 of the License, or
                     17: #   (at your option) any later version.
                     18: #
                     19: #   FreeM is distributed in the hope that it will be useful,
                     20: #   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     21: #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     22: #   GNU Affero Public License for more details.
                     23: #
                     24: #   You should have received a copy of the GNU Affero Public License
                     25: #   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
                     26: #
1.2       snw        27: #   $Log: fmd-changelog,v $
1.3     ! snw        28: #   Revision 1.2  2025/04/06 03:38:05  snw
        !            29: #   Prepare for adding packaging functionality to fmd
        !            30: #
1.2       snw        31: #   Revision 1.1  2025/04/04 18:00:01  snw
                     32: #   *** empty log message ***
                     33: #
1.1       snw        34: #
                     35: # SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
                     36: # SPDX-License-Identifier: AGPL-3.0-or-later
                     37: #
                     38: 
                     39: MINIMAL=0
                     40: 
                     41: function usage() {
1.2       snw        42:     echo
                     43:     echo "Prints a FreeM ChangeLog entry"
                     44:     echo
                     45:     echo "usage:"
                     46:     echo
                     47:     echo "  fmd changelog [--minimal] [<freem-version>]"
                     48:     echo
                     49:     echo "  If the '--minimal' flag is specified, will print only the ChangeLog entries"
                     50:     echo "  without the version header."
                     51:     echo
                     52:     echo "  If <freem-version> is omitted, fmd changelog will assume you want the ChangeLog"
                     53:     echo "  for the current version in your copy of the repository."    
                     54:     echo 
1.1       snw        55:     exit 1
                     56: }
                     57: 
1.2       snw        58: if [[ $1 == "help" ]]
                     59: then
                     60:     usage
                     61: fi
                     62: 
1.1       snw        63: if [[ $# == 0 ]]
                     64: then
                     65:     echo "changelog:  must be run from 'fmd changelog'"
                     66:     exit 1
                     67: fi
                     68: 
                     69: if [[ ! -f sem.ver ]]
                     70: then
                     71:     echo "Not in the root of the FreeM repository."
                     72:     exit 1
                     73: fi
                     74: 
                     75: if [[ $# < 2 ]]
                     76: then
                     77:     if [[ $# == 1 ]]
                     78:     then
                     79:         FREEM_VERSION=$(cat sem.ver)
                     80:     else
                     81:         usage
                     82:     fi
                     83: fi
                     84: 
                     85: if [[ $# == 2 ]]
                     86: then
                     87:     if [[ "$2" == "--minimal" ]]
                     88:     then
                     89:         MINIMAL=1
                     90:         FREEM_VERSION=$(cat sem.ver)
                     91:     else
                     92:         FREEM_VERSION=$2
                     93:     fi
                     94: elif [[ $# == 3 ]]
                     95: then
                     96:     if [[ "$2" != "--minimal" ]]
                     97:     then
                     98:         usage
                     99:     fi
                    100:     FREEM_VERSION=$3
                    101:     MINIMAL=1
                    102: fi
                    103: 
                    104: VERSTR="VERSION ${FREEM_VERSION}"
                    105: 
                    106: egrep "^${VERSTR}" ChangeLog &> /dev/null
                    107: RESULT=$?
                    108: 
                    109: if [[ ${RESULT} != 0 ]]
                    110: then
                    111:     echo "setversion:  version ${FREEM_VERSION} not found in ChangeLog"
                    112:     exit 1
                    113: fi
                    114: 
                    115: DIVIDER='********************************************************************************'
                    116: INVER=0
                    117: 
                    118: 
                    119: while read -r LINE
                    120: do    
                    121:     if [[ "${LINE}" == "${VERSTR}" ]]
                    122:     then
                    123:         if [[ ${MINIMAL} == 0 ]]
                    124:         then
                    125:             echo "${LINE}"
                    126:         fi
                    127:         INVER=1
                    128:     else
                    129:         if [[ ${INVER} == 1 ]]
                    130:         then
                    131:             if [[ "${LINE:0:2}" == '**' ]]
                    132:             then
                    133:                 exit 0
                    134:             fi
                    135:             if [[ ${MINIMAL} == 0 ]]
                    136:             then
                    137:                 echo "  ${LINE}"
                    138:             else
                    139:                 if [[ "${LINE:0:1}" == '*' ]]
                    140:                 then
1.3     ! snw       141:                    OLINE=$(echo "${LINE}" | cut -d\* -f2)
        !           142:                    echo "${OLINE:1}"
1.1       snw       143:                 fi
                    144:             fi
                    145:         fi        
                    146:     fi
                    147: 
                    148: done < ChangeLog
                    149: 
                    150: 
                    151: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>