Check in example repo’s in-memory representation (#166)
Summary: Two reasons for this. First, we want tests to be able to operate on this data without having to generate repositories via `git(1)`. (Doing that is slow, and requires a Git installation, and makes it less clear that the tests are correctly isolated/provides more surface area for something to go wrong.) Second, in general plugins will need a canonical source of test data, so setting/continuing this precedent is a good thing. Test Plan: Observe that the old Jest snapshot must be equivalent to the new JSON one, because the test criterion in `loadRepository.test.js` changed and the test still passes. Then, run `loadRepositoryTest.sh` and note that it passes; change the `example-git.json` file and note that the test fails when re-run; then, run the test with `--updateSnapshot` and watch it magically revert your changes. wchargin-branch: check-in-git-repo
This commit is contained in:
parent
301e542ee1
commit
1c28c75e39
|
@ -63,5 +63,8 @@ module.exports = {
|
|||
"src/plugins/github/bin/fetchAndPrintGithubRepo.js"
|
||||
),
|
||||
createExampleRepo: resolveApp("src/plugins/git/bin/createExampleRepo.js"),
|
||||
loadAndPrintGitRepository: resolveApp(
|
||||
"src/plugins/git/bin/loadAndPrintRepository.js"
|
||||
),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,257 +1,5 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`loadRepository loads from HEAD 1`] = `
|
||||
Object {
|
||||
"commits": Object {
|
||||
"3715ddfb8d4c4fd2a6f6af75488c82f84c92ec2f": Object {
|
||||
"hash": "3715ddfb8d4c4fd2a6f6af75488c82f84c92ec2f",
|
||||
"treeHash": "7be3ecfee5314ffa9b2d93fc4377792b2d6d70ed",
|
||||
},
|
||||
"69c5aad50eec8f2a0a07c988c3b283a6490eb45b": Object {
|
||||
"hash": "69c5aad50eec8f2a0a07c988c3b283a6490eb45b",
|
||||
"treeHash": "bbf3b8b3d26a4f884b5c022d46851f593d329192",
|
||||
},
|
||||
"8d287c3bfbf8455ef30187bf5153ffc1b6eef268": Object {
|
||||
"hash": "8d287c3bfbf8455ef30187bf5153ffc1b6eef268",
|
||||
"treeHash": "3dfb84795e07341b05fad3a0d5a55f8304b2d7d8",
|
||||
},
|
||||
"c08ee3a4edea384d5291ffcbf06724a13ed72325": Object {
|
||||
"hash": "c08ee3a4edea384d5291ffcbf06724a13ed72325",
|
||||
"treeHash": "2f7155e359fd0ecb96ffdca66fa45b6ed5792809",
|
||||
},
|
||||
"c2b51945e7457546912a8ce158ed9d294558d294": Object {
|
||||
"hash": "c2b51945e7457546912a8ce158ed9d294558d294",
|
||||
"treeHash": "bdff5d94193170015d6cbb549b7b630649428b1f",
|
||||
},
|
||||
"d160cca97611e9dfed642522ad44408d0292e8ea": Object {
|
||||
"hash": "d160cca97611e9dfed642522ad44408d0292e8ea",
|
||||
"treeHash": "569e1d383759903134df75230d63c0090196d4cb",
|
||||
},
|
||||
"e8b7a8f19701cd5a25e4a097d513ead60e5f8bcc": Object {
|
||||
"hash": "e8b7a8f19701cd5a25e4a097d513ead60e5f8bcc",
|
||||
"treeHash": "819fc546cea489476ce8dc90785e9ba7753d0a8f",
|
||||
},
|
||||
},
|
||||
"trees": Object {
|
||||
"2f7155e359fd0ecb96ffdca66fa45b6ed5792809": Object {
|
||||
"entries": Object {
|
||||
"README.txt": Object {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"science.txt": Object {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
},
|
||||
"hash": "2f7155e359fd0ecb96ffdca66fa45b6ed5792809",
|
||||
},
|
||||
"3dfb84795e07341b05fad3a0d5a55f8304b2d7d8": Object {
|
||||
"entries": Object {
|
||||
".gitmodules": Object {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob",
|
||||
},
|
||||
"README.txt": Object {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"pygravitydefier": Object {
|
||||
"hash": "762c062fbdc7ec198cd693e95d55b374a08ff3e3",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit",
|
||||
},
|
||||
"science.txt": Object {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
},
|
||||
"hash": "3dfb84795e07341b05fad3a0d5a55f8304b2d7d8",
|
||||
},
|
||||
"569e1d383759903134df75230d63c0090196d4cb": Object {
|
||||
"entries": Object {
|
||||
".gitmodules": Object {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob",
|
||||
},
|
||||
"README.txt": Object {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"TODOS.txt": Object {
|
||||
"hash": "ddec7477206c30c31b81482e56b877a0b3c2638b",
|
||||
"name": "TODOS.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"pygravitydefier": Object {
|
||||
"hash": "762c062fbdc7ec198cd693e95d55b374a08ff3e3",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit",
|
||||
},
|
||||
"science.txt": Object {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"src": Object {
|
||||
"hash": "7b79d579b62994faba3b69fdf8aa442586c32681",
|
||||
"name": "src",
|
||||
"type": "tree",
|
||||
},
|
||||
},
|
||||
"hash": "569e1d383759903134df75230d63c0090196d4cb",
|
||||
},
|
||||
"78fc9c83023386854c6bfdc5761c0e58f68e226f": Object {
|
||||
"entries": Object {
|
||||
"index.py": Object {
|
||||
"hash": "674b0b476989384510304846248b3acd16206782",
|
||||
"name": "index.py",
|
||||
"type": "blob",
|
||||
},
|
||||
"quantum_gravity.py": Object {
|
||||
"hash": "aea4f28abb23abde151b0ead4063227f8bf6c0b0",
|
||||
"name": "quantum_gravity.py",
|
||||
"type": "blob",
|
||||
},
|
||||
},
|
||||
"hash": "78fc9c83023386854c6bfdc5761c0e58f68e226f",
|
||||
},
|
||||
"7b79d579b62994faba3b69fdf8aa442586c32681": Object {
|
||||
"entries": Object {
|
||||
"index.py": Object {
|
||||
"hash": "674b0b476989384510304846248b3acd16206782",
|
||||
"name": "index.py",
|
||||
"type": "blob",
|
||||
},
|
||||
"quantum_gravity.py": Object {
|
||||
"hash": "887ad856bbc1373da146106c86cb581ad78cdafe",
|
||||
"name": "quantum_gravity.py",
|
||||
"type": "blob",
|
||||
},
|
||||
},
|
||||
"hash": "7b79d579b62994faba3b69fdf8aa442586c32681",
|
||||
},
|
||||
"7be3ecfee5314ffa9b2d93fc4377792b2d6d70ed": Object {
|
||||
"entries": Object {
|
||||
".gitmodules": Object {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob",
|
||||
},
|
||||
"README.txt": Object {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"pygravitydefier": Object {
|
||||
"hash": "29ef158bc982733e2ba429fcf73e2f7562244188",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit",
|
||||
},
|
||||
"science.txt": Object {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"src": Object {
|
||||
"hash": "78fc9c83023386854c6bfdc5761c0e58f68e226f",
|
||||
"name": "src",
|
||||
"type": "tree",
|
||||
},
|
||||
},
|
||||
"hash": "7be3ecfee5314ffa9b2d93fc4377792b2d6d70ed",
|
||||
},
|
||||
"819fc546cea489476ce8dc90785e9ba7753d0a8f": Object {
|
||||
"entries": Object {
|
||||
".gitmodules": Object {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob",
|
||||
},
|
||||
"README.txt": Object {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"TODOS.txt": Object {
|
||||
"hash": "ddec7477206c30c31b81482e56b877a0b3c2638b",
|
||||
"name": "TODOS.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"pygravitydefier": Object {
|
||||
"hash": "29ef158bc982733e2ba429fcf73e2f7562244188",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit",
|
||||
},
|
||||
"science.txt": Object {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"src": Object {
|
||||
"hash": "7b79d579b62994faba3b69fdf8aa442586c32681",
|
||||
"name": "src",
|
||||
"type": "tree",
|
||||
},
|
||||
},
|
||||
"hash": "819fc546cea489476ce8dc90785e9ba7753d0a8f",
|
||||
},
|
||||
"bbf3b8b3d26a4f884b5c022d46851f593d329192": Object {
|
||||
"entries": Object {
|
||||
".gitmodules": Object {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob",
|
||||
},
|
||||
"README.txt": Object {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"TODOS.txt": Object {
|
||||
"hash": "ddec7477206c30c31b81482e56b877a0b3c2638b",
|
||||
"name": "TODOS.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"pygravitydefier": Object {
|
||||
"hash": "29ef158bc982733e2ba429fcf73e2f7562244188",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit",
|
||||
},
|
||||
"science.txt": Object {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
"src": Object {
|
||||
"hash": "78fc9c83023386854c6bfdc5761c0e58f68e226f",
|
||||
"name": "src",
|
||||
"type": "tree",
|
||||
},
|
||||
},
|
||||
"hash": "bbf3b8b3d26a4f884b5c022d46851f593d329192",
|
||||
},
|
||||
"bdff5d94193170015d6cbb549b7b630649428b1f": Object {
|
||||
"entries": Object {
|
||||
"README.txt": Object {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob",
|
||||
},
|
||||
},
|
||||
"hash": "bdff5d94193170015d6cbb549b7b630649428b1f",
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`loadRepository processes an old commit 1`] = `
|
||||
Object {
|
||||
"commits": Set {
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Command-line utility to load a Git repository into memory and then
|
||||
* print the resulting JSON representation.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* node bin/loadAndPrintGitRepository.js PATH [ROOT_REF]
|
||||
*
|
||||
* where PATH is the path on disk to a Git repository, and ROOT_REF is
|
||||
* the revision to load (defaults to HEAD).
|
||||
*/
|
||||
// @flow
|
||||
|
||||
import stringify from "json-stable-stringify";
|
||||
|
||||
import {loadRepository} from "../loadRepository";
|
||||
|
||||
function parseArgs() {
|
||||
const argv = process.argv.slice(2);
|
||||
if (argv.length !== 1 && argv.length !== 2) {
|
||||
const invocation = process.argv.slice(0, 2).join(" ");
|
||||
throw new Error(`Usage: ${invocation} PATH`);
|
||||
}
|
||||
return {
|
||||
repositoryPath: argv[0],
|
||||
rootRef: argv.length > 1 ? argv[1] : "HEAD",
|
||||
};
|
||||
}
|
||||
|
||||
function main() {
|
||||
const args = parseArgs();
|
||||
const result = loadRepository(args.repositoryPath, args.rootRef);
|
||||
console.log(stringify(result, {space: 4}));
|
||||
}
|
||||
|
||||
main();
|
|
@ -0,0 +1,249 @@
|
|||
{
|
||||
"commits": {
|
||||
"3715ddfb8d4c4fd2a6f6af75488c82f84c92ec2f": {
|
||||
"hash": "3715ddfb8d4c4fd2a6f6af75488c82f84c92ec2f",
|
||||
"treeHash": "7be3ecfee5314ffa9b2d93fc4377792b2d6d70ed"
|
||||
},
|
||||
"69c5aad50eec8f2a0a07c988c3b283a6490eb45b": {
|
||||
"hash": "69c5aad50eec8f2a0a07c988c3b283a6490eb45b",
|
||||
"treeHash": "bbf3b8b3d26a4f884b5c022d46851f593d329192"
|
||||
},
|
||||
"8d287c3bfbf8455ef30187bf5153ffc1b6eef268": {
|
||||
"hash": "8d287c3bfbf8455ef30187bf5153ffc1b6eef268",
|
||||
"treeHash": "3dfb84795e07341b05fad3a0d5a55f8304b2d7d8"
|
||||
},
|
||||
"c08ee3a4edea384d5291ffcbf06724a13ed72325": {
|
||||
"hash": "c08ee3a4edea384d5291ffcbf06724a13ed72325",
|
||||
"treeHash": "2f7155e359fd0ecb96ffdca66fa45b6ed5792809"
|
||||
},
|
||||
"c2b51945e7457546912a8ce158ed9d294558d294": {
|
||||
"hash": "c2b51945e7457546912a8ce158ed9d294558d294",
|
||||
"treeHash": "bdff5d94193170015d6cbb549b7b630649428b1f"
|
||||
},
|
||||
"d160cca97611e9dfed642522ad44408d0292e8ea": {
|
||||
"hash": "d160cca97611e9dfed642522ad44408d0292e8ea",
|
||||
"treeHash": "569e1d383759903134df75230d63c0090196d4cb"
|
||||
},
|
||||
"e8b7a8f19701cd5a25e4a097d513ead60e5f8bcc": {
|
||||
"hash": "e8b7a8f19701cd5a25e4a097d513ead60e5f8bcc",
|
||||
"treeHash": "819fc546cea489476ce8dc90785e9ba7753d0a8f"
|
||||
}
|
||||
},
|
||||
"trees": {
|
||||
"2f7155e359fd0ecb96ffdca66fa45b6ed5792809": {
|
||||
"entries": {
|
||||
"README.txt": {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"science.txt": {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob"
|
||||
}
|
||||
},
|
||||
"hash": "2f7155e359fd0ecb96ffdca66fa45b6ed5792809"
|
||||
},
|
||||
"3dfb84795e07341b05fad3a0d5a55f8304b2d7d8": {
|
||||
"entries": {
|
||||
".gitmodules": {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob"
|
||||
},
|
||||
"README.txt": {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"pygravitydefier": {
|
||||
"hash": "762c062fbdc7ec198cd693e95d55b374a08ff3e3",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit"
|
||||
},
|
||||
"science.txt": {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob"
|
||||
}
|
||||
},
|
||||
"hash": "3dfb84795e07341b05fad3a0d5a55f8304b2d7d8"
|
||||
},
|
||||
"569e1d383759903134df75230d63c0090196d4cb": {
|
||||
"entries": {
|
||||
".gitmodules": {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob"
|
||||
},
|
||||
"README.txt": {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"TODOS.txt": {
|
||||
"hash": "ddec7477206c30c31b81482e56b877a0b3c2638b",
|
||||
"name": "TODOS.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"pygravitydefier": {
|
||||
"hash": "762c062fbdc7ec198cd693e95d55b374a08ff3e3",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit"
|
||||
},
|
||||
"science.txt": {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"src": {
|
||||
"hash": "7b79d579b62994faba3b69fdf8aa442586c32681",
|
||||
"name": "src",
|
||||
"type": "tree"
|
||||
}
|
||||
},
|
||||
"hash": "569e1d383759903134df75230d63c0090196d4cb"
|
||||
},
|
||||
"78fc9c83023386854c6bfdc5761c0e58f68e226f": {
|
||||
"entries": {
|
||||
"index.py": {
|
||||
"hash": "674b0b476989384510304846248b3acd16206782",
|
||||
"name": "index.py",
|
||||
"type": "blob"
|
||||
},
|
||||
"quantum_gravity.py": {
|
||||
"hash": "aea4f28abb23abde151b0ead4063227f8bf6c0b0",
|
||||
"name": "quantum_gravity.py",
|
||||
"type": "blob"
|
||||
}
|
||||
},
|
||||
"hash": "78fc9c83023386854c6bfdc5761c0e58f68e226f"
|
||||
},
|
||||
"7b79d579b62994faba3b69fdf8aa442586c32681": {
|
||||
"entries": {
|
||||
"index.py": {
|
||||
"hash": "674b0b476989384510304846248b3acd16206782",
|
||||
"name": "index.py",
|
||||
"type": "blob"
|
||||
},
|
||||
"quantum_gravity.py": {
|
||||
"hash": "887ad856bbc1373da146106c86cb581ad78cdafe",
|
||||
"name": "quantum_gravity.py",
|
||||
"type": "blob"
|
||||
}
|
||||
},
|
||||
"hash": "7b79d579b62994faba3b69fdf8aa442586c32681"
|
||||
},
|
||||
"7be3ecfee5314ffa9b2d93fc4377792b2d6d70ed": {
|
||||
"entries": {
|
||||
".gitmodules": {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob"
|
||||
},
|
||||
"README.txt": {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"pygravitydefier": {
|
||||
"hash": "29ef158bc982733e2ba429fcf73e2f7562244188",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit"
|
||||
},
|
||||
"science.txt": {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"src": {
|
||||
"hash": "78fc9c83023386854c6bfdc5761c0e58f68e226f",
|
||||
"name": "src",
|
||||
"type": "tree"
|
||||
}
|
||||
},
|
||||
"hash": "7be3ecfee5314ffa9b2d93fc4377792b2d6d70ed"
|
||||
},
|
||||
"819fc546cea489476ce8dc90785e9ba7753d0a8f": {
|
||||
"entries": {
|
||||
".gitmodules": {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob"
|
||||
},
|
||||
"README.txt": {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"TODOS.txt": {
|
||||
"hash": "ddec7477206c30c31b81482e56b877a0b3c2638b",
|
||||
"name": "TODOS.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"pygravitydefier": {
|
||||
"hash": "29ef158bc982733e2ba429fcf73e2f7562244188",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit"
|
||||
},
|
||||
"science.txt": {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"src": {
|
||||
"hash": "7b79d579b62994faba3b69fdf8aa442586c32681",
|
||||
"name": "src",
|
||||
"type": "tree"
|
||||
}
|
||||
},
|
||||
"hash": "819fc546cea489476ce8dc90785e9ba7753d0a8f"
|
||||
},
|
||||
"bbf3b8b3d26a4f884b5c022d46851f593d329192": {
|
||||
"entries": {
|
||||
".gitmodules": {
|
||||
"hash": "8c6cac301e763aa6d36466e0a775eb804be2c311",
|
||||
"name": ".gitmodules",
|
||||
"type": "blob"
|
||||
},
|
||||
"README.txt": {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"TODOS.txt": {
|
||||
"hash": "ddec7477206c30c31b81482e56b877a0b3c2638b",
|
||||
"name": "TODOS.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"pygravitydefier": {
|
||||
"hash": "29ef158bc982733e2ba429fcf73e2f7562244188",
|
||||
"name": "pygravitydefier",
|
||||
"type": "commit"
|
||||
},
|
||||
"science.txt": {
|
||||
"hash": "f1f2514ca6d7a6a1a0511957021b1995bf9ace1c",
|
||||
"name": "science.txt",
|
||||
"type": "blob"
|
||||
},
|
||||
"src": {
|
||||
"hash": "78fc9c83023386854c6bfdc5761c0e58f68e226f",
|
||||
"name": "src",
|
||||
"type": "tree"
|
||||
}
|
||||
},
|
||||
"hash": "bbf3b8b3d26a4f884b5c022d46851f593d329192"
|
||||
},
|
||||
"bdff5d94193170015d6cbb549b7b630649428b1f": {
|
||||
"entries": {
|
||||
"README.txt": {
|
||||
"hash": "0fb31858c8e3710be77e1dbb8880acf8a5543d82",
|
||||
"name": "README.txt",
|
||||
"type": "blob"
|
||||
}
|
||||
},
|
||||
"hash": "bdff5d94193170015d6cbb549b7b630649428b1f"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,7 +22,12 @@ function mkdtemp() {
|
|||
describe("loadRepository", () => {
|
||||
it("loads from HEAD", () => {
|
||||
const repository = createExampleRepo(mkdtemp());
|
||||
expect(loadRepository(repository.path, "HEAD")).toMatchSnapshot();
|
||||
// In case of failure, run
|
||||
// src/plugins/git/loadRepositoryTest.sh --updateSnapshot
|
||||
// to update the snapshot, then inspect the resulting changes.
|
||||
expect(loadRepository(repository.path, "HEAD")).toEqual(
|
||||
require("./demoData/example-git.json")
|
||||
);
|
||||
});
|
||||
|
||||
it("processes an old commit", () => {
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
data_file=src/plugins/git/demoData/example-git.json
|
||||
|
||||
usage() {
|
||||
printf 'usage: %s [-u|--updateSnapshot] [--help]\n' "$0"
|
||||
printf 'Flags:\n'
|
||||
printf ' -u|--updateSnapshot\n'
|
||||
printf ' Update the stored file instead of checking its contents\n'
|
||||
printf ' --help\n'
|
||||
printf ' Show this message\n'
|
||||
}
|
||||
|
||||
fetch() {
|
||||
yarn backend >&2
|
||||
tmpdir="$(mktemp -d)"
|
||||
node bin/createExampleRepo.js "${tmpdir}"
|
||||
node bin/loadAndPrintGitRepository.js "${tmpdir}"
|
||||
rm -rf "${tmpdir}"
|
||||
}
|
||||
|
||||
check() {
|
||||
output="$(mktemp)"
|
||||
fetch >"${output}"
|
||||
diff -uw "${data_file}" "${output}"
|
||||
rm "${output}"
|
||||
}
|
||||
|
||||
update() {
|
||||
fetch >"${data_file}"
|
||||
}
|
||||
|
||||
main() {
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
if [ $# -eq 0 ]; then
|
||||
check
|
||||
elif [ $# -eq 1 ]; then
|
||||
if [ "$1" = "-u" ] || [ "$1" = "--updateSnapshot" ]; then
|
||||
update
|
||||
elif [ "$1" = "--help" ]; then
|
||||
usage
|
||||
else
|
||||
usage >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
usage >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue