Skip to content

Commit

Permalink
[eas-cli] fix git diff header in fingerprint:compare (#2915)
Browse files Browse the repository at this point in the history
* [eas-cli] fix git diff header in fingerprint:compare

* Temporary Commit at 2/24/2025, 12:01:45 PM
  • Loading branch information
quinlanj authored Feb 24, 2025
1 parent 3ac6472 commit 1b713af
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is the log of notable changes to EAS CLI and related packages.

- Fix `eas fingerprint:compare` URL generation and pretty prints. ([#2909](https://github.com/expo/eas-cli/pull/2909) by [@quinlanj](https://github.com/quinlanj))
- fix formatFields to handle empty array. ([#2914](https://github.com/expo/eas-cli/pull/2914) by [@quinlanj](https://github.com/quinlanj))
- fix git diff header in `fingerprint:compare`. ([#2915](https://github.com/expo/eas-cli/pull/2915) by [@quinlanj](https://github.com/quinlanj))

## [15.0.12](https://github.com/expo/eas-cli/releases/tag/v15.0.12) - 2025-02-22

Expand Down
4 changes: 2 additions & 2 deletions packages/eas-cli/src/utils/__tests__/fingerprintDiff-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('abridgedDiff', () => {
abridgedDiff(str1, str2, 1);

const expectedOutput = [
'cyan(@@ -2,1 +2,1 @@)',
'cyan(@@ -1,3 +1,3 @@)',
' gray(Line1)',
'red(-Line2)',
'green(+LineX)',
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('abridgedDiff', () => {
abridgedDiff(str1, str2, 1);

const expectedOutput = [
'cyan(@@ -3,1 +3,1 @@)',
'cyan(@@ -2,3 +2,3 @@)',
' gray(Line1)',
'red(-Line2)',
'green(+LineX)',
Expand Down
9 changes: 7 additions & 2 deletions packages/eas-cli/src/utils/fingerprintDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ export function abridgedDiff(str1: string, str2: string, contextLines: number =

const flushChunk = (): void => {
if (currentChunk.length > 0) {
const originalRange = `${startOriginal},${removedLines || 0}`;
const modifiedRange = `${startModified},${addedLines || 0}`;
const contextLines = currentChunkPriorContext.length + currentChunkAfterContext.length;
const originalRange = `${(startOriginal ?? 1) - currentChunkPriorContext.length},${
contextLines + removedLines
}`;
const modifiedRange = `${(startModified ?? 1) - currentChunkPriorContext.length},${
contextLines + addedLines
}`;
// `git diff` style header
output.push(chalk.cyan(`@@ -${originalRange} +${modifiedRange} @@`));
output.push(...currentChunkPriorContext);
Expand Down

0 comments on commit 1b713af

Please sign in to comment.