fix: disable diff detection for renames and copies (#3330)

* fix: disable diff detection for renames and copies

* fix format
This commit is contained in:
Peter Evans 2024-09-12 12:48:43 +01:00 committed by GitHub
parent f4d66f4d5a
commit d121e62763
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 9 deletions

View file

@ -19,14 +19,17 @@ git clone git://127.0.0.1/repos/test-base.git /git/local/repos/test-base
cd /git/local/repos/test-base
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
echo "#test-base" > README.md
echo "#test-base" > README_TEMP.md
git add .
git commit -m "initial commit"
git commit --allow-empty -m "empty commit for tests"
echo "#test-base :sparkles:" > README.md
echo "#test-base :sparkles:" > README_TEMP.md
git add .
git commit -m "add sparkles" -m "Change description:
- updates README.md to add sparkles to the title"
- updates README_TEMP.md to add sparkles to the title"
mv README_TEMP.md README.md
git add .
git commit -m "rename readme"
git push -u
git log -1 --pretty=oneline
git config --global --unset user.email

View file

@ -11,14 +11,15 @@ describe('git-command-manager integration tests', () => {
})
it('tests getCommit', async () => {
const initialCommit = await git.getCommit('HEAD^^')
const emptyCommit = await git.getCommit('HEAD^')
const initialCommit = await git.getCommit('HEAD^^^')
const emptyCommit = await git.getCommit('HEAD^^')
const modifiedCommit = await git.getCommit('HEAD^')
const headCommit = await git.getCommit('HEAD')
expect(initialCommit.subject).toEqual('initial commit')
expect(initialCommit.signed).toBeFalsy()
expect(initialCommit.changes).toEqual([
{mode: '100644', status: 'A', path: 'README.md'}
{mode: '100644', status: 'A', path: 'README_TEMP.md'}
])
expect(emptyCommit.subject).toEqual('empty commit for tests')
@ -27,11 +28,19 @@ describe('git-command-manager integration tests', () => {
expect(emptyCommit.signed).toBeFalsy()
expect(emptyCommit.changes).toEqual([])
expect(headCommit.subject).toEqual('add sparkles')
expect(headCommit.parents[0]).toEqual(emptyCommit.sha)
expect(modifiedCommit.subject).toEqual('add sparkles')
expect(modifiedCommit.parents[0]).toEqual(emptyCommit.sha)
expect(modifiedCommit.signed).toBeFalsy()
expect(modifiedCommit.changes).toEqual([
{mode: '100644', status: 'M', path: 'README_TEMP.md'}
])
expect(headCommit.subject).toEqual('rename readme')
expect(headCommit.parents[0]).toEqual(modifiedCommit.sha)
expect(headCommit.signed).toBeFalsy()
expect(headCommit.changes).toEqual([
{mode: '100644', status: 'M', path: 'README.md'}
{mode: '100644', status: 'A', path: 'README.md'},
{mode: '100644', status: 'D', path: 'README_TEMP.md'}
])
})
})

1
dist/index.js vendored
View file

@ -745,6 +745,7 @@ class GitCommandManager {
'show',
'--raw',
'--cc',
'--no-renames',
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
ref
]);

View file

@ -159,6 +159,7 @@ export class GitCommandManager {
'show',
'--raw',
'--cc',
'--no-renames',
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
ref
])