[SM-Discuss] Another grimoire pruning script

Juuso Alasuutari iuso at sourcemage.org
Tue Oct 3 03:08:00 EDT 2006


On Monday 02 October 2006 20:40, Arwed von Merkatz wrote:
> On Sat, Sep 30, 2006 at 08:19:13PM -0700, Eric Sandall wrote:
> > Juuso Alasuutari wrote:
> > > I have here a script that removes UPDATED from spells where ENTERED is
> > > exactly the same. According to my reasoning this shouldn't hurt
> > > anybody, no matter how ancient their systems are. Am I correct?
> > >
> > > ~1900 commits await!
> >
> > That is, technically, correct. In practice, though, it may not be. ;)
> > I'd still say go for it, but Arwed might have different plans.
>
> Sounds good to me.

Ok, done. :)

Modified 1849 spells in main grimoire and 70 in z-rejected. Here's how:

--------------------

#!/bin/bash

NAME="Name Here"
EMAIL="email at he.re"
COMMIT_MSG="[automated] Removed UPDATED."


echo -n "Counting spells to process... "
spellCount=0
for file in `grep -lr "^ *UPDATED=[0-9][0-9]*" ./ | grep DETAILS`; do
  updatedDate=`grep "^ *UPDATED=[0-9][0-9]*" "$file"`
  updatedDate=${updatedDate## *UPDATED=}
   if grep -q "ENTERED=$updatedDate\ *$" "$file"; then
     ((spellCount+=1))
   fi
done
echo Done.


n=0
for file in `grep -lr "^ *UPDATED=[0-9][0-9]*" ./ | grep DETAILS`; do
  updatedDate=`grep "^ *UPDATED=[0-9][0-9]*" "$file"`
  updatedDate=${updatedDate## *UPDATED=}
   if grep -q "ENTERED=$updatedDate\ *$" "$file"; then
    sed -i  "/^\ *UPDATED=[0-9][0-9]*.*$/d" "$file"
    sed -i  "1i$(date +%Y-%m-%d) $NAME <$EMAIL>\n\t* DETAILS: $COMMIT_MSG\n" \
            "${file/\/DETAILS//HISTORY}"
    spellName="${file%%/DETAILS}"
    spellName="${spellName##*/}"
    git commit -m "$spellName: $COMMIT_MSG" -a
    ((n+=1))
    echo $n/$spellCount: $spellName
  fi
done

--------------------

-- 
        Juuso Alasuutari
[[ Source Mage GNU/Linux ]]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/sm-discuss/attachments/20061003/08add10e/attachment.bin 


More information about the SM-Discuss mailing list