-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't read configuration files, set a consistent date for commits, and pass a tempdir as the home directory. This will prevent the test suite from attempting to GPG-sign commits in the tests!
- Loading branch information
Showing
1 changed file
with
25 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -850,23 +850,22 @@ vcsTestDriverGit | |
{ vcsVCS = vcs' | ||
, vcsRepoRoot = repoRoot | ||
, vcsIgnoreFiles = Set.empty | ||
, vcsInit = | ||
, vcsInit = do | ||
createDirectoryIfMissing True home | ||
gitconfigExists <- doesFileExist gitconfigPath | ||
unless gitconfigExists $ do | ||
writeFile gitconfigPath gitconfig | ||
git $ ["init"] ++ verboseArg | ||
, vcsAddFile = \_ filename -> | ||
git ["add", filename] | ||
, vcsCommitChanges = \_state -> do | ||
git $ | ||
[ "-c" | ||
, "user.name=A" | ||
, "-c" | ||
, "[email protected]" | ||
, "commit" | ||
[ "commit" | ||
, "--all" | ||
, "--message=a patch" | ||
, "--author=A <[email protected]>" | ||
] | ||
++ verboseArg | ||
commit <- git' ["log", "--format=%H", "-1"] | ||
commit <- git' ["rev-parse", "HEAD"] | ||
let commit' = takeWhile (not . isSpace) commit | ||
return (Just commit') | ||
, vcsTagState = \_ tagname -> | ||
|
@@ -906,21 +905,35 @@ vcsTestDriverGit | |
updateSubmodulesAndCleanup | ||
} | ||
where | ||
home = tmpDir </> "home" | ||
gitconfigPath = home </> ".gitconfig" | ||
-- Git 2.38.1 and newer fails to clone from local paths with `fatal: transport 'file' | ||
-- not allowed` unless `protocol.file.allow=always` is set. | ||
-- | ||
-- This is not safe in general, but it's fine in the test suite. | ||
-- | ||
-- See: https://github.blog/open-source/git/git-security-vulnerabilities-announced/#fn-67904-1 | ||
-- See: https://git-scm.com/docs/git-config#Documentation/git-config.txt-protocolallow | ||
gitconfig = | ||
"[protocol.file]\n\ | ||
\allow = always\n\ | ||
\[user]\n\ | ||
\name = Puppy Doggy\n\ | ||
\email = [email protected]\n" | ||
|
||
vcs' = | ||
vcs | ||
{ vcsProgram = | ||
(vcsProgram vcs) | ||
{ programDefaultArgs = | ||
programDefaultArgs (vcsProgram vcs) | ||
++ [ "-c" | ||
, "protocol.file.allow=always" | ||
{ programOverrideEnv = | ||
programOverrideEnv (vcsProgram vcs) | ||
++ [ -- > Whether to skip reading settings from the system-wide $(prefix)/etc/gitconfig file. | ||
("GIT_CONFIG_NOSYSTEM", Just "1") | ||
, ("GIT_CONFIG_GLOBAL", Just gitconfigPath) | ||
, -- Setting the author and committer dates makes commit hashes deterministic between test runs. | ||
("GIT_AUTHOR_DATE", Just "1998-04-30T18:25:03-0400") | ||
, ("GIT_COMMITTER_DATE", Just "1998-04-30T18:25:00-0400") | ||
, ("HOME", Just home) | ||
] | ||
} | ||
} | ||
|