Use the dune-project name as main package if it exists
This should avoid getting the package description of an arbitrary package from the packages to be submitted, as the order is determined by the file system otherwise.
Reported by @emillon
Not sure there is a nice way to write a test for this given the functionality is in the middle of the side-effectful submit function.
After looking how Undraft handles the same case, it just loads the current Pkg.t by loading Pkg.v which infers the main package name (from the dune-project, .opam files or README). This seemed to me the most sensible way and is at least consistent with what other parts of the code do so I adjusted the code to do just that.
Let me know what you think about this approach. I've so far left in the previous implementations in the PR but will remove them before merging.
I sort of agree, the way Undraft does it is a bit weird, just pulling a Pkg.t like a rabbit out of a hat.
In e2230618a5f6f70289c1e4d9404466e8afcb3297 I had an approach which for each Pkg.t you could ask whether it is the main Pkg.t. I wasn't particularly fond of that API, but maybe that's a bit better?
On the other thing, maybe something like
main_pkg : Pkg.t -> Pkg.t option
would be more sensible?
One could also envision something like main_pkg : unit -> Pkg.t option but that's pretty much Pkg.v already.
I had something like main_package_name: Pkg.t -> string or main_package_name: Repo.t -> string` in mind since that's what we want here right?
We might need more than the name and working on a main_package: Repo.t -> Pkg.t in the future might prove useful, for instance to get the package description when we open a PR for multi opam repos' releases.