[gdal-dev] Trac to GitHub

Even Rouault even.rouault at spatialys.com
Mon Mar 19 09:42:56 PDT 2018


Regarding my point 1), I've experimented locally on my git clone to rewrite references
to Trac tickets like "fix #1234" to become "fix https://trac.osgeo.org/gdal/ticket/1234"

with

git filter-branch -f --msg-filter 'python /home/even/rewrite.py'  -- trunk

where rewrite.py is

{{{
import sys
msg = sys.stdin.read()

# Don't touch messages that reference other databases
if msg.find('MITAB bug ') >= 0 or msg.find('Safe bug ') >= 0 or msg.find('bugzilla') >= 0 or msg.find('Bugzilla') >= 0:
    sys.stdout.write(msg)
    sys.exit(0)

oldpos = 0
old_msg = msg
while True:

    # We already have reference to github pull requests written like
    # 'github #1234', so skip them
    newpos = msg.find('github #', oldpos)
    if newpos >= 0:
        oldpos = newpos + len('github #')
        continue

    # Exception...
    newpos = msg.find('patch #1 ', oldpos)
    if newpos >= 0:
        oldpos = newpos + len('patch #1 ')
        continue

    # Exception...
    newpos = msg.find('bug 1 ', oldpos)
    if newpos >= 0:
        oldpos = newpos + len('bug 1 ')
        continue

    # Fix 'bug 1234'
    newpos = msg.find('bug ', oldpos)
    if newpos >= 0:
        if newpos == len(msg) - 4:
            break
        if not(msg[newpos+4] >= '1' and msg[newpos+4] <= '9'):
            oldpos = newpos + 4
            continue

        msg = msg[0:newpos] + 'https://trac.osgeo.org/gdal/ticket/' + msg[newpos+4:]
        oldpos = newpos
        continue

    # Fix 'ticket 1234'
    newpos = msg.find('ticket ', oldpos)
    if newpos >= 0:
        if newpos == len(msg) - 7:
            break
        if not(msg[newpos+7] >= '1' and msg[newpos+7] <= '9'):
            oldpos = newpos + 7
            continue

        msg = msg[0:newpos] + 'https://trac.osgeo.org/gdal/ticket/' + msg[newpos+7:]
        oldpos = newpos
        continue

    # Fix '#1234'
    newpos = msg.find('#', oldpos)
    if newpos >= 0:
        if newpos == len(msg) - 1:
            break
        if not(msg[newpos+1] >= '1' and msg[newpos+1] <= '9'):
            oldpos = newpos + 1
            continue

        # Skip stacktraces like '#1 0xdeadbeef'
        space_pos = msg.find(' ', newpos)
        if space_pos > 0 and space_pos + 2 < len(msg) and msg[space_pos + 1] == '0' and msg[space_pos + 2] == 'x':
            oldpos = newpos + 1
            continue

        msg = msg[0:newpos] + 'https://trac.osgeo.org/gdal/ticket/' + msg[newpos+1:]
        oldpos = newpos
        continue

    break

if msg != old_msg:
    f = open('/tmp/log.txt', 'a')
    f.write('Old message was:\n' + old_msg + 'New message is:\n' + msg + '\n')
    f.close()

sys.stdout.write(msg)
}}}


I'v uploaded the log of the changes (the content of /tmp/log.txt) in http://even.rouault.free.fr/log.txt
It shows the original and modified commit messages (just for commits for which a modification was done)
In case you have the motivation to actually review it, let me know if you see some weird things in it...

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list