Create an example submodule repository (#153)

Summary:
We want our main repository to include submodules so that we can test
submodule support. Here, we create a repository to be included as a
submodule.

wchargin-branch: example-submodule-repository
This commit is contained in:
William Chargin 2018-04-26 19:43:01 -07:00 committed by GitHub
parent 75fd068a35
commit 28a118c814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 1 deletions

View File

@ -8,3 +8,10 @@ Array [
"677b340674bde17fdaac3b5f5eef929139ef2a52",
]
`;
exports[`createExampleSubmoduleRepo is deterministic 1`] = `
Array [
"762c062fbdc7ec198cd693e95d55b374a08ff3e3",
"29ef158bc982733e2ba429fcf73e2f7562244188",
]
`;

View File

@ -44,3 +44,37 @@ export function createExampleRepo(intoDirectory: string): RepositoryInfo {
return {path: repositoryPath, commits};
}
/**
* Create the example repository that should be included as a submodule
* in a larger repository. (This repository does not itself have
* submodules.)
*/
export function createExampleSubmoduleRepo(
intoDirectory: string
): RepositoryInfo {
const repositoryPath = intoDirectory;
mkdirp(repositoryPath);
const git = makeUtils(repositoryPath);
const commits = [];
git.exec(["init"]);
git.writeAndStage(
"README.txt",
[
"example-git-submodule\n",
"---------------------\n\n",
"This simple repository serves no purpose other than to be included as\n",
"a submodule in a larger repository.\n",
].join("")
);
git.deterministicCommit("Initial commit");
commits.push(git.head());
git.writeAndStage("useless.txt", "Nothing to see here; move along.\n");
git.deterministicCommit("Add a file, so that we have multiple commits");
commits.push(git.head());
return {path: repositoryPath, commits};
}

View File

@ -2,7 +2,7 @@
import tmp from "tmp";
import {createExampleRepo} from "./exampleRepo";
import {createExampleRepo, createExampleSubmoduleRepo} from "./exampleRepo";
const cleanups: (() => void)[] = [];
afterAll(() => {
@ -22,3 +22,9 @@ describe("createExampleRepo", () => {
expect(createExampleRepo(mkdtemp()).commits).toMatchSnapshot();
});
});
describe("createExampleSubmoduleRepo", () => {
it("is deterministic", () => {
expect(createExampleSubmoduleRepo(mkdtemp()).commits).toMatchSnapshot();
});
});