Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCS tests: Quieter output #10587

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/VCS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ vcsGit =
-- is needed because sometimes `git submodule sync` does not actually
-- update the submodule source URL. Detailed description here:
-- https://git.coop/-/snippets/85
git localDir ["submodule", "deinit", "--force", "--all"]
git localDir $ ["submodule", "deinit", "--force", "--all"] ++ verboseArg
let gitModulesDir = localDir </> ".git" </> "modules"
gitModulesExists <- doesDirectoryExist gitModulesDir
when gitModulesExists $
Expand Down
26 changes: 17 additions & 9 deletions cabal-install/tests/UnitTests/Distribution/Client/VCS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -878,17 +878,18 @@ vcsTestDriverGit verbosity vcs submoduleDir repoRoot =
(||)
<$> doesFileExist (repoRoot </> dest)
<*> doesDirectoryExist (repoRoot </> dest)
when destExists $ git ["rm", "-f", dest]
when destExists $ gitQuiet ["rm", "--force", dest]
-- If there is an old submodule git dir with the same name, remove it.
-- It most likely has a different URL and `git submodule add` will fai.
submoduleGitDirExists <- doesDirectoryExist $ submoduleGitDir dest
when submoduleGitDirExists $ removeDirectoryRecursive (submoduleGitDir dest)
git ["submodule", "add", source, dest]
git ["submodule", "update", "--init", "--recursive", "--force"]
gitQuiet ["submodule", "add", source, dest]
gitQuiet ["submodule", "update", "--init", "--recursive", "--force"]
, vcsSwitchBranch = \RepoState{allBranches} branchname -> do
deinitAndRemoveCachedSubmodules
unless (branchname `Map.member` allBranches) $
git ["branch", branchname]
git $
["branch", branchname] ++ verboseArg
git $ ["checkout", branchname] ++ verboseArg
updateSubmodulesAndCleanup
, vcsCheckoutTag = Left $ \tagname -> do
Expand All @@ -915,24 +916,31 @@ vcsTestDriverGit verbosity vcs submoduleDir repoRoot =
]
}
}

gitInvocation args =
(programInvocation (vcsProgram vcs') args)
{ progInvokeCwd = Just repoRoot
}

git = runProgramInvocation verbosity . gitInvocation
git' = getProgramInvocationOutput verbosity . gitInvocation

gitQuiet [] = git []
gitQuiet (cmd : args) = git (cmd : verboseArg ++ args)

verboseArg = ["--quiet" | verbosity < Verbosity.normal]

submoduleGitDir path = repoRoot </> ".git" </> "modules" </> path
deinitAndRemoveCachedSubmodules = do
git $ ["submodule", "deinit", "--force", "--all"] ++ verboseArg
gitQuiet ["submodule", "deinit", "--force", "--all"]
let gitModulesDir = repoRoot </> ".git" </> "modules"
gitModulesExists <- doesDirectoryExist gitModulesDir
when gitModulesExists $ removeDirectoryRecursive gitModulesDir
updateSubmodulesAndCleanup = do
git $ ["submodule", "sync", "--recursive"] ++ verboseArg
git $ ["submodule", "update", "--init", "--recursive", "--force"] ++ verboseArg
git $ ["submodule", "foreach", "--recursive"] ++ verboseArg ++ ["git clean -ffxdq"]
git $ ["clean", "-ffxdq"] ++ verboseArg
gitQuiet ["submodule", "sync", "--recursive"]
gitQuiet ["submodule", "update", "--init", "--recursive", "--force"]
gitQuiet $ ["submodule", "foreach", "--recursive", "git clean -ffxdq"] ++ verboseArg
gitQuiet ["clean", "-ffxdq"]

type MTimeChange = Int

Expand Down
12 changes: 12 additions & 0 deletions changelog.d/pr-10587
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
synopsis: "Quieter Git output"
packages: [cabal-install]
prs: 10587
---

When `cabal` clones a Git repo for a `source-repository-package` listed in a
`cabal.project`, it will run various commands to check out the correct
revision, initialize submodules if they're present, and so on.

Now, `cabal` will pass `--quiet` to Git in more cases to help prevent
cluttering command-line output.
Loading