trustmaster / trac2github

Converts Trac milestones, tickets and comments into Github issues 2.0 using github api v3
49 stars 38 forks source link

add attachment conversion support #7

Open Habbie opened 11 years ago

Habbie commented 11 years ago

Hello,

this patch adds support for converting attachments. It posts them as gists (one gist per attachment) and then posts comments to the ticket.

Limitations:

When I used this, I hardcoded the URL. For this pull request, I moved the URL to a variable. I did not test this.

I extracted this patch from a bigger bunch of changes; I did not test the code after extraction. If anything is broken, my apologies.

Habbie commented 11 years ago

Replying to #5 I realise this pull request depends on SQLite. Remove rowid, from the query, and from one of the prints, and it is portable to MySQL.

trustmaster commented 11 years ago

Does it have to have both $row['id'] and $row['rowid'] for SQLite?

ctrueden commented 10 years ago

@trustmaster: I am no expert, but at least with my SQLite3 Trac environments, here's what I see:

sqlite> select count(*) from `ticket`;
822
sqlite> select count(*) from `ticket` where rowid <> id;
0

I am guessing id vs. rowid doesn't matter unless you start manually deleting rows from your ticket table.

So for consistency (assuming @Habbie ever comes back to this), I would suggest the patch just use $row['id'] like everywhere else does.

Habbie commented 10 years ago

id vs. rowid actually makes a big difference in the attachment table:

sqlite> select id,rowid from attachment limit 3;
8|1
8|2
8|3

However, the only reason rowid is in the select is so we can print it. Drop it from the select, drop the print, everything should work with both SQLite and MySQL again.