@rushstack/package-deps-hash 3.2.67 → 4.0.0
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/dist/package-deps-hash.d.ts +4 -2
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/getRepoState.d.ts +10 -10
- package/lib/getRepoState.d.ts.map +1 -1
- package/lib/getRepoState.js +119 -60
- package/lib/getRepoState.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -60,11 +60,13 @@ export declare function getRepoRoot(currentWorkingDirectory: string, gitPath?: s
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Gets the object hashes for all files in the Git repo, combining the current commit with working tree state.
|
|
63
|
-
*
|
|
63
|
+
* Uses async operations and runs all primary Git calls in parallel.
|
|
64
|
+
* @param rootDirectory - The root directory of the Git repository
|
|
65
|
+
* @param additionalRelativePathsToHash - Root-relative file paths to have Git hash and include in the results
|
|
64
66
|
* @param gitPath - The path to the Git executable
|
|
65
67
|
* @beta
|
|
66
68
|
*/
|
|
67
|
-
export declare function
|
|
69
|
+
export declare function getRepoStateAsync(rootDirectory: string, additionalRelativePathsToHash?: string[], gitPath?: string): Promise<Map<string, string>>;
|
|
68
70
|
|
|
69
71
|
/**
|
|
70
72
|
* Information about the changes to a file.
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/getRepoState.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ interface IGitTreeState {
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export declare function parseGitLsTree(output: string): IGitTreeState;
|
|
15
|
+
/**
|
|
16
|
+
* Parses the output of `git hash-object`
|
|
17
|
+
* yields [filePath, hash] pairs.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseGitHashObject(output: string, filePaths: ReadonlyArray<string>): Iterable<[string, string]>;
|
|
15
21
|
/**
|
|
16
22
|
* Information about the changes to a file.
|
|
17
23
|
* @beta
|
|
@@ -46,21 +52,15 @@ export declare function parseGitStatus(output: string): Map<string, boolean>;
|
|
|
46
52
|
* @beta
|
|
47
53
|
*/
|
|
48
54
|
export declare function getRepoRoot(currentWorkingDirectory: string, gitPath?: string): string;
|
|
49
|
-
/**
|
|
50
|
-
* Augments the state value with modifications that are not in the index.
|
|
51
|
-
* @param rootDirectory - The root directory of the Git repository
|
|
52
|
-
* @param state - The current map of git path -> object hash. Will be mutated.
|
|
53
|
-
* @param gitPath - The path to the Git executable
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
export declare function applyWorkingTreeState(rootDirectory: string, state: Map<string, string>, gitPath?: string): void;
|
|
57
55
|
/**
|
|
58
56
|
* Gets the object hashes for all files in the Git repo, combining the current commit with working tree state.
|
|
59
|
-
*
|
|
57
|
+
* Uses async operations and runs all primary Git calls in parallel.
|
|
58
|
+
* @param rootDirectory - The root directory of the Git repository
|
|
59
|
+
* @param additionalRelativePathsToHash - Root-relative file paths to have Git hash and include in the results
|
|
60
60
|
* @param gitPath - The path to the Git executable
|
|
61
61
|
* @beta
|
|
62
62
|
*/
|
|
63
|
-
export declare function
|
|
63
|
+
export declare function getRepoStateAsync(rootDirectory: string, additionalRelativePathsToHash?: string[], gitPath?: string): Promise<Map<string, string>>;
|
|
64
64
|
/**
|
|
65
65
|
* Find all changed files tracked by Git, their current hashes, and the nature of the change. Only useful if all changes are staged or committed.
|
|
66
66
|
* @param currentWorkingDirectory - The working directory. Only used to find the repository root.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRepoState.d.ts","sourceRoot":"","sources":["../src/getRepoState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getRepoState.d.ts","sourceRoot":"","sources":["../src/getRepoState.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;I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AE,MAAM,EAC/B,QAAQ,GAAE,MAAe,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CA8B9B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAe9D;AAeD,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAyBrE"}
|
package/lib/getRepoState.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
5
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
6
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
7
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
8
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
9
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
10
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
11
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
12
|
+
function fulfill(value) { resume("next", value); }
|
|
13
|
+
function reject(value) { resume("throw", value); }
|
|
14
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
15
|
+
};
|
|
4
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.parseGitVersion = exports.ensureGitMinimumVersion = exports.getRepoChanges = exports.
|
|
17
|
+
exports.parseGitVersion = exports.ensureGitMinimumVersion = exports.getRepoChanges = exports.getRepoStateAsync = exports.getRepoRoot = exports.parseGitStatus = exports.parseGitDiffIndex = exports.parseGitHashObject = exports.parseGitLsTree = void 0;
|
|
18
|
+
const events_1 = require("events");
|
|
19
|
+
const stream_1 = require("stream");
|
|
6
20
|
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
7
21
|
const MINIMUM_GIT_VERSION = {
|
|
8
22
|
major: 2,
|
|
@@ -51,6 +65,34 @@ function parseGitLsTree(output) {
|
|
|
51
65
|
};
|
|
52
66
|
}
|
|
53
67
|
exports.parseGitLsTree = parseGitLsTree;
|
|
68
|
+
/**
|
|
69
|
+
* Parses the output of `git hash-object`
|
|
70
|
+
* yields [filePath, hash] pairs.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
function* parseGitHashObject(output, filePaths) {
|
|
74
|
+
output = output.trim();
|
|
75
|
+
let last = 0;
|
|
76
|
+
let i = 0;
|
|
77
|
+
let index = output.indexOf('\n', last);
|
|
78
|
+
const expected = filePaths.length;
|
|
79
|
+
for (; i < expected && index > 0; i++) {
|
|
80
|
+
const hash = output.slice(last, index);
|
|
81
|
+
yield [filePaths[i], hash];
|
|
82
|
+
last = index + 1;
|
|
83
|
+
index = output.indexOf('\n', last);
|
|
84
|
+
}
|
|
85
|
+
// Handle last line
|
|
86
|
+
if (index < 0) {
|
|
87
|
+
const hash = output.slice(last);
|
|
88
|
+
yield [filePaths[i], hash];
|
|
89
|
+
i++;
|
|
90
|
+
}
|
|
91
|
+
if (i < expected) {
|
|
92
|
+
throw new Error(`Expected ${expected} hashes from "git hash-object" but only received ${i}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.parseGitHashObject = parseGitHashObject;
|
|
54
96
|
/**
|
|
55
97
|
* Parses the output of `git diff-index --color=never --no-renames --no-commit-id -z <REVISION> --
|
|
56
98
|
* Returns a map of file path to diff
|
|
@@ -138,90 +180,107 @@ function getRepoRoot(currentWorkingDirectory, gitPath) {
|
|
|
138
180
|
ensureGitMinimumVersion(gitPath);
|
|
139
181
|
throw new Error(`git rev-parse exited with status ${result.status}: ${result.stderr}`);
|
|
140
182
|
}
|
|
141
|
-
|
|
183
|
+
cachedResult = result.stdout.trim();
|
|
184
|
+
repoRootCache.set(currentWorkingDirectory, cachedResult);
|
|
185
|
+
// To ensure that calling getRepoRoot on the result is a no-op.
|
|
186
|
+
repoRootCache.set(cachedResult, cachedResult);
|
|
142
187
|
}
|
|
143
188
|
return cachedResult;
|
|
144
189
|
}
|
|
145
190
|
exports.getRepoRoot = getRepoRoot;
|
|
146
191
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
150
|
-
* @param
|
|
151
|
-
* @
|
|
192
|
+
* Helper function for async process invocation with optional stdin support.
|
|
193
|
+
* @param gitPath - Path to the Git executable
|
|
194
|
+
* @param args - The process arguments
|
|
195
|
+
* @param currentWorkingDirectory - The working directory. Should be the repository root.
|
|
196
|
+
* @param stdin - An optional Readable stream to use as stdin to the process.
|
|
152
197
|
*/
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
currentWorkingDirectory
|
|
198
|
+
async function spawnGitAsync(gitPath, args, currentWorkingDirectory, stdin) {
|
|
199
|
+
const spawnOptions = {
|
|
200
|
+
currentWorkingDirectory,
|
|
201
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
202
|
+
};
|
|
203
|
+
let stdout = '';
|
|
204
|
+
let stderr = '';
|
|
205
|
+
const proc = node_core_library_1.Executable.spawn(gitPath || 'git', args, spawnOptions);
|
|
206
|
+
proc.stdout.setEncoding('utf-8');
|
|
207
|
+
proc.stderr.setEncoding('utf-8');
|
|
208
|
+
proc.stdout.on('data', (chunk) => {
|
|
209
|
+
stdout += chunk.toString();
|
|
156
210
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const filesToHash = [];
|
|
163
|
-
for (const [filePath, exists] of locallyModified) {
|
|
164
|
-
if (exists) {
|
|
165
|
-
filesToHash.push(filePath);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
state.delete(filePath);
|
|
169
|
-
}
|
|
211
|
+
proc.stderr.on('data', (chunk) => {
|
|
212
|
+
stderr += chunk.toString();
|
|
213
|
+
});
|
|
214
|
+
if (stdin) {
|
|
215
|
+
stdin.pipe(proc.stdin);
|
|
170
216
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const hashObjectResult = node_core_library_1.Executable.spawnSync(gitPath || 'git', ['hash-object', '--stdin-paths'], { currentWorkingDirectory: rootDirectory, input: filesToHash.join('\n') });
|
|
175
|
-
if (hashObjectResult.status !== 0) {
|
|
176
|
-
ensureGitMinimumVersion(gitPath);
|
|
177
|
-
throw new Error(`git hash-object exited with status ${hashObjectResult.status}: ${hashObjectResult.stderr}`);
|
|
178
|
-
}
|
|
179
|
-
const hashStdout = hashObjectResult.stdout.trim();
|
|
180
|
-
// The result of "git hash-object" will be a list of file hashes delimited by newlines
|
|
181
|
-
const hashes = hashStdout.split('\n');
|
|
182
|
-
if (hashes.length !== filesToHash.length) {
|
|
183
|
-
throw new Error(`Passed ${filesToHash.length} file paths to Git to hash, but received ${hashes.length} hashes.`);
|
|
184
|
-
}
|
|
185
|
-
const len = hashes.length;
|
|
186
|
-
for (let i = 0; i < len; i++) {
|
|
187
|
-
const hash = hashes[i];
|
|
188
|
-
const filePath = filesToHash[i];
|
|
189
|
-
state.set(filePath, hash);
|
|
190
|
-
}
|
|
217
|
+
const [status] = await (0, events_1.once)(proc, 'exit');
|
|
218
|
+
if (status !== 0) {
|
|
219
|
+
throw new Error(`git ${args[0]} exited with code ${status}: ${stderr}`);
|
|
191
220
|
}
|
|
221
|
+
return stdout;
|
|
192
222
|
}
|
|
193
|
-
exports.applyWorkingTreeState = applyWorkingTreeState;
|
|
194
223
|
/**
|
|
195
224
|
* Gets the object hashes for all files in the Git repo, combining the current commit with working tree state.
|
|
196
|
-
*
|
|
225
|
+
* Uses async operations and runs all primary Git calls in parallel.
|
|
226
|
+
* @param rootDirectory - The root directory of the Git repository
|
|
227
|
+
* @param additionalRelativePathsToHash - Root-relative file paths to have Git hash and include in the results
|
|
197
228
|
* @param gitPath - The path to the Git executable
|
|
198
229
|
* @beta
|
|
199
230
|
*/
|
|
200
|
-
function
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
231
|
+
async function getRepoStateAsync(rootDirectory, additionalRelativePathsToHash, gitPath) {
|
|
232
|
+
const statePromise = spawnGitAsync(gitPath, ['--no-optional-locks', 'ls-tree', '-r', '-z', '--full-name', 'HEAD', '--'], rootDirectory).then(parseGitLsTree);
|
|
233
|
+
const locallyModifiedPromise = spawnGitAsync(gitPath, ['--no-optional-locks', 'status', '-z', '-u', '--no-renames', '--ignore-submodules', '--'], rootDirectory).then(parseGitStatus);
|
|
234
|
+
const hashPaths = [];
|
|
235
|
+
function getFilesToHash() {
|
|
236
|
+
return __asyncGenerator(this, arguments, function* getFilesToHash_1() {
|
|
237
|
+
if (additionalRelativePathsToHash) {
|
|
238
|
+
for (const file of additionalRelativePathsToHash) {
|
|
239
|
+
hashPaths.push(file);
|
|
240
|
+
yield yield __await(`${file}\n`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const [{ files }, locallyModified] = yield __await(Promise.all([statePromise, locallyModifiedPromise]));
|
|
244
|
+
for (const [filePath, exists] of locallyModified) {
|
|
245
|
+
if (exists) {
|
|
246
|
+
hashPaths.push(filePath);
|
|
247
|
+
yield yield __await(`${filePath}\n`);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
files.delete(filePath);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const hashObjectPromise = spawnGitAsync(gitPath, ['--no-optional-locks', 'hash-object', '--stdin-paths'], rootDirectory, stream_1.Readable.from(getFilesToHash(), {
|
|
256
|
+
encoding: 'utf-8',
|
|
257
|
+
objectMode: false,
|
|
258
|
+
autoDestroy: true
|
|
259
|
+
}));
|
|
260
|
+
const [{ files, submodules }, hashObject] = await Promise.all([
|
|
261
|
+
statePromise,
|
|
262
|
+
hashObjectPromise,
|
|
263
|
+
locallyModifiedPromise
|
|
264
|
+
]);
|
|
265
|
+
// The result of "git hash-object" will be a list of file hashes delimited by newlines
|
|
266
|
+
for (const [filePath, hash] of parseGitHashObject(hashObject, hashPaths)) {
|
|
267
|
+
files.set(filePath, hash);
|
|
208
268
|
}
|
|
209
|
-
const { files, submodules } = parseGitLsTree(lsTreeResult.stdout);
|
|
210
|
-
applyWorkingTreeState(rootDirectory, files, gitPath);
|
|
211
|
-
const state = files;
|
|
212
269
|
// Existence check for the .gitmodules file
|
|
213
270
|
const hasSubmodules = submodules.size > 0 && node_core_library_1.FileSystem.exists(`${rootDirectory}/.gitmodules`);
|
|
214
271
|
if (hasSubmodules) {
|
|
272
|
+
// Submodules are not the normal critical path. Accept serial performance rather than investing in complexity.
|
|
273
|
+
// Can revisit if submodules become more commonly used.
|
|
215
274
|
for (const submodulePath of submodules.keys()) {
|
|
216
|
-
const submoduleState =
|
|
275
|
+
const submoduleState = await getRepoStateAsync(`${rootDirectory}/${submodulePath}`, [], gitPath);
|
|
217
276
|
for (const [filePath, hash] of submoduleState) {
|
|
218
|
-
|
|
277
|
+
files.set(`${submodulePath}/${filePath}`, hash);
|
|
219
278
|
}
|
|
220
279
|
}
|
|
221
280
|
}
|
|
222
|
-
return
|
|
281
|
+
return files;
|
|
223
282
|
}
|
|
224
|
-
exports.
|
|
283
|
+
exports.getRepoStateAsync = getRepoStateAsync;
|
|
225
284
|
/**
|
|
226
285
|
* Find all changed files tracked by Git, their current hashes, and the nature of the change. Only useful if all changes are staged or committed.
|
|
227
286
|
* @param currentWorkingDirectory - The working directory. Only used to find the repository root.
|
package/lib/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ACH;IAED,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE7C,OAAO;QACL,KAAK;QACL,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC;AAzBD,0CAyBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as child_process from 'child_process';\nimport { Executable, FileSystem } from '@rushstack/node-core-library';\n\nexport interface IGitVersion {\n major: number;\n minor: number;\n patch: number;\n}\n\nconst MINIMUM_GIT_VERSION: IGitVersion = {\n major: 2,\n minor: 20,\n patch: 0\n};\n\ninterface IGitTreeState {\n files: Map<string, string>; // type \"blob\"\n submodules: Map<string, string>; // type \"commit\"\n}\n\n/**\n * Parses the output of the \"git ls-tree -r -z\" command\n * @internal\n */\nexport function parseGitLsTree(output: string): IGitTreeState {\n const files: Map<string, string> = new Map();\n const submodules: Map<string, string> = new Map();\n\n // Parse the output\n // With the -z modifier, paths are delimited by nulls\n // A line looks like:\n // <mode> <type> <newhash>\\t<path>\\0\n // 100644 blob a300ccb0b36bd2c85ef18e3c619a2c747f95959e\\ttools/prettier-git/prettier-git.js\\0\n\n let last: number = 0;\n let index: number = output.indexOf('\\0', last);\n while (index >= 0) {\n const item: string = output.slice(last, index);\n\n const tabIndex: number = item.indexOf('\\t');\n const filePath: string = item.slice(tabIndex + 1);\n\n // The newHash will be all zeros if the file is deleted, or a hash if it exists\n const hash: string = item.slice(tabIndex - 40, tabIndex);\n\n const spaceIndex: number = item.lastIndexOf(' ', tabIndex - 42);\n\n const type: string = item.slice(spaceIndex + 1, tabIndex - 41);\n\n switch (type) {\n case 'commit': {\n submodules.set(filePath, hash);\n break;\n }\n case 'blob':\n default: {\n files.set(filePath, hash);\n break;\n }\n }\n\n last = index + 1;\n index = output.indexOf('\\0', last);\n }\n\n return {\n files,\n submodules\n };\n}\n\n/**\n * Information about the changes to a file.\n * @beta\n */\nexport interface IFileDiffStatus {\n mode: string;\n oldhash: string;\n newhash: string;\n status: 'A' | 'D' | 'M';\n}\n\n/**\n * Parses the output of `git diff-index --color=never --no-renames --no-commit-id -z <REVISION> --\n * Returns a map of file path to diff\n * @internal\n */\nexport function parseGitDiffIndex(output: string): Map<string, IFileDiffStatus> {\n const result: Map<string, IFileDiffStatus> = new Map();\n\n // Parse the output\n // With the -z modifier, paths are delimited by nulls\n // A line looks like:\n // :<oldmode> <newmode> <oldhash> <newhash> <status>\\0<path>\\0\n // :100644 100644 a300ccb0b36bd2c85ef18e3c619a2c747f95959e 0000000000000000000000000000000000000000 M\\0tools/prettier-git/prettier-git.js\\0\n\n let last: number = 0;\n let index: number = output.indexOf('\\0', last);\n while (index >= 0) {\n const header: string = output.slice(last, index);\n const status: IFileDiffStatus['status'] = header.slice(-1) as IFileDiffStatus['status'];\n\n last = index + 1;\n index = output.indexOf('\\0', last);\n const filePath: string = output.slice(last, index);\n\n // We passed --no-renames above, so a rename will be a delete of the old location and an add at the new.\n // The newHash will be all zeros if the file is deleted, or a hash if it exists\n const mode: string = header.slice(8, 14);\n const oldhash: string = header.slice(-83, -43);\n const newhash: string = header.slice(-42, -2);\n result.set(filePath, {\n mode,\n oldhash,\n newhash,\n status\n });\n\n last = index + 1;\n index = output.indexOf('\\0', last);\n }\n\n return result;\n}\n\n/**\n * Parses the output of `git status -z -u` to extract the set of files that have changed since HEAD.\n *\n * @param output - The raw output from Git\n * @returns a map of file path to if it exists\n * @internal\n */\nexport function parseGitStatus(output: string): Map<string, boolean> {\n const result: Map<string, boolean> = new Map();\n\n // Parse the output\n // With the -z modifier, paths are delimited by nulls\n // A line looks like:\n // XY <path>\\0\n // M tools/prettier-git/prettier-git.js\\0\n\n let startOfLine: number = 0;\n let eolIndex: number = output.indexOf('\\0', startOfLine);\n while (eolIndex >= 0) {\n // We passed --no-renames above, so a rename will be a delete of the old location and an add at the new.\n // charAt(startOfLine) is the index status, charAt(startOfLine + 1) is the working tree status\n const workingTreeStatus: string = output.charAt(startOfLine + 1);\n // Deleted in working tree, or not modified in working tree and deleted in index\n const deleted: boolean =\n workingTreeStatus === 'D' || (workingTreeStatus === ' ' && output.charAt(startOfLine) === 'D');\n\n const filePath: string = output.slice(startOfLine + 3, eolIndex);\n result.set(filePath, !deleted);\n\n startOfLine = eolIndex + 1;\n eolIndex = output.indexOf('\\0', startOfLine);\n }\n\n return result;\n}\n\nconst repoRootCache: Map<string, string> = new Map();\n\n/**\n * Finds the root of the current Git repository\n *\n * @param currentWorkingDirectory - The working directory for which to locate the repository\n * @param gitPath - The path to the Git executable\n *\n * @returns The full path to the root directory of the Git repository\n * @beta\n */\nexport function getRepoRoot(currentWorkingDirectory: string, gitPath?: string): string {\n let cachedResult: string | undefined = repoRootCache.get(currentWorkingDirectory);\n if (!cachedResult) {\n const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(\n gitPath || 'git',\n ['--no-optional-locks', 'rev-parse', '--show-toplevel'],\n {\n currentWorkingDirectory\n }\n );\n\n if (result.status !== 0) {\n ensureGitMinimumVersion(gitPath);\n\n throw new Error(`git rev-parse exited with status ${result.status}: ${result.stderr}`);\n }\n\n repoRootCache.set(currentWorkingDirectory, (cachedResult = result.stdout.trim()));\n }\n\n return cachedResult;\n}\n\n/**\n * Augments the state value with modifications that are not in the index.\n * @param rootDirectory - The root directory of the Git repository\n * @param state - The current map of git path -> object hash. Will be mutated.\n * @param gitPath - The path to the Git executable\n * @internal\n */\nexport function applyWorkingTreeState(\n rootDirectory: string,\n state: Map<string, string>,\n gitPath?: string\n): void {\n const statusResult: child_process.SpawnSyncReturns<string> = Executable.spawnSync(\n gitPath || 'git',\n ['--no-optional-locks', 'status', '-z', '-u', '--no-renames', '--ignore-submodules', '--'],\n {\n currentWorkingDirectory: rootDirectory\n }\n );\n\n if (statusResult.status !== 0) {\n ensureGitMinimumVersion(gitPath);\n\n throw new Error(`git status exited with status ${statusResult.status}: ${statusResult.stderr}`);\n }\n\n const locallyModified: Map<string, boolean> = parseGitStatus(statusResult.stdout);\n\n const filesToHash: string[] = [];\n for (const [filePath, exists] of locallyModified) {\n if (exists) {\n filesToHash.push(filePath);\n } else {\n state.delete(filePath);\n }\n }\n\n if (filesToHash.length) {\n // Use --stdin-paths arg to pass the list of files to git in order to avoid issues with\n // command length\n const hashObjectResult: child_process.SpawnSyncReturns<string> = Executable.spawnSync(\n gitPath || 'git',\n ['hash-object', '--stdin-paths'],\n { currentWorkingDirectory: rootDirectory, input: filesToHash.join('\\n') }\n );\n\n if (hashObjectResult.status !== 0) {\n ensureGitMinimumVersion(gitPath);\n\n throw new Error(\n `git hash-object exited with status ${hashObjectResult.status}: ${hashObjectResult.stderr}`\n );\n }\n\n const hashStdout: string = hashObjectResult.stdout.trim();\n\n // The result of \"git hash-object\" will be a list of file hashes delimited by newlines\n const hashes: string[] = hashStdout.split('\\n');\n\n if (hashes.length !== filesToHash.length) {\n throw new Error(\n `Passed ${filesToHash.length} file paths to Git to hash, but received ${hashes.length} hashes.`\n );\n }\n\n const len: number = hashes.length;\n for (let i: number = 0; i < len; i++) {\n const hash: string = hashes[i];\n const filePath: string = filesToHash[i];\n state.set(filePath, hash);\n }\n }\n}\n\n/**\n * Gets the object hashes for all files in the Git repo, combining the current commit with working tree state.\n * @param currentWorkingDirectory - The working directory. Only used to find the repository root.\n * @param gitPath - The path to the Git executable\n * @beta\n */\nexport function getRepoState(currentWorkingDirectory: string, gitPath?: string): Map<string, string> {\n const rootDirectory: string = getRepoRoot(currentWorkingDirectory, gitPath);\n\n const lsTreeResult: child_process.SpawnSyncReturns<string> = Executable.spawnSync(\n gitPath || 'git',\n ['--no-optional-locks', 'ls-tree', '-r', '-z', '--full-name', 'HEAD', '--'],\n {\n currentWorkingDirectory: rootDirectory\n }\n );\n\n if (lsTreeResult.status !== 0) {\n ensureGitMinimumVersion(gitPath);\n\n throw new Error(`git ls-tree exited with status ${lsTreeResult.status}: ${lsTreeResult.stderr}`);\n }\n\n const { files, submodules } = parseGitLsTree(lsTreeResult.stdout);\n\n applyWorkingTreeState(rootDirectory, files, gitPath);\n\n const state: Map<string, string> = files;\n\n // Existence check for the .gitmodules file\n const hasSubmodules: boolean = submodules.size > 0 && FileSystem.exists(`${rootDirectory}/.gitmodules`);\n\n if (hasSubmodules) {\n for (const submodulePath of submodules.keys()) {\n const submoduleState: Map<string, string> = getRepoState(`${rootDirectory}/${submodulePath}`, gitPath);\n for (const [filePath, hash] of submoduleState) {\n state.set(`${submodulePath}/${filePath}`, hash);\n }\n }\n }\n\n return state;\n}\n\n/**\n * Find all changed files tracked by Git, their current hashes, and the nature of the change. Only useful if all changes are staged or committed.\n * @param currentWorkingDirectory - The working directory. Only used to find the repository root.\n * @param revision - The Git revision specifier to detect changes relative to. Defaults to HEAD (i.e. will compare staged vs. committed)\n * If comparing against a different branch, call `git merge-base` first to find the target commit.\n * @param gitPath - The path to the Git executable\n * @returns A map from the Git file path to the corresponding file change metadata\n * @beta\n */\nexport function getRepoChanges(\n currentWorkingDirectory: string,\n revision: string = 'HEAD',\n gitPath?: string\n): Map<string, IFileDiffStatus> {\n const rootDirectory: string = getRepoRoot(currentWorkingDirectory, gitPath);\n\n const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(\n gitPath || 'git',\n [\n '--no-optional-locks',\n 'diff-index',\n '--color=never',\n '--no-renames',\n '--no-commit-id',\n '--cached',\n '-z',\n revision,\n '--'\n ],\n {\n currentWorkingDirectory: rootDirectory\n }\n );\n\n if (result.status !== 0) {\n ensureGitMinimumVersion(gitPath);\n\n throw new Error(`git diff-index exited with status ${result.status}: ${result.stderr}`);\n }\n\n const changes: Map<string, IFileDiffStatus> = parseGitDiffIndex(result.stdout);\n\n return changes;\n}\n\n/**\n * Checks the git version and throws an error if it is less than the minimum required version.\n *\n * @public\n */\nexport function ensureGitMinimumVersion(gitPath?: string): void {\n const gitVersion: IGitVersion = getGitVersion(gitPath);\n if (\n gitVersion.major < MINIMUM_GIT_VERSION.major ||\n (gitVersion.major === MINIMUM_GIT_VERSION.major && gitVersion.minor < MINIMUM_GIT_VERSION.minor) ||\n (gitVersion.major === MINIMUM_GIT_VERSION.major &&\n gitVersion.minor === MINIMUM_GIT_VERSION.minor &&\n gitVersion.patch < MINIMUM_GIT_VERSION.patch)\n ) {\n throw new Error(\n `The minimum Git version required is ` +\n `${MINIMUM_GIT_VERSION.major}.${MINIMUM_GIT_VERSION.minor}.${MINIMUM_GIT_VERSION.patch}. ` +\n `Your version is ${gitVersion.major}.${gitVersion.minor}.${gitVersion.patch}.`\n );\n }\n}\n\nfunction getGitVersion(gitPath?: string): IGitVersion {\n const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(gitPath || 'git', ['version']);\n\n if (result.status !== 0) {\n throw new Error(\n `While validating the Git installation, the \"git version\" command failed with ` +\n `status ${result.status}: ${result.stderr}`\n );\n }\n\n return parseGitVersion(result.stdout);\n}\n\nexport function parseGitVersion(gitVersionOutput: string): IGitVersion {\n // This regexp matches output of \"git version\" that looks like `git version <number>.<number>.<number>(+whatever)`\n // Examples:\n // - git version 1.2.3\n // - git version 1.2.3.4.5\n // - git version 1.2.3windows.1\n // - git version 1.2.3.windows.1\n const versionRegex: RegExp = /^git version (\\d+)\\.(\\d+)\\.(\\d+)/;\n const match: RegExpMatchArray | null = versionRegex.exec(gitVersionOutput);\n if (!match) {\n throw new Error(\n `While validating the Git installation, the \"git version\" command produced ` +\n `unexpected output: \"${gitVersionOutput}\"`\n );\n }\n\n const major: number = parseInt(match[1], 10);\n const minor: number = parseInt(match[2], 10);\n const patch: number = parseInt(match[3], 10);\n\n return {\n major,\n minor,\n patch\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getRepoState.js","sourceRoot":"","sources":["../src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C,CAAC;IAC3E,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CACb,4EAA4E;YAC1E,uBAAuB,gBAAgB,GAAG,CAC7C,CAAC;KACH;IAED,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE7C,OAAO;QACL,KAAK;QACL,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC;AAzBD,0CAyBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as child_process from 'child_process';\nimport { once } from 'events';\nimport { Readable } from 'stream';\n\nimport { Executable, FileSystem, IExecutableSpawnOptions } from '@rushstack/node-core-library';\n\nexport interface IGitVersion {\n major: number;\n minor: number;\n patch: number;\n}\n\nconst MINIMUM_GIT_VERSION: IGitVersion = {\n major: 2,\n minor: 20,\n patch: 0\n};\n\ninterface IGitTreeState {\n files: Map<string, string>; // type \"blob\"\n submodules: Map<string, string>; // type \"commit\"\n}\n\n/**\n * Parses the output of the \"git ls-tree -r -z\" command\n * @internal\n */\nexport function parseGitLsTree(output: string): IGitTreeState {\n const files: Map<string, string> = new Map();\n const submodules: Map<string, string> = new Map();\n\n // Parse the output\n // With the -z modifier, paths are delimited by nulls\n // A line looks like:\n // <mode> <type> <newhash>\\t<path>\\0\n // 100644 blob a300ccb0b36bd2c85ef18e3c619a2c747f95959e\\ttools/prettier-git/prettier-git.js\\0\n\n let last: number = 0;\n let index: number = output.indexOf('\\0', last);\n while (index >= 0) {\n const item: string = output.slice(last, index);\n\n const tabIndex: number = item.indexOf('\\t');\n const filePath: string = item.slice(tabIndex + 1);\n\n // The newHash will be all zeros if the file is deleted, or a hash if it exists\n const hash: string = item.slice(tabIndex - 40, tabIndex);\n\n const spaceIndex: number = item.lastIndexOf(' ', tabIndex - 42);\n\n const type: string = item.slice(spaceIndex + 1, tabIndex - 41);\n\n switch (type) {\n case 'commit': {\n submodules.set(filePath, hash);\n break;\n }\n case 'blob':\n default: {\n files.set(filePath, hash);\n break;\n }\n }\n\n last = index + 1;\n index = output.indexOf('\\0', last);\n }\n\n return {\n files,\n submodules\n };\n}\n\n/**\n * Parses the output of `git hash-object`\n * yields [filePath, hash] pairs.\n * @internal\n */\nexport function* parseGitHashObject(\n output: string,\n filePaths: ReadonlyArray<string>\n): Iterable<[string, string]> {\n output = output.trim();\n\n let last: number = 0;\n let i: number = 0;\n let index: number = output.indexOf('\\n', last);\n const expected: number = filePaths.length;\n for (; i < expected && index > 0; i++) {\n const hash: string = output.slice(last, index);\n yield [filePaths[i], hash];\n last = index + 1;\n index = output.indexOf('\\n', last);\n }\n\n // Handle last line\n if (index < 0) {\n const hash: string = output.slice(last);\n yield [filePaths[i], hash];\n i++;\n }\n\n if (i < expected) {\n throw new Error(`Expected ${expected} hashes from \"git hash-object\" but only received ${i}`);\n }\n}\n\n/**\n * Information about the changes to a file.\n * @beta\n */\nexport interface IFileDiffStatus {\n mode: string;\n oldhash: string;\n newhash: string;\n status: 'A' | 'D' | 'M';\n}\n\n/**\n * Parses the output of `git diff-index --color=never --no-renames --no-commit-id -z <REVISION> --\n * Returns a map of file path to diff\n * @internal\n */\nexport function parseGitDiffIndex(output: string): Map<string, IFileDiffStatus> {\n const result: Map<string, IFileDiffStatus> = new Map();\n\n // Parse the output\n // With the -z modifier, paths are delimited by nulls\n // A line looks like:\n // :<oldmode> <newmode> <oldhash> <newhash> <status>\\0<path>\\0\n // :100644 100644 a300ccb0b36bd2c85ef18e3c619a2c747f95959e 0000000000000000000000000000000000000000 M\\0tools/prettier-git/prettier-git.js\\0\n\n let last: number = 0;\n let index: number = output.indexOf('\\0', last);\n while (index >= 0) {\n const header: string = output.slice(last, index);\n const status: IFileDiffStatus['status'] = header.slice(-1) as IFileDiffStatus['status'];\n\n last = index + 1;\n index = output.indexOf('\\0', last);\n const filePath: string = output.slice(last, index);\n\n // We passed --no-renames above, so a rename will be a delete of the old location and an add at the new.\n // The newHash will be all zeros if the file is deleted, or a hash if it exists\n const mode: string = header.slice(8, 14);\n const oldhash: string = header.slice(-83, -43);\n const newhash: string = header.slice(-42, -2);\n result.set(filePath, {\n mode,\n oldhash,\n newhash,\n status\n });\n\n last = index + 1;\n index = output.indexOf('\\0', last);\n }\n\n return result;\n}\n\n/**\n * Parses the output of `git status -z -u` to extract the set of files that have changed since HEAD.\n *\n * @param output - The raw output from Git\n * @returns a map of file path to if it exists\n * @internal\n */\nexport function parseGitStatus(output: string): Map<string, boolean> {\n const result: Map<string, boolean> = new Map();\n\n // Parse the output\n // With the -z modifier, paths are delimited by nulls\n // A line looks like:\n // XY <path>\\0\n // M tools/prettier-git/prettier-git.js\\0\n\n let startOfLine: number = 0;\n let eolIndex: number = output.indexOf('\\0', startOfLine);\n while (eolIndex >= 0) {\n // We passed --no-renames above, so a rename will be a delete of the old location and an add at the new.\n // charAt(startOfLine) is the index status, charAt(startOfLine + 1) is the working tree status\n const workingTreeStatus: string = output.charAt(startOfLine + 1);\n // Deleted in working tree, or not modified in working tree and deleted in index\n const deleted: boolean =\n workingTreeStatus === 'D' || (workingTreeStatus === ' ' && output.charAt(startOfLine) === 'D');\n\n const filePath: string = output.slice(startOfLine + 3, eolIndex);\n result.set(filePath, !deleted);\n\n startOfLine = eolIndex + 1;\n eolIndex = output.indexOf('\\0', startOfLine);\n }\n\n return result;\n}\n\nconst repoRootCache: Map<string, string> = new Map();\n\n/**\n * Finds the root of the current Git repository\n *\n * @param currentWorkingDirectory - The working directory for which to locate the repository\n * @param gitPath - The path to the Git executable\n *\n * @returns The full path to the root directory of the Git repository\n * @beta\n */\nexport function getRepoRoot(currentWorkingDirectory: string, gitPath?: string): string {\n let cachedResult: string | undefined = repoRootCache.get(currentWorkingDirectory);\n if (!cachedResult) {\n const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(\n gitPath || 'git',\n ['--no-optional-locks', 'rev-parse', '--show-toplevel'],\n {\n currentWorkingDirectory\n }\n );\n\n if (result.status !== 0) {\n ensureGitMinimumVersion(gitPath);\n\n throw new Error(`git rev-parse exited with status ${result.status}: ${result.stderr}`);\n }\n\n cachedResult = result.stdout.trim();\n\n repoRootCache.set(currentWorkingDirectory, cachedResult);\n // To ensure that calling getRepoRoot on the result is a no-op.\n repoRootCache.set(cachedResult, cachedResult);\n }\n\n return cachedResult;\n}\n\n/**\n * Helper function for async process invocation with optional stdin support.\n * @param gitPath - Path to the Git executable\n * @param args - The process arguments\n * @param currentWorkingDirectory - The working directory. Should be the repository root.\n * @param stdin - An optional Readable stream to use as stdin to the process.\n */\nasync function spawnGitAsync(\n gitPath: string | undefined,\n args: string[],\n currentWorkingDirectory: string,\n stdin?: Readable\n): Promise<string> {\n const spawnOptions: IExecutableSpawnOptions = {\n currentWorkingDirectory,\n stdio: ['pipe', 'pipe', 'pipe']\n };\n\n let stdout: string = '';\n let stderr: string = '';\n\n const proc: child_process.ChildProcess = Executable.spawn(gitPath || 'git', args, spawnOptions);\n proc.stdout!.setEncoding('utf-8');\n proc.stderr!.setEncoding('utf-8');\n\n proc.stdout!.on('data', (chunk: string) => {\n stdout += chunk.toString();\n });\n proc.stderr!.on('data', (chunk: string) => {\n stderr += chunk.toString();\n });\n\n if (stdin) {\n stdin.pipe(proc.stdin!);\n }\n\n const [status] = await once(proc, 'exit');\n if (status !== 0) {\n throw new Error(`git ${args[0]} exited with code ${status}: ${stderr}`);\n }\n\n return stdout;\n}\n\n/**\n * Gets the object hashes for all files in the Git repo, combining the current commit with working tree state.\n * Uses async operations and runs all primary Git calls in parallel.\n * @param rootDirectory - The root directory of the Git repository\n * @param additionalRelativePathsToHash - Root-relative file paths to have Git hash and include in the results\n * @param gitPath - The path to the Git executable\n * @beta\n */\nexport async function getRepoStateAsync(\n rootDirectory: string,\n additionalRelativePathsToHash?: string[],\n gitPath?: string\n): Promise<Map<string, string>> {\n const statePromise: Promise<IGitTreeState> = spawnGitAsync(\n gitPath,\n ['--no-optional-locks', 'ls-tree', '-r', '-z', '--full-name', 'HEAD', '--'],\n rootDirectory\n ).then(parseGitLsTree);\n const locallyModifiedPromise: Promise<Map<string, boolean>> = spawnGitAsync(\n gitPath,\n ['--no-optional-locks', 'status', '-z', '-u', '--no-renames', '--ignore-submodules', '--'],\n rootDirectory\n ).then(parseGitStatus);\n\n const hashPaths: string[] = [];\n async function* getFilesToHash(): AsyncIterableIterator<string> {\n if (additionalRelativePathsToHash) {\n for (const file of additionalRelativePathsToHash) {\n hashPaths.push(file);\n yield `${file}\\n`;\n }\n }\n\n const [{ files }, locallyModified] = await Promise.all([statePromise, locallyModifiedPromise]);\n\n for (const [filePath, exists] of locallyModified) {\n if (exists) {\n hashPaths.push(filePath);\n yield `${filePath}\\n`;\n } else {\n files.delete(filePath);\n }\n }\n }\n\n const hashObjectPromise: Promise<string> = spawnGitAsync(\n gitPath,\n ['--no-optional-locks', 'hash-object', '--stdin-paths'],\n rootDirectory,\n Readable.from(getFilesToHash(), {\n encoding: 'utf-8',\n objectMode: false,\n autoDestroy: true\n })\n );\n\n const [{ files, submodules }, hashObject] = await Promise.all([\n statePromise,\n hashObjectPromise,\n locallyModifiedPromise\n ]);\n\n // The result of \"git hash-object\" will be a list of file hashes delimited by newlines\n for (const [filePath, hash] of parseGitHashObject(hashObject, hashPaths)) {\n files.set(filePath, hash);\n }\n\n // Existence check for the .gitmodules file\n const hasSubmodules: boolean = submodules.size > 0 && FileSystem.exists(`${rootDirectory}/.gitmodules`);\n\n if (hasSubmodules) {\n // Submodules are not the normal critical path. Accept serial performance rather than investing in complexity.\n // Can revisit if submodules become more commonly used.\n for (const submodulePath of submodules.keys()) {\n const submoduleState: Map<string, string> = await getRepoStateAsync(\n `${rootDirectory}/${submodulePath}`,\n [],\n gitPath\n );\n for (const [filePath, hash] of submoduleState) {\n files.set(`${submodulePath}/${filePath}`, hash);\n }\n }\n }\n\n return files;\n}\n\n/**\n * Find all changed files tracked by Git, their current hashes, and the nature of the change. Only useful if all changes are staged or committed.\n * @param currentWorkingDirectory - The working directory. Only used to find the repository root.\n * @param revision - The Git revision specifier to detect changes relative to. Defaults to HEAD (i.e. will compare staged vs. committed)\n * If comparing against a different branch, call `git merge-base` first to find the target commit.\n * @param gitPath - The path to the Git executable\n * @returns A map from the Git file path to the corresponding file change metadata\n * @beta\n */\nexport function getRepoChanges(\n currentWorkingDirectory: string,\n revision: string = 'HEAD',\n gitPath?: string\n): Map<string, IFileDiffStatus> {\n const rootDirectory: string = getRepoRoot(currentWorkingDirectory, gitPath);\n\n const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(\n gitPath || 'git',\n [\n '--no-optional-locks',\n 'diff-index',\n '--color=never',\n '--no-renames',\n '--no-commit-id',\n '--cached',\n '-z',\n revision,\n '--'\n ],\n {\n currentWorkingDirectory: rootDirectory\n }\n );\n\n if (result.status !== 0) {\n ensureGitMinimumVersion(gitPath);\n\n throw new Error(`git diff-index exited with status ${result.status}: ${result.stderr}`);\n }\n\n const changes: Map<string, IFileDiffStatus> = parseGitDiffIndex(result.stdout);\n\n return changes;\n}\n\n/**\n * Checks the git version and throws an error if it is less than the minimum required version.\n *\n * @public\n */\nexport function ensureGitMinimumVersion(gitPath?: string): void {\n const gitVersion: IGitVersion = getGitVersion(gitPath);\n if (\n gitVersion.major < MINIMUM_GIT_VERSION.major ||\n (gitVersion.major === MINIMUM_GIT_VERSION.major && gitVersion.minor < MINIMUM_GIT_VERSION.minor) ||\n (gitVersion.major === MINIMUM_GIT_VERSION.major &&\n gitVersion.minor === MINIMUM_GIT_VERSION.minor &&\n gitVersion.patch < MINIMUM_GIT_VERSION.patch)\n ) {\n throw new Error(\n `The minimum Git version required is ` +\n `${MINIMUM_GIT_VERSION.major}.${MINIMUM_GIT_VERSION.minor}.${MINIMUM_GIT_VERSION.patch}. ` +\n `Your version is ${gitVersion.major}.${gitVersion.minor}.${gitVersion.patch}.`\n );\n }\n}\n\nfunction getGitVersion(gitPath?: string): IGitVersion {\n const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(gitPath || 'git', ['version']);\n\n if (result.status !== 0) {\n throw new Error(\n `While validating the Git installation, the \"git version\" command failed with ` +\n `status ${result.status}: ${result.stderr}`\n );\n }\n\n return parseGitVersion(result.stdout);\n}\n\nexport function parseGitVersion(gitVersionOutput: string): IGitVersion {\n // This regexp matches output of \"git version\" that looks like `git version <number>.<number>.<number>(+whatever)`\n // Examples:\n // - git version 1.2.3\n // - git version 1.2.3.4.5\n // - git version 1.2.3windows.1\n // - git version 1.2.3.windows.1\n const versionRegex: RegExp = /^git version (\\d+)\\.(\\d+)\\.(\\d+)/;\n const match: RegExpMatchArray | null = versionRegex.exec(gitVersionOutput);\n if (!match) {\n throw new Error(\n `While validating the Git installation, the \"git version\" command produced ` +\n `unexpected output: \"${gitVersionOutput}\"`\n );\n }\n\n const major: number = parseInt(match[1], 10);\n const minor: number = parseInt(match[2], 10);\n const patch: number = parseInt(match[3], 10);\n\n return {\n major,\n minor,\n patch\n };\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
12
|
export { getPackageDeps, getGitHashForFiles } from './getPackageDeps';
|
|
13
|
-
export { IFileDiffStatus, getRepoChanges, getRepoRoot,
|
|
13
|
+
export { IFileDiffStatus, getRepoChanges, getRepoRoot, getRepoStateAsync, ensureGitMinimumVersion } from './getRepoState';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,eAAe,EACf,cAAc,EACd,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,eAAe,EACf,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.ensureGitMinimumVersion = exports.
|
|
5
|
+
exports.ensureGitMinimumVersion = exports.getRepoStateAsync = exports.getRepoRoot = exports.getRepoChanges = exports.getGitHashForFiles = exports.getPackageDeps = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* This package builds a JSON object containing the git hashes of all files used to produce a given NPM package.
|
|
8
8
|
* The {@link https://rushjs.io/ | Rush} tool uses this library to implement incremental build detection.
|
|
@@ -20,6 +20,6 @@ Object.defineProperty(exports, "getGitHashForFiles", { enumerable: true, get: fu
|
|
|
20
20
|
var getRepoState_1 = require("./getRepoState");
|
|
21
21
|
Object.defineProperty(exports, "getRepoChanges", { enumerable: true, get: function () { return getRepoState_1.getRepoChanges; } });
|
|
22
22
|
Object.defineProperty(exports, "getRepoRoot", { enumerable: true, get: function () { return getRepoState_1.getRepoRoot; } });
|
|
23
|
-
Object.defineProperty(exports, "
|
|
23
|
+
Object.defineProperty(exports, "getRepoStateAsync", { enumerable: true, get: function () { return getRepoState_1.getRepoStateAsync; } });
|
|
24
24
|
Object.defineProperty(exports, "ensureGitMinimumVersion", { enumerable: true, get: function () { return getRepoState_1.ensureGitMinimumVersion; } });
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;;;;;GAUG;AAEH,mDAAsE;AAA7D,gHAAA,cAAc,OAAA;AAAE,oHAAA,kBAAkB,OAAA;AAC3C,+CAMwB;AAJtB,8GAAA,cAAc,OAAA;AACd,2GAAA,WAAW,OAAA;AACX,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;;;;;GAUG;AAEH,mDAAsE;AAA7D,gHAAA,cAAc,OAAA;AAAE,oHAAA,kBAAkB,OAAA;AAC3C,+CAMwB;AAJtB,8GAAA,cAAc,OAAA;AACd,2GAAA,WAAW,OAAA;AACX,iHAAA,iBAAiB,OAAA;AACjB,uHAAA,uBAAuB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * This package builds a JSON object containing the git hashes of all files used to produce a given NPM package.\n * The {@link https://rushjs.io/ | Rush} tool uses this library to implement incremental build detection.\n *\n * @remarks\n *\n * For more info, please see the package {@link https://www.npmjs.com/package/@rushstack/package-deps-hash\n * | README}.\n *\n * @packageDocumentation\n */\n\nexport { getPackageDeps, getGitHashForFiles } from './getPackageDeps';\nexport {\n IFileDiffStatus,\n getRepoChanges,\n getRepoRoot,\n getRepoStateAsync,\n ensureGitMinimumVersion\n} from './getRepoState';\n"]}
|