diff --git a/change/change-f0bd1776-bc07-4c5d-b8f9-04a5728eef3b.json b/change/change-f0bd1776-bc07-4c5d-b8f9-04a5728eef3b.json new file mode 100644 index 00000000..694d9da8 --- /dev/null +++ b/change/change-f0bd1776-bc07-4c5d-b8f9-04a5728eef3b.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "type": "patch", + "comment": "Limit git rev-list to one result", + "packageName": "workspace-tools", + "email": "rsiemens@microsoft.com", + "dependentChangeType": "patch" + } + ] +} \ No newline at end of file diff --git a/packages/workspace-tools/src/git/gitUtilities.ts b/packages/workspace-tools/src/git/gitUtilities.ts index cce677df..09864395 100644 --- a/packages/workspace-tools/src/git/gitUtilities.ts +++ b/packages/workspace-tools/src/git/gitUtilities.ts @@ -150,10 +150,10 @@ export function getCurrentHash(cwd: string) { * Get the commit hash in which the file was first added. */ export function getFileAddedHash(filename: string, cwd: string) { - const results = git(["rev-list", "HEAD", filename], { cwd }); + const results = git(["rev-list", "--max-count=1", "HEAD", filename], { cwd }); if (results.success) { - return results.stdout.trim().split("\n").slice(-1)[0]; + return results.stdout.trim(); } return undefined;