This commit is contained in:
di-sukharev
2023-05-20 19:34:23 +08:00
parent 90361b65ee
commit 66eb8e1008
5 changed files with 1266 additions and 1980 deletions

View File

@@ -16333,6 +16333,7 @@ var package_default = {
},
dependencies: {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@clack/prompts": "^0.6.1",
"@dqbd/tiktoken": "^1.0.2",

File diff suppressed because it is too large Load Diff

30
package-lock.json generated
View File

@@ -10,6 +10,7 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@clack/prompts": "^0.6.1",
"@dqbd/tiktoken": "^1.0.2",
@@ -38,7 +39,6 @@
"dotenv": "^16.0.3",
"esbuild": "^0.15.18",
"eslint": "^8.28.0",
"husky": "^8.0.3",
"prettier": "^2.8.4",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
@@ -53,6 +53,14 @@
"uuid": "^8.3.2"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/github": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
@@ -137,6 +145,11 @@
"tunnel": "^0.0.6"
}
},
"node_modules/@actions/io": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
},
"node_modules/@clack/core": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@clack/core/-/core-0.3.2.tgz",
@@ -2187,21 +2200,6 @@
"node": ">=14.18.0"
}
},
"node_modules/husky": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz",
"integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==",
"dev": true,
"bin": {
"husky": "lib/bin.js"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",

View File

@@ -61,6 +61,7 @@
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@clack/prompts": "^0.6.1",
"@dqbd/tiktoken": "^1.0.2",

View File

@@ -1,6 +1,6 @@
import core from '@actions/core';
import github from '@actions/github';
import { execa } from 'execa';
import exec from '@actions/exec';
import { intro, outro } from '@clack/prompts';
import { PullRequestEvent } from '@octokit/webhooks-types';
import { generateCommitMessageByDiff } from './generateCommitMessageFromGitDiff';
@@ -140,28 +140,28 @@ async function improveCommitMessagesWithRebase({
outro(`Starting interactive rebase: "$ rebase -i ${base}".`);
// Set the Git identity
await execa('git', [
await exec.exec('git', [
'config',
'user.email',
`${process.env.GITHUB_ACTOR}@users.noreply.github.com`
]);
await execa('git', ['config', 'user.name', process.env.GITHUB_ACTOR!]);
await exec.exec('git', ['config', 'user.name', process.env.GITHUB_ACTOR!]);
// fetch all commits inside the process
await execa('git', ['fetch', '--all']);
await exec.exec('git', ['fetch', '--all']);
for (const commit of commitsToImprove) {
try {
const improvedMessage = improvedMessagesBySha[commit.sha];
// Checkout the commit
await execa('git', ['checkout', commit.sha]);
await exec.exec('git', ['checkout', commit.sha]);
// Amend the commit message
await execa('git', ['commit', '--amend', '-m', improvedMessage]);
await exec.exec('git', ['commit', '--amend', '-m', improvedMessage]);
outro('Commit improved 🌞');
// await execa('git', ['commit', '--amend', '-m', improvedMessage]);
// await execa('git', ['rebase', '--continue']);
// await exec.exec('git', ['commit', '--amend', '-m', improvedMessage]);
// await exec.exec('git', ['rebase', '--continue']);
} catch (error) {
throw error;
}
@@ -169,13 +169,13 @@ async function improveCommitMessagesWithRebase({
// Once all commits have been amended, you'll need to rebase the original branch onto the last amended commit
const lastCommit = commits[0];
await execa('git', ['checkout', source]); // replace 'master' with your branch name
await execa('git', ['rebase', lastCommit.sha]);
await exec.exec('git', ['checkout', source]);
await exec.exec('git', ['rebase', lastCommit.sha]);
outro('Force pushing interactively rebased commits into remote origin.');
// Force push the rebased commits
await execa('git', ['push', 'origin', `+${source}`]);
await exec.exec('git', ['push', 'origin', `+${source}`]);
outro('Done ⏱️');
}