Skip to content

Commit

Permalink
Update nuke_format so that it's safe (enough) to handle the bulk dele…
Browse files Browse the repository at this point in the history
…tion

to get rid of most of our older and unused formats. Some hand tuning may
still be needed
  • Loading branch information
robertlipe committed Dec 9, 2021
1 parent d9dcfd9 commit da7ae59
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
28 changes: 18 additions & 10 deletions tools/nuke_format
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# usage nuke_format format_name

SED=$(which gsed)
EDITOR="${EDITOR:-vim}"
EDITOR="${EDITOR:-vim}"

# $1 = format $2 = file in all functions


# $1 = format $2 = file
remove_word() {
# git add $2
$SED -i "s/$1//g" $2
set -x
# This uses a GNU extension ? for zero or more, letting us match with last
# entry in a line which has no following whitespace
$SED -i "s/$1\s*//g" $2
}

remove_line_containing() {
Expand All @@ -27,22 +32,25 @@ remove_word $1.h GPSBabel.pro

remove_manually $1 reference/help.txt

remove_line_containing $1 reference/format0.txt
remove_line_containing $1 reference/format1.txt
remove_line_containing $1 reference/format2.txt
remove_manually $1 reference/format3.txt
# Take out the boilerplate entries in vecs.h ...
remove_line_containing extern.*$1 vecs.h
remove_line_containing Format.*$1 vecs.h
remove_line_containing include.*$1 vecs.h
remove_manually $1 reference/format3.txt
# ... then let a human nerd snip3 the actual table entry awy
remove_manually $1 vecs.h

remove_line_containing $1 reference/format0.txt
remove_line_containing $1 reference/format1.txt
remove_line_containing $1 reference/format2.txt
# This breaks these, but at least it leaves a clue in version history.
remove_line_containing $1 msvc/GPSBabel.vcxproj
remove_line_containing $1 msvc/GPSBabel.vcxproj.filters

git rm -f reference/$1*
git rm -f xmldoc/formats/$1.xml
git rm -f xmldoc/formats/options/$1.xml
git rm -f testo.d/$1.test
git rm -f $1.cc
git rm -f $1.h
git mv $1.cc deprecated/
git mv $1.h deprecated/

# make && ./testo
30 changes: 30 additions & 0 deletions tools/reset_nuke
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Temporary script to undo what

rm reference/format?.txt reference/help.txt
# git rm reference/format?.txt reference/help.txt
git reset reference/format?.txt reference/help.txt
git checkout reference/format0.txt
git checkout reference/format1.txt
git checkout reference/format2.txt
git checkout reference/format3.txt reference/help.txt

rm GPSBabel.pro vecs.h vecs.cc
# git rm GPSBabel.pro vecs.h
#git reset GPSBabel.pro
#git reset vecs.h
git checkout GPSBabel.pro vecs.h vecs.cc

# This part of the code devalues almot immediately once pushed upstream
echo "Now re-killing formats to exercise the script. ^C to cancel. <enter> to ontinue"
read x

for f in compegps cst destinator g7to2in gopal gpsutil jtr maggeo mapsend nm4 pcx pocketfms skyforce stmsdf stmwpp tiger vpl wfff yahoo
do
git checkout $f.cc $f.h
tools/nuke_format $f
done

# nuke_format is also believed to work on:
# gpsutil destinator exif gopal gpsutil jogmap jtr maggeo
# mapsend pcx skyforce stmsdf stmwpp tiger vidaone vpl yahoo

0 comments on commit da7ae59

Please sign in to comment.