A composite format

Bonjour,

The Friendly Forge Format is not just JSON files with their schema explaining the semantic: they do not capture all the information about a software project hosted on a forge: it also needs to include the code repository, the assets of releases and the file hierarchy in which the JSON files are expected to be organized. For instance comments about an issue (or a pull request) are stored in a single file named after the id (e.g. comments/45.json). It mimics the way Gitea does it at the moment.

The git repository as well as the release assets are referenced by the JSON files. The assets are easy: they are individual files that can be copied. The git repository is however referenced from every pull request and following what Gitea does would not be right. In Gitea there is a separation between a downloader which gets information from a forge and an uploader which uploads information to a forge. But this separation is not enforced for git repositories and the Gitea uploader actually downloads / fetches git repositories. This is a problem because the Gitea uploader does not know the details of the pull requests implementation of the originating forge: only the downloader does.

There is a need for two new functions in the interface of the Friendly Forge Format Go implementation:

GetRepositories() []*format.Repository
CreateRepositories(repositories …*format.Repository)

and the associated format:

type Repository struct {
Directory string json:"directory"
Name string json:"name"
}

The GetRepositories method git fetch the repository. The GetPullRequests method can then fetch the commits and add them to the repository, using the same convention as what Gitea currently implements. The CreateRepositories method then git fetch from whatever GetRepositories created and uploads to the target forge, possibly converting the Friendly Forge Format convention into something the destination forge understands. The CreatePullRequests can recreate / update pull requests using the repository content exclusively using what GetRepositories and GetPullRequests prepared.

To be continued

The implementation is here.