haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 696 forks source link

Warn about overly many `source-repository` stanzas #10574

Open philderbeast opened 1 day ago

philderbeast commented 1 day ago

Can we have cabal check warn if there is more than one source-repository head or more than one source-repository this stanza?

I ran a quick cabal check and we can have as many source-repository stanza as we please. The following passes cabal check;

$ git diff
diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal
index f842d4d31..afc1101b9 100644
--- a/cabal-install/cabal-install.cabal
+++ b/cabal-install/cabal-install.cabal
@@ -26,6 +26,23 @@ source-repository head
   location: https://github.com/haskell/cabal/
   subdir:   cabal-install

+source-repository head
+  type:     git
+  location: https://gitlab.com/haskell/cabal/
+  subdir:   cabal-install
+
+source-repository this
+  type:     git
+  location: https://github.com/haskell/cabal/
+  tag:      v3.11.0.0
+  subdir:   cabal-install
+
+source-repository this
+  type:     git
+  location: https://gitlab.com/haskell/cabal/
+  tag:      v3.11.0.0
+  subdir:   cabal-install

Originally posted by @philderbeast in https://github.com/haskell/cabal/issues/9655#issuecomment-1907990554

ffaf1 commented 1 day ago

Interestingly enough, PackageDescription allows more SourceRepos:

https://github.com/haskell/cabal/blob/c3a9dd7722335900619d64ad19be79ec5b7cf402/Cabal-syntax/src/Distribution/Types/PackageDescription.hs#L121

I wonder whether there is a legitimate use-case for multiple repos.

ulysses4ever commented 1 day ago

It's pretty clear to me that at least two should be allowed, as long one is head and one is this (not that I think it's a great idea to have both). If we could emit a soft warning on the repetitive head or this, that would be an (admittedly slight) improvement.