This commit is contained in:
di-sukharev
2023-05-21 00:06:07 +08:00
parent cd89054f0f
commit 07f07e5e18
2 changed files with 23 additions and 8 deletions

View File

@@ -27191,6 +27191,9 @@ function randomIntFromInterval(min, max) {
// src/github-action.ts
var import_fs2 = require("fs");
var import_util3 = require("util");
var import_child_process = require("child_process");
var execPromise = (0, import_util3.promisify)(import_child_process.exec);
var GITHUB_TOKEN = import_core3.default.getInput("GITHUB_TOKEN");
var pattern = import_core3.default.getInput("pattern");
var octokit = import_github.default.getOctokit(GITHUB_TOKEN);
@@ -27284,9 +27287,8 @@ async function improveCommitMessagesWithRebase({
ce(`creating -F file for ${commit.sha}`);
(0, import_fs2.writeFileSync)(`./commit-${i2}.txt`, improvedMessagesBySha[commit.sha]);
});
const done = await import_exec.default.exec(
`echo 0 > count.txt && git rebase -i ${commitsToImprove[0].sha}^ --exec "git commit --amend -F commit-$(cat count.txt).txt && echo $(($(cat count.txt) + 1)) > count.txt"`,
[],
await execPromise(
`echo 0 > count.txt && git rebase -i ${commitsToImprove[0].sha}^ --exec "git commit --amend -F commit-$(cat count.txt).txt && echo $(( $(cat count.txt) + 1 )) > count.txt"`,
{
env: {
GIT_SEQUENCE_EDITOR: 'sed -i -e "s/^pick/reword/g"',
@@ -27295,7 +27297,6 @@ async function improveCommitMessagesWithRebase({
}
}
);
ce(`!!!done: ${done}`);
commitsToImprove.forEach((_commit, i2) => (0, import_fs2.unlinkSync)(`./commit-${i2}.txt`));
ce("Force pushing interactively rebased commits into remote origin.");
await import_exec.default.exec("git", ["status"]);

View File

@@ -7,6 +7,9 @@ import { generateCommitMessageByDiff } from './generateCommitMessageFromGitDiff'
import { sleep } from './utils/sleep';
import { randomIntFromInterval } from './utils/randomIntFromInterval';
import { unlinkSync, writeFileSync } from 'fs';
import { promisify } from 'util';
import { exec as cpExec } from 'child_process';
const execPromise = promisify(cpExec);
// This should be a token with access to your repository scoped in as a secret.
// The YML workflow will need to set GITHUB_TOKEN with the GitHub Secret Token
@@ -163,9 +166,20 @@ async function improveCommitMessagesWithRebase({
});
// echo 0 > count.txt && git rebase <sha>^ --exec "git commit --amend -F \$(cat count.txt).txt && echo \$((\$(cat count.txt) + 1)) > count.txt"
const done = await exec.exec(
`echo 0 > count.txt && git rebase -i ${commitsToImprove[0].sha}^ --exec "git commit --amend -F commit-$(cat count.txt).txt && echo $(($(cat count.txt) + 1)) > count.txt"`,
[],
// const done = await exec.exec(
// `echo 0 > count.txt && git rebase -i ${commitsToImprove[0].sha}^ --exec "git commit --amend -F commit-$(cat count.txt).txt && echo $(($(cat count.txt) + 1)) > count.txt"`,
// [],
// {
// env: {
// GIT_SEQUENCE_EDITOR: 'sed -i -e "s/^pick/reword/g"',
// GIT_COMMITTER_NAME: process.env.GITHUB_ACTOR!,
// GIT_COMMITTER_EMAIL: `${process.env.GITHUB_ACTOR}@users.noreply.github.com`
// }
// }
// );
await execPromise(
`echo 0 > count.txt && git rebase -i ${commitsToImprove[0].sha}^ --exec "git commit --amend -F commit-$(cat count.txt).txt && echo $(( $(cat count.txt) + 1 )) > count.txt"`,
{
env: {
GIT_SEQUENCE_EDITOR: 'sed -i -e "s/^pick/reword/g"',
@@ -192,7 +206,7 @@ async function improveCommitMessagesWithRebase({
// }
// );
outro(`!!!done: ${done}`);
// outro(`!!!done: ${done}`);
commitsToImprove.forEach((_commit, i) => unlinkSync(`./commit-${i}.txt`));