Changeset 07bc90a in rtems-testing


Ignore:
Timestamp:
Feb 23, 2012, 1:51:50 PM (7 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 8895273c193787f84c4585a10f6d6aceb3b25dc4
Children:
f0bc7c2
Parents:
0d54987
Message:

Add initial git support to merge-helper scripts

Location:
merge-helpers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • merge-helpers/ChangeLog

    r0d54987 r07bc90a  
     1#! /bin/sh
     2#
     3#   Use git from the current directory and put the file names
     4#   in suitable format for use in a ChangeLog.
     5#
     6#   TODO:  Initial conversion from cvs
     7#
     8#  $Id: mkChangeLogList,v 1.6 2011/01/04 19:53:53 joel Exp $
     9#
     10
     11mklog_()
     12{
     13  cat >XXX
     14  if test `cat XXX | wc -l` -ne 0 ; then
     15    (cat XXX | cut -d':' -f2 | \
     16    sed -e '$!s/$/,/' -e '$s/$/:/' ; \
     17    test $? -ne 0 || echo "$*" )| \
     18    xargs -s80 | sed -e '1s/^/  \* /' -e '2,$s/^/       /'
     19  fi
     20  rm -f XXX
     21}
     22
     23progname=${0##*/}
     24usage()
     25{
     26  echo "$progname [-ln] [-u user] [-U user_information] [-m message] [-M msgfile]"
     27  exit 1
     28}
     29
     30print_name="no"
     31user=$LOGNAME
     32git_local_arg=""
     33basedir=.
     34while getopts d:lnM:m:p:c:u:U: OPT
     35do
     36  case "$OPT" in
     37    d) basedir=$OPTARG ;;
     38    l) git_local_arg="-l" ;;
     39    n) print_name="yes" ;;
     40    p) prnum=$OPTARG ;;
     41    c) coverity_num=$OPTARG ;;
     42    m) message=$OPTARG ;;
     43    M) message=`cat $OPTARG` ;;
     44    u) user=$OPTARG ; print_name="yes" ;;
     45    U) user_name=$OPTARG ; print_name="yes" ;;
     46    *) usage ;;
     47  esac
     48done
     49
     50let $((shiftcount = $OPTIND - 1))
     51shift #shiftcount
     52
     53args=$*
     54
     55dirarg="${basedir}"
     56
     57# Determine VCS in use
     58isgit()
     59{
     60  depth=0
     61  dir=.git
     62  while [ $depth -lt 10 ]
     63  do
     64    if [ -d ${dir} ] ; then
     65      return 1
     66    fi
     67    dir=../${dir}
     68    depth=`expr ${depth} + 1`
     69  done 
     70  return 0
     71}
     72
     73isgit
     74if [ $? -eq 1 ] ; then
     75  VCS=git
     76elif [ -d CVS ] ; then
     77  VCS=cvs
     78else
     79  echo "This does not look like a checkout from a VCS I understand."
     80  exit 1
     81fi
     82
     83if [ ! -r ChangeLog ] ; then
     84  ( echo "There is no ChangeLog in this directory." ;
     85    echo "Where are you putting the entry?" )>/dev/stderr
     86  exit 1
     87fi
     88
     89case ${VCS} in
     90  cvs)
     91    # done parsing arguments, now work
     92    if [ "X${CVSROOT}" = "X" ] ; then
     93      CVS=cvs
     94    else
     95      CVS="cvs -d ${CVSROOT}"
     96    fi
     97    CVS="${CVS}"
     98
     99    files_modded=`${CVS} diff ${dirarg} 2>&1 | grep ^Index | wc -l`
     100    files_added=`${CVS} diff ${dirarg} 2>&1 | grep "is a new entry, no " | wc -l`
     101    files_deleted=`${CVS} diff ${dirarg} 2>&1 | grep " was removed, no " | wc -l`
     102    ;;
     103  git)
     104    files_modded=`git status ${dirarg} 2>&1 | grep "modified: " | wc -l`
     105    files_added=`git status ${dirarg} 2>&1 | grep "new file: " | wc -l`
     106    files_deleted=0
     107    #files_deleted=`${CVS} diff ${dirarg} 2>&1 | grep " was removed, no " | wc -l`
     108    ;;
     109  *)
     110    echo "${VCS} to be implemented"
     111    exit 1
     112    ;;
     113esac
     114
     115files_changed=`expr ${files_modded} + ${files_added} + ${files_deleted}`
     116if test ${files_changed} -eq 0 ; then
     117  exit 0
     118fi
     119
     120if test ${print_name} = "yes" ; then
     121  if test "X${user_name}" = "X" ; then
     122    if test "X${user}" = "X" ; then
     123      echo "User not specified (LOGNAME not set or no -u option)"
     124      usage
     125    fi
     126
     127    user_name=`grep ^${user} /etc/passwd | cut -d':' -f5 | cut -d',' -f1`
     128    if test "X${user_name}" = "X" ; then
     129      echo "User information not set"
     130      usage
     131    fi
     132  fi
     133
     134  date=`date +%Y-%m-%d`
     135  echo "${date} ${user_name}"
     136  echo
     137fi
     138
     139if test "X${prnum}" != "X" ; then
     140  echo "        PR ${prnum}"
     141fi
     142if test "X${coverity_num}" != "X" ; then
     143  echo "        Coverity Id ${coverity_num}"
     144fi
     145
     146case ${VCS} in
     147  cvs)
     148    # Generate list of modified files
     149    ${CVS} diff ${dirarg} 2>/dev/null | grep ^Index | mklog_ ${message}
     150
     151    # Generate list of deleted files
     152    test ${files_added} -gt 1 && plural=s
     153    ${CVS} diff ${dirarg} 2>&1 | grep "is a new entry, no comparison" | \
     154      sed -e 's/^.*: //' -e 's/ is a .*$//' | mklog_ "New file${plural}."
     155
     156    # Generate list of removed files
     157    ${CVS} diff ${dirarg} 2>&1 | grep "was removed, no comparison" | \
     158      sed -e 's/^.*: //' -e 's/ was removed, no comparison.*$//' | \
     159      mklog_ Removed.
     160    ;;
     161  git)
     162    # Generate list of modified files
     163    git status 2>&1 | grep "modified: " | mklog_ ${message}
     164
     165    # Generate list of deleted files
     166    test ${files_added} -gt 1 && plural=s
     167    git status 2>&1 | grep "new file: " | \
     168      sed -e 's/^.*: //' -e 's/ is a .*$//' | mklog_ "New file${plural}."
     169
     170    # Generate list of removed files
     171    #${CVS} diff ${dirarg} 2>&1 | grep "was removed, no comparison" | \
     172    #  sed -e 's/^.*: //' -e 's/ was removed, no comparison.*$//' | \
     173    #  mklog_ Removed.
     174    ;;
     175  *)
     176    echo "${VCS} to be implemented"
     177    exit 1
     178    ;;
     179esac
     180
     181echo
     182
     183# rm -f XXX
     184exit 0
    11852011-08-31      Joel Sherrill <joel.sherrill@oarcorp.com>
    2186
  • merge-helpers/commit

    r0d54987 r07bc90a  
    2727
    2828# Determine VCS in use
    29 if [ -d .git ] ; then
     29isgit()
     30{
     31  depth=0
     32  dir=.git
     33  while [ $depth -lt 10 ]
     34  do
     35    if [ -d ${dir} ] ; then
     36      return 1
     37    fi
     38    dir=../${dir}
     39    depth=`expr ${depth} + 1`
     40  done 
     41  return 0
     42}
     43
     44isgit
     45if [ $? -eq 1 ] ; then
    3046  VCS=git
    3147elif [ -d CVS ] ; then
     
    105121fi
    106122
    107 commit()
     123commit_helper()
    108124{
    109125  if [ $? -ne 0 ] ; then
     
    121137    git)
    122138      echo "git commit -F ${changefile}"
    123       git commit -a -F ${changefile}
     139      git add ${changefile}
     140      git commit -F ${changefile}
    124141      ;;
    125142    *) echo "${VCS} to be implemented" ;  exit 1 ;;
     
    142159  test "${ddir}" = "install" && continue
    143160  if [ -d "${ddir}" ]; then
    144     if [ ! -d "${ddir}/${VCSDIR}" ] ; then
    145       echo "WARNING - ${ddir} is not in .git"
    146       continue
    147     fi
     161    case ${VCS} in
     162      cvs)
     163        if [ ! -d "${ddir}/${VCSDIR}" ] ; then
     164          echo "WARNING - ${ddir} is not in .git"
     165          continue
     166        fi
     167        ;;
     168      git)
     169        ;;
     170      *)
     171        echo "${VCS} to be implemented"
     172        exit 1
     173        ;;
     174    esac
    148175    test -f "${ddir}/ChangeLog" || continue
    149176    cd "$ddir" >/dev/null
     
    158185      read -p "Commit changes? [y/n/e(edit)]: " response
    159186      case ${response} in
    160         y) commit; break ;;
     187        y) commit_helper; break ;;
    161188        n) break ;;
    162189        e) ${editor} ${changefile} ;;
  • merge-helpers/mkChangeLogList

    r0d54987 r07bc90a  
    5656
    5757# Determine VCS in use
    58 if [ -d .git ] ; then
     58isgit()
     59{
     60  depth=0
     61  dir=.git
     62  while [ $depth -lt 10 ]
     63  do
     64    if [ -d ${dir} ] ; then
     65      return 1
     66    fi
     67    dir=../${dir}
     68    depth=`expr ${depth} + 1`
     69  done 
     70  return 0
     71}
     72
     73isgit
     74if [ $? -eq 1 ] ; then
    5975  VCS=git
    6076elif [ -d CVS ] ; then
Note: See TracChangeset for help on using the changeset viewer.