Skip to content

Commit ec2bb0c

Browse files
committed
VCS tests: Quieter output
This prevents the tests from spamming lots of output, making it easier to watch them as they run. Before: ``` check VCS test framework: 10% warning: refname 'd6077f476a7c17fe8528e62688a19cc5bddbfbdc' is ambiguous. Git normally never creates a ref that ends with 40 hex characters because it will be ignored when you just specify 40-hex. These refs may be created by mistake. For example, git switch -c $br $(git rev-parse ...) where "$br" is somehow empty and a 40-hex ref is created. Please examine these refs and maybe delete them. Turn this message off by running "git config advice.objectNameWarning false" rm 'file/C' Cloning into '/private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/vcstest-64269/src/file/C'... done. Submodule path 'file/C': checked out '210af0166ade8b306b425782305b8c6e910aa2c0' Cloning into '/private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/vcstest-64267/src/file/D'... done. Submodule path 'file/D': checked out '95b580ef06aec22b38f6e0a5c3305d5c293669a0' branch 'branch_D' set up to track 'main'. branch 'branch_C' set up to track 'main'. rm 'file/C' Cloning into '/private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/vcstest-64269/src/file/C'... done. rm 'file/D' Submodule path 'file/C': checked out 'ee47ffdda57945d841bc7f59ea72a78043c4ac02' Cloning into '/private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/vcstest-64267/src/file/D'... done. Submodule path 'file/D': checked out '23d9b5f39ae56c429dd9498d42338d27ea4e6545' ``` After: ``` UnitTests.Distribution.Client.VCS git check VCS test framework: warning: --depth is ignored in local clones; use file:// instead. warning: refname 'fbfe708a98c79a7c97e83609275b0f604f26e18b' is ambiguous. Git normally never creates a ref that ends with 40 hex characters because it will be ignored when you just specify 40-hex. These refs may be created by mistake. For example, git switch -c $br $(git rev-parse ...) where "$br" is somehow empty and a 40-hex ref is created. Please examine these refs and maybe delete them. Turn this message off by running "git config advice.objectNameWarning false" warning: --depth is ignored in local clones; use file:// instead. warning: --depth is ignored in local clones; use file:// instead. warning: refname 'dc2abca0fd032b5cdd8904e6931679b4d6e6b25b' is ambiguous. Git normally never creates a ref that ends with 40 hex characters because it will be ignored when you just specify 40-hex. These refs may be created by mistake. For example, git switch -c $br $(git rev-parse ...) where "$br" is somehow empty and a 40-hex ref is created. Please examine these refs and maybe delete them. Turn this message off by running "git config advice.objectNameWarning false" ``` These warnings require semantic changes which will come in a separate PR.
1 parent 55ccc0a commit ec2bb0c

File tree

3 files changed

+34
-15
lines changed
  • cabal-install
    • src/Distribution/Client
    • tests/UnitTests/Distribution/Client
  • changelog.d

3 files changed

+34
-15
lines changed

cabal-install/src/Distribution/Client/VCS.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ vcsGit =
516516
-- is needed because sometimes `git submodule sync` does not actually
517517
-- update the submodule source URL. Detailed description here:
518518
-- https://git.coop/-/snippets/85
519-
git localDir ["submodule", "deinit", "--force", "--all"]
519+
git localDir $ ["submodule", "deinit", "--force", "--all"] ++ verboseArg
520520
let gitModulesDir = localDir </> ".git" </> "modules"
521521
gitModulesExists <- doesDirectoryExist gitModulesDir
522522
when gitModulesExists $

cabal-install/tests/UnitTests/Distribution/Client/VCS.hs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -897,16 +897,15 @@ vcsTestDriverGit
897897
gitconfigExists <- doesFileExist gitconfigPath
898898
unless gitconfigExists $ do
899899
writeFile gitconfigPath gitconfig
900-
git $ ["init"] ++ verboseArg
900+
gitQuiet ["init"]
901901
, vcsAddFile = \_ filename ->
902902
git ["add", filename]
903903
, vcsCommitChanges = \_state -> do
904-
git $
904+
gitQuiet
905905
[ "commit"
906906
, "--all"
907907
, "--message=a patch"
908908
]
909-
++ verboseArg
910909
commit <- git' ["rev-parse", "HEAD"]
911910
let commit' = takeWhile (not . isSpace) commit
912911
return (Just commit')
@@ -928,22 +927,22 @@ vcsTestDriverGit
928927
(||)
929928
<$> doesFileExist (repoRoot </> dest)
930929
<*> doesDirectoryExist (repoRoot </> dest)
931-
when destExists $ git ["rm", "-f", dest]
930+
when destExists $ gitQuiet ["rm", "--force", dest]
932931
-- If there is an old submodule git dir with the same name, remove it.
933932
-- It most likely has a different URL and `git submodule add` will fai.
934933
submoduleGitDirExists <- doesDirectoryExist $ submoduleGitDir dest
935934
when submoduleGitDirExists $ removeDirectoryRecursive (submoduleGitDir dest)
936-
git ["submodule", "add", source, dest]
937-
git ["submodule", "update", "--init", "--recursive", "--force"]
935+
gitQuiet ["submodule", "add", source, dest]
936+
gitQuiet ["submodule", "update", "--init", "--recursive", "--force"]
938937
, vcsSwitchBranch = \RepoState{allBranches} branchname -> do
939938
deinitAndRemoveCachedSubmodules
940939
unless (branchname `Map.member` allBranches) $
941-
git ["branch", branchname]
942-
git $ ["checkout", branchname] ++ verboseArg
940+
gitQuiet ["branch", branchname]
941+
gitQuiet ["checkout", branchname]
943942
updateSubmodulesAndCleanup
944943
, vcsCheckoutTag = Left $ \tagname -> do
945944
deinitAndRemoveCachedSubmodules
946-
git $ ["checkout", "--detach", "--force", tagname] ++ verboseArg
945+
gitQuiet ["checkout", "--detach", "--force", tagname]
947946
updateSubmodulesAndCleanup
948947
}
949948
where
@@ -981,24 +980,32 @@ vcsTestDriverGit
981980
]
982981
}
983982
}
983+
984984
gitInvocation args =
985985
(programInvocation (vcsProgram vcs') args)
986986
{ progInvokeCwd = Just repoRoot
987987
}
988+
988989
git = runProgramInvocation verbosity . gitInvocation
989990
git' = getProgramInvocationOutput verbosity . gitInvocation
991+
992+
gitQuiet [] = git []
993+
gitQuiet (cmd : args) = git (cmd : verboseArg ++ args)
994+
990995
verboseArg = ["--quiet" | verbosity < Verbosity.normal]
996+
991997
submoduleGitDir path = repoRoot </> ".git" </> "modules" </> path
992998
deinitAndRemoveCachedSubmodules = do
993-
git $ ["submodule", "deinit", "--force", "--all"] ++ verboseArg
999+
gitQuiet ["submodule", "deinit", "--force", "--all"]
9941000
let gitModulesDir = repoRoot </> ".git" </> "modules"
9951001
gitModulesExists <- doesDirectoryExist gitModulesDir
9961002
when gitModulesExists $ removeDirectoryRecursive gitModulesDir
9971003
updateSubmodulesAndCleanup = do
998-
git $ ["submodule", "sync", "--recursive"] ++ verboseArg
999-
git $ ["submodule", "update", "--init", "--recursive", "--force"] ++ verboseArg
1000-
git $ ["submodule", "foreach", "--recursive"] ++ verboseArg ++ ["git clean -ffxdq"]
1001-
git $ ["clean", "-ffxdq"] ++ verboseArg
1004+
gitQuiet ["submodule", "sync", "--recursive"]
1005+
gitQuiet ["submodule", "update", "--init", "--recursive", "--force"]
1006+
-- Note: We need to manually add `verboseArg` here so that the embedded `git clean` command includes it as well.
1007+
gitQuiet $ ["submodule", "foreach", "--recursive", "git clean -ffxdq"] ++ verboseArg
1008+
gitQuiet ["clean", "-ffxdq"]
10021009

10031010
type MTimeChange = Int
10041011

changelog.d/pr-10587

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
synopsis: "Quieter Git output"
3+
packages: [cabal-install]
4+
prs: 10587
5+
---
6+
7+
When `cabal` clones a Git repo for a `source-repository-package` listed in a
8+
`cabal.project`, it will run various commands to check out the correct
9+
revision, initialize submodules if they're present, and so on.
10+
11+
Now, `cabal` will pass `--quiet` to Git in more cases to help prevent
12+
cluttering command-line output.

0 commit comments

Comments
 (0)