summaryrefslogtreecommitdiffstats
path: root/cvs-helpers/cvscommit
blob: 7c00fcadec5d37f477f52d26e61b5ed99b3ad443 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#! /bin/sh
#
#   Do a cvs diff from the current directory and put the file names
#   in suitable format for use in a ChangeLog.
#
#   TODO:  No outstanding isses.
#
#  $Id$
#


progname=${0##*/}
usage()
{
  echo "$progname [-dlq] [-e editor] [-u user] [-m message] [-M msgfile]"
  echo "options:"
  echo "  -d         .. debug, don't delete change files";
  echo "  -q         .. quiet, don't display directories";
  echo "  -l         .. local directory only";
  echo "  -m message .. text to use for modified files";
  echo "  -M msgfile .. file containing to use for modified files";
  echo "  -u user    .. use user instead of LOGNAME";
  echo "  -U user    .. use explicit user info -- not from passwd";
  echo "  -p PR      .. PR info";
  echo "  -c CID     .. Coverity Id number";
  echo
  exit 1
}

if [ ! -d CVS ] ; then
  echo There is no CVS directory in the current directory.
  exit 1
fi

editor="vim"
changefile="changes-xxx"
rem_changes="yes"
quiet="no"
user=$LOGNAME
mkchoptions="-n"
message=
localdir="no"
while getopts dlqe:M:m:u:U:p:c: OPT
do
  case "$OPT" in 
    d) rem_changes="yes" ;;
    e) editor=$OPTARG ;;
    l) localdir="yes" ;;
    m) message=$OPTARG ;; 
    M) message=`cat $OPTARG` ;; 
    q) quiet="yes" ;;
    u) user=$OPTARG ; mkchoptions=${mkchoptions}" -u ${user}" ;;
    U) userArg="-U" userInfo=$OPTARG ;;
    p) PrInfo=$OPTARG ; mkchoptions=${mkchoptions}" -p ${PrInfo}" ;;
    c) CoverityInfo=$OPTARG ; mkchoptions=${mkchoptions}" -c ${CoverityInfo}" ;;
    *) usage ;;
  esac
done

export message
let $((shiftcount = $OPTIND - 1))
shift #shiftcount

args=$*

# done parsing arguments, now work 
if [ "X${CVSROOT}" = "X" ] ; then
  CVS=cvs
else
  CVS="cvs -d ${CVSROOT}"
fi

CVS="${CVS}"

if [ ${localdir} = "yes" ] ; then
  subdirs="."
else
  subdirs="* ."
fi

# Make sure we have user information
if test "X${userInfo}" = "X" ; then
  user_name=`grep ^${user} /etc/passwd | cut -d':' -f5 | cut -d',' -f1`
  if test "X${user_name}" = "X" ; then
    echo "User information not set"
    usage
  fi
fi

commit()
{
  ${CVS} up ChangeLog
  if [ $? -eq 0 ] ; then
    prepend ${changefile}
    cvs commit -F ${changefile}
  fi
}

for ddir in ${subdirs} ; do
  test "${ddir}" = "CVS" && continue
  test "${ddir}" = "autom4te.cache" && continue
  test "${ddir}" = "install" && continue
  if [ -d "${ddir}" ]; then
    if [ ! -d "${ddir}/CVS" ] ; then
      echo "WARNING - ${ddir} is not in CVS"
      continue
    fi
    test -f "${ddir}/ChangeLog" || continue
    cd "$ddir" >/dev/null
    mkChangeLogList ${mkchoptions} ${userArg} "${userInfo}" \
          -m "${message}" >${changefile}
    test $? -ne 0 && continue 
    while test -s ${changefile} ; do
      fullpath=`pwd`
      test "$quiet" = "no" && echo "** directory: $fullpath **"
      cat ${changefile}
      response="n"
      read -p "Commit changes? [y/n/e(edit)]: " response
      case ${response} in
        y) commit; break ;;
        n) break ;;
        e) ${editor} ${changefile} ;;
        *) echo "*** enter y,n, or e ***" ;;
      esac
    done
    test $rem_changes = "yes" && rm -rf $changefile
    cd - >/dev/null
  fi
done