Skip to content

Commit

Permalink
fix: disable diff detection for renames and copies (#3330)
Browse files Browse the repository at this point in the history
* fix: disable diff detection for renames and copies

* fix format
  • Loading branch information
peter-evans authored Sep 12, 2024
1 parent f4d66f4 commit d121e62
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
9 changes: 6 additions & 3 deletions __test__/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
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
Expand Down
21 changes: 15 additions & 6 deletions __test__/git-command-manager.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
Expand Down
1 change: 1 addition & 0 deletions src/git-command-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
])
Expand Down

0 comments on commit d121e62

Please sign in to comment.