Compare commits
6 Commits
diff-stat-
...
v7.0.3
Author | SHA1 | Date | |
---|---|---|---|
6cd32fd936 | |||
d121e62763 | |||
f4d66f4d5a | |||
488c869d17 | |||
5354f85616 | |||
8867c4aba1 |
20
README.md
20
README.md
@ -246,26 +246,6 @@ Note that the repository must be checked out on a branch with a remote, it won't
|
|||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v7
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
|
||||||
### Create a project card
|
|
||||||
|
|
||||||
To create a project card for the pull request, pass the `pull-request-number` step output to [create-or-update-project-card](https://github.com/peter-evans/create-or-update-project-card) action.
|
|
||||||
|
|
||||||
```yml
|
|
||||||
- name: Create Pull Request
|
|
||||||
id: cpr
|
|
||||||
uses: peter-evans/create-pull-request@v7
|
|
||||||
|
|
||||||
- name: Create or Update Project Card
|
|
||||||
if: ${{ steps.cpr.outputs.pull-request-number }}
|
|
||||||
uses: peter-evans/create-or-update-project-card@v2
|
|
||||||
with:
|
|
||||||
project-name: My project
|
|
||||||
column-name: My column
|
|
||||||
issue-number: ${{ steps.cpr.outputs.pull-request-number }}
|
|
||||||
```
|
|
||||||
-->
|
|
||||||
|
|
||||||
### Auto-merge
|
### Auto-merge
|
||||||
|
|
||||||
Auto-merge can be enabled on a pull request allowing it to be automatically merged once requirements have been satisfied.
|
Auto-merge can be enabled on a pull request allowing it to be automatically merged once requirements have been satisfied.
|
||||||
|
@ -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
|
cd /git/local/repos/test-base
|
||||||
git config --global user.email "you@example.com"
|
git config --global user.email "you@example.com"
|
||||||
git config --global user.name "Your Name"
|
git config --global user.name "Your Name"
|
||||||
echo "#test-base" > README.md
|
echo "#test-base" > README_TEMP.md
|
||||||
git add .
|
git add .
|
||||||
git commit -m "initial commit"
|
git commit -m "initial commit"
|
||||||
git commit --allow-empty -m "empty commit for tests"
|
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 add .
|
||||||
git commit -m "add sparkles" -m "Change description:
|
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 push -u
|
||||||
git log -1 --pretty=oneline
|
git log -1 --pretty=oneline
|
||||||
git config --global --unset user.email
|
git config --global --unset user.email
|
||||||
|
@ -11,14 +11,15 @@ describe('git-command-manager integration tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('tests getCommit', async () => {
|
it('tests getCommit', async () => {
|
||||||
const initialCommit = await git.getCommit('HEAD^^')
|
const initialCommit = await git.getCommit('HEAD^^^')
|
||||||
const emptyCommit = await git.getCommit('HEAD^')
|
const emptyCommit = await git.getCommit('HEAD^^')
|
||||||
|
const modifiedCommit = await git.getCommit('HEAD^')
|
||||||
const headCommit = await git.getCommit('HEAD')
|
const headCommit = await git.getCommit('HEAD')
|
||||||
|
|
||||||
expect(initialCommit.subject).toEqual('initial commit')
|
expect(initialCommit.subject).toEqual('initial commit')
|
||||||
expect(initialCommit.signed).toBeFalsy()
|
expect(initialCommit.signed).toBeFalsy()
|
||||||
expect(initialCommit.changes).toEqual([
|
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')
|
expect(emptyCommit.subject).toEqual('empty commit for tests')
|
||||||
@ -27,11 +28,19 @@ describe('git-command-manager integration tests', () => {
|
|||||||
expect(emptyCommit.signed).toBeFalsy()
|
expect(emptyCommit.signed).toBeFalsy()
|
||||||
expect(emptyCommit.changes).toEqual([])
|
expect(emptyCommit.changes).toEqual([])
|
||||||
|
|
||||||
expect(headCommit.subject).toEqual('add sparkles')
|
expect(modifiedCommit.subject).toEqual('add sparkles')
|
||||||
expect(headCommit.parents[0]).toEqual(emptyCommit.sha)
|
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.signed).toBeFalsy()
|
||||||
expect(headCommit.changes).toEqual([
|
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'}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
15
dist/index.js
vendored
15
dist/index.js
vendored
@ -46,6 +46,7 @@ exports.buildBranchCommits = buildBranchCommits;
|
|||||||
exports.createOrUpdateBranch = createOrUpdateBranch;
|
exports.createOrUpdateBranch = createOrUpdateBranch;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const uuid_1 = __nccwpck_require__(5840);
|
const uuid_1 = __nccwpck_require__(5840);
|
||||||
|
const utils = __importStar(__nccwpck_require__(918));
|
||||||
const CHERRYPICK_EMPTY = 'The previous cherry-pick is now empty, possibly due to conflict resolution.';
|
const CHERRYPICK_EMPTY = 'The previous cherry-pick is now empty, possibly due to conflict resolution.';
|
||||||
const NOTHING_TO_COMMIT = 'nothing to commit, working tree clean';
|
const NOTHING_TO_COMMIT = 'nothing to commit, working tree clean';
|
||||||
const FETCH_DEPTH_MARGIN = 10;
|
const FETCH_DEPTH_MARGIN = 10;
|
||||||
@ -136,9 +137,19 @@ function isEven(git, branch1, branch2) {
|
|||||||
// Return true if the specified number of commits on branch1 and branch2 have a diff
|
// Return true if the specified number of commits on branch1 and branch2 have a diff
|
||||||
function commitsHaveDiff(git, branch1, branch2, depth) {
|
function commitsHaveDiff(git, branch1, branch2, depth) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// Some action use cases lead to the depth being a very large number and the diff fails.
|
||||||
|
// I've made this check optional for now because it was a fix for an edge case that is
|
||||||
|
// very rare, anyway.
|
||||||
|
try {
|
||||||
const diff1 = (yield git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])).stdout.trim();
|
const diff1 = (yield git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])).stdout.trim();
|
||||||
const diff2 = (yield git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])).stdout.trim();
|
const diff2 = (yield git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])).stdout.trim();
|
||||||
return diff1 !== diff2;
|
return diff1 !== diff2;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.info('Failed optional check of commits diff; Skipping.');
|
||||||
|
core.debug(utils.getErrorMessage(error));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function splitLines(multilineString) {
|
function splitLines(multilineString) {
|
||||||
@ -734,6 +745,8 @@ class GitCommandManager {
|
|||||||
'show',
|
'show',
|
||||||
'--raw',
|
'--raw',
|
||||||
'--cc',
|
'--cc',
|
||||||
|
'--no-renames',
|
||||||
|
'--no-abbrev',
|
||||||
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
||||||
ref
|
ref
|
||||||
]);
|
]);
|
||||||
@ -749,7 +762,7 @@ class GitCommandManager {
|
|||||||
subject: detailLines[4],
|
subject: detailLines[4],
|
||||||
body: detailLines.slice(5, endOfBodyIndex).join('\n'),
|
body: detailLines.slice(5, endOfBodyIndex).join('\n'),
|
||||||
changes: lines.slice(endOfBodyIndex + 2, -1).map(line => {
|
changes: lines.slice(endOfBodyIndex + 2, -1).map(line => {
|
||||||
const change = line.match(/^:(\d{6}) (\d{6}) \w{7} \w{7} ([AMD])\s+(.*)$/);
|
const change = line.match(/^:(\d{6}) (\d{6}) \w{40} \w{40} ([AMD])\s+(.*)$/);
|
||||||
if (change) {
|
if (change) {
|
||||||
return {
|
return {
|
||||||
mode: change[3] === 'D' ? change[1] : change[2],
|
mode: change[3] === 'D' ? change[1] : change[2],
|
||||||
|
16
package-lock.json
generated
16
package-lock.json
generated
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^18.19.48",
|
"@types/node": "^18.19.50",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||||
"@typescript-eslint/parser": "^7.18.0",
|
"@typescript-eslint/parser": "^7.18.0",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.6.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
@ -1560,9 +1560,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "18.19.48",
|
"version": "18.19.50",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.48.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.50.tgz",
|
||||||
"integrity": "sha512-7WevbG4ekUcRQSZzOwxWgi5dZmTak7FaxXDoW7xVxPBmKx1rTzfmRLkeCgJzcbBnOV2dkhAPc8cCeT6agocpjg==",
|
"integrity": "sha512-xonK+NRrMBRtkL1hVCc3G+uXtjh1Al4opBLjqVmipe5ZAaBYWW6cNAiBVZ1BvmkBhep698rP3UM3aRAdSALuhg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~5.26.4"
|
"undici-types": "~5.26.4"
|
||||||
@ -7756,9 +7756,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.5.4",
|
"version": "5.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
|
||||||
"integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==",
|
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^18.19.48",
|
"@types/node": "^18.19.50",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||||
"@typescript-eslint/parser": "^7.18.0",
|
"@typescript-eslint/parser": "^7.18.0",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
@ -58,6 +58,6 @@
|
|||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {GitCommandManager, Commit} from './git-command-manager'
|
import {GitCommandManager, Commit} from './git-command-manager'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
import {v4 as uuidv4} from 'uuid'
|
||||||
|
import * as utils from './utils'
|
||||||
|
|
||||||
const CHERRYPICK_EMPTY =
|
const CHERRYPICK_EMPTY =
|
||||||
'The previous cherry-pick is now empty, possibly due to conflict resolution.'
|
'The previous cherry-pick is now empty, possibly due to conflict resolution.'
|
||||||
@ -131,6 +132,10 @@ async function commitsHaveDiff(
|
|||||||
branch2: string,
|
branch2: string,
|
||||||
depth: number
|
depth: number
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
|
// Some action use cases lead to the depth being a very large number and the diff fails.
|
||||||
|
// I've made this check optional for now because it was a fix for an edge case that is
|
||||||
|
// very rare, anyway.
|
||||||
|
try {
|
||||||
const diff1 = (
|
const diff1 = (
|
||||||
await git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])
|
await git.exec(['diff', '--stat', `${branch1}..${branch1}~${depth}`])
|
||||||
).stdout.trim()
|
).stdout.trim()
|
||||||
@ -138,6 +143,11 @@ async function commitsHaveDiff(
|
|||||||
await git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])
|
await git.exec(['diff', '--stat', `${branch2}..${branch2}~${depth}`])
|
||||||
).stdout.trim()
|
).stdout.trim()
|
||||||
return diff1 !== diff2
|
return diff1 !== diff2
|
||||||
|
} catch (error) {
|
||||||
|
core.info('Failed optional check of commits diff; Skipping.')
|
||||||
|
core.debug(utils.getErrorMessage(error))
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function splitLines(multilineString: string): string[] {
|
function splitLines(multilineString: string): string[] {
|
||||||
|
@ -159,6 +159,8 @@ export class GitCommandManager {
|
|||||||
'show',
|
'show',
|
||||||
'--raw',
|
'--raw',
|
||||||
'--cc',
|
'--cc',
|
||||||
|
'--no-renames',
|
||||||
|
'--no-abbrev',
|
||||||
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
||||||
ref
|
ref
|
||||||
])
|
])
|
||||||
@ -176,7 +178,7 @@ export class GitCommandManager {
|
|||||||
body: detailLines.slice(5, endOfBodyIndex).join('\n'),
|
body: detailLines.slice(5, endOfBodyIndex).join('\n'),
|
||||||
changes: lines.slice(endOfBodyIndex + 2, -1).map(line => {
|
changes: lines.slice(endOfBodyIndex + 2, -1).map(line => {
|
||||||
const change = line.match(
|
const change = line.match(
|
||||||
/^:(\d{6}) (\d{6}) \w{7} \w{7} ([AMD])\s+(.*)$/
|
/^:(\d{6}) (\d{6}) \w{40} \w{40} ([AMD])\s+(.*)$/
|
||||||
)
|
)
|
||||||
if (change) {
|
if (change) {
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user