-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Prevent tests from trying to sign
Set git config on test repos to avoid signing commits and tags.
- Loading branch information
1 parent
d88de13
commit 4c901a5
Showing
6 changed files
with
37 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -172,6 +172,13 @@ public void initRepository() throws IOException, GitAPIException { | |
.setDirectory(repoDir.toFile()) | ||
.call(); | ||
|
||
var config = git.getRepository().getConfig(); | ||
config.setString("user", null, "name", "Some Person"); | ||
config.setString("user", null, "email", "[email protected]"); | ||
config.setString("commit", null, "gpgSign", "false"); | ||
config.setString("tag", null, "gpgSign", "false"); | ||
config.save(); | ||
|
||
var initialBranch = git.getRepository().getBranch(); | ||
|
||
commit(); | ||
|
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 |
---|---|---|
|
@@ -56,6 +56,13 @@ public void setupRepo() throws IOException, GitAPIException { | |
repoDir = Files.createTempDirectory("repo"); | ||
git = Git.init().setDirectory(repoDir.toFile()).call(); | ||
initialBranch = git.getRepository().getBranch(); | ||
|
||
var config = git.getRepository().getConfig(); | ||
config.setString("user", null, "name", "Some Person"); | ||
config.setString("user", null, "email", "[email protected]"); | ||
config.setString("commit", null, "gpgSign", "false"); | ||
config.setString("tag", null, "gpgSign", "false"); | ||
config.save(); | ||
} | ||
|
||
@AfterEach | ||
|
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
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.UncheckedIOException; | ||
import java.net.URISyntaxException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
@@ -14,9 +15,24 @@ | |
public final class Gits { | ||
private static final SecureRandom random = new SecureRandom(); | ||
|
||
public static void resetConfig(Git git) { | ||
try { | ||
var config = git.getRepository().getConfig(); | ||
config.setString("user", null, "name", "Some Person"); | ||
config.setString("user", null, "email", "[email protected]"); | ||
config.setString("commit", null, "gpgSign", "false"); | ||
config.setString("tag", null, "gpgSign", "false"); | ||
config.save(); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
|
||
public static Git clone(File dir, Git origin) throws GitAPIException { | ||
var uri = origin.getRepository().getDirectory().getAbsolutePath(); | ||
return Git.cloneRepository().setDirectory(dir).setURI(uri).setCloneAllBranches(true).setNoCheckout(false).call(); | ||
var git = Git.cloneRepository().setDirectory(dir).setURI(uri).setCloneAllBranches(true).setNoCheckout(false).call(); | ||
resetConfig(git); | ||
return git; | ||
} | ||
|
||
public static Path repoFile(Git git, String path) throws IOException { | ||
|
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