Save tags and branches properly

This is a first part of tags and branches refactoring. It will start collecting proper tags/branch info in a separate tables.

The next step will be to use these tables in places where we need branches info.

A big question here is: can we just switch to the new way of saving info about branches without porting info from archive builds? I'm a bit torn on this: if we need to go through all the builds and populate branches/tags tables, it will take quite a lot of time. On the other hand if we don't do it, branches list for most repos will be empty after the switch.