Skip to content

Commit d121e62

Browse files
authored
fix: disable diff detection for renames and copies (#3330)
* fix: disable diff detection for renames and copies * fix format
1 parent f4d66f4 commit d121e62

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

__test__/entrypoint.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ git clone git://127.0.0.1/repos/test-base.git /git/local/repos/test-base
1919
cd /git/local/repos/test-base
2020
git config --global user.email "[email protected]"
2121
git config --global user.name "Your Name"
22-
echo "#test-base" > README.md
22+
echo "#test-base" > README_TEMP.md
2323
git add .
2424
git commit -m "initial commit"
2525
git commit --allow-empty -m "empty commit for tests"
26-
echo "#test-base :sparkles:" > README.md
26+
echo "#test-base :sparkles:" > README_TEMP.md
2727
git add .
2828
git commit -m "add sparkles" -m "Change description:
29-
- updates README.md to add sparkles to the title"
29+
- updates README_TEMP.md to add sparkles to the title"
30+
mv README_TEMP.md README.md
31+
git add .
32+
git commit -m "rename readme"
3033
git push -u
3134
git log -1 --pretty=oneline
3235
git config --global --unset user.email

__test__/git-command-manager.int.test.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ describe('git-command-manager integration tests', () => {
1111
})
1212

1313
it('tests getCommit', async () => {
14-
const initialCommit = await git.getCommit('HEAD^^')
15-
const emptyCommit = await git.getCommit('HEAD^')
14+
const initialCommit = await git.getCommit('HEAD^^^')
15+
const emptyCommit = await git.getCommit('HEAD^^')
16+
const modifiedCommit = await git.getCommit('HEAD^')
1617
const headCommit = await git.getCommit('HEAD')
1718

1819
expect(initialCommit.subject).toEqual('initial commit')
1920
expect(initialCommit.signed).toBeFalsy()
2021
expect(initialCommit.changes).toEqual([
21-
{mode: '100644', status: 'A', path: 'README.md'}
22+
{mode: '100644', status: 'A', path: 'README_TEMP.md'}
2223
])
2324

2425
expect(emptyCommit.subject).toEqual('empty commit for tests')
@@ -27,11 +28,19 @@ describe('git-command-manager integration tests', () => {
2728
expect(emptyCommit.signed).toBeFalsy()
2829
expect(emptyCommit.changes).toEqual([])
2930

30-
expect(headCommit.subject).toEqual('add sparkles')
31-
expect(headCommit.parents[0]).toEqual(emptyCommit.sha)
31+
expect(modifiedCommit.subject).toEqual('add sparkles')
32+
expect(modifiedCommit.parents[0]).toEqual(emptyCommit.sha)
33+
expect(modifiedCommit.signed).toBeFalsy()
34+
expect(modifiedCommit.changes).toEqual([
35+
{mode: '100644', status: 'M', path: 'README_TEMP.md'}
36+
])
37+
38+
expect(headCommit.subject).toEqual('rename readme')
39+
expect(headCommit.parents[0]).toEqual(modifiedCommit.sha)
3240
expect(headCommit.signed).toBeFalsy()
3341
expect(headCommit.changes).toEqual([
34-
{mode: '100644', status: 'M', path: 'README.md'}
42+
{mode: '100644', status: 'A', path: 'README.md'},
43+
{mode: '100644', status: 'D', path: 'README_TEMP.md'}
3544
])
3645
})
3746
})

dist/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ class GitCommandManager {
745745
'show',
746746
'--raw',
747747
'--cc',
748+
'--no-renames',
748749
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
749750
ref
750751
]);

src/git-command-manager.ts

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export class GitCommandManager {
159159
'show',
160160
'--raw',
161161
'--cc',
162+
'--no-renames',
162163
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
163164
ref
164165
])

0 commit comments

Comments
 (0)