@simbo/git-fixture 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +18 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @simbo/git-fixture
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fa8d241: Document how to set and restore the environment for the code under
|
|
8
|
+
test.
|
|
9
|
+
|
|
10
|
+
- The README shows `vi.stubEnv()` in `beforeEach()` and `vi.unstubAllEnvs()`
|
|
11
|
+
with `cleanup()` in `afterEach()`.
|
|
12
|
+
- It notes that the variables apply to the whole test process until they are
|
|
13
|
+
restored.
|
|
14
|
+
|
|
3
15
|
## 1.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -70,14 +70,28 @@ Without `await using`, remove the repository with `cleanup()`, for example in
|
|
|
70
70
|
|
|
71
71
|
The fixture runs its own Git commands with the neutral configuration. Code under
|
|
72
72
|
test that runs Git itself reads the environment of the process instead. Set the
|
|
73
|
-
variables of `env` for it, for example with Vitest
|
|
73
|
+
variables of `env` for it, for example with Vitest, and restore the environment
|
|
74
|
+
after each test:
|
|
74
75
|
|
|
75
76
|
```ts
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
let repo: GitFixture;
|
|
78
|
+
|
|
79
|
+
beforeEach(async () => {
|
|
80
|
+
repo = await createGitFixture({ files: { 'a.txt': 'a\n' } });
|
|
81
|
+
for (const [name, value] of Object.entries(repo.env)) {
|
|
82
|
+
vi.stubEnv(name, value);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
afterEach(async () => {
|
|
87
|
+
vi.unstubAllEnvs();
|
|
88
|
+
await repo.cleanup();
|
|
89
|
+
});
|
|
79
90
|
```
|
|
80
91
|
|
|
92
|
+
The variables then apply to all code in the test process, also to Git commands
|
|
93
|
+
outside the repository, until `vi.unstubAllEnvs()` restores them.
|
|
94
|
+
|
|
81
95
|
`env` holds `GIT_CONFIG_GLOBAL` (the null device), `GIT_CONFIG_NOSYSTEM`,
|
|
82
96
|
`GIT_CEILING_DIRECTORIES` (the parent of the repository), `GIT_TERMINAL_PROMPT`,
|
|
83
97
|
and name, email, and date of author and committer. Signing is turned off with
|