From 45b1e3298a08add437ab6a2032314255997e5de8 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 11 Nov 2020 22:44:04 +0100 Subject: [PATCH] Allow to overwrite on copy to temp folder Show changed files in group --- .github/workflows/ci.yml | 1 + dist/index.js | 12 +++++++----- src/git.ts | 4 ++-- src/main.ts | 9 ++++++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b83ee91..811f9b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: name: Gen dummy page run: | mkdir public + touch public/file{0001..3000} cat > public/index.html < diff --git a/dist/index.js b/dist/index.js index 67454e5..9abe34b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -183,9 +183,9 @@ function commit(allowEmptyCommit, author, message) { }); } exports.commit = commit; -function showStat(count) { +function showStat() { return __awaiter(this, void 0, void 0, function* () { - return yield git(['show', `--stat-count=${count}`, 'HEAD']).then(output => { + return yield git(['show', `--stat-count=2000`, 'HEAD']).then(output => { return output; }); }); @@ -301,6 +301,8 @@ function run() { } core.info(`🏃 Copying ${path.join(currentdir, buildDir)} contents to ${tmpdir}`); yield fs_extra_1.copySync(path.join(currentdir, buildDir), tmpdir, { + overwrite: true, + errorOnExist: false, dereference: true }); if (fqdn) { @@ -327,16 +329,16 @@ function run() { } core.info(`📐 Updating index of working tree`); yield git.add('.'); - core.info(`📦 Committing changes`); if (allowEmptyCommit) { core.info(`✅ Allow empty commit`); } const authorPrs = addressparser_1.default(author)[0]; - core.info(`🔨 Configuring git author as ${authorPrs.name} <${authorPrs.address}>`); + core.startGroup(`📦 Committing changes as ${authorPrs.name} <${authorPrs.address}> author`); yield git.commit(allowEmptyCommit, `${authorPrs.name} <${authorPrs.address}>`, commitMessage); - yield git.showStat(10).then(output => { + yield git.showStat().then(output => { core.info(output); }); + core.endGroup(); core.info(`🏃 Pushing ${buildDir} directory to ${targetBranch} branch on ${repo} repo`); if (!keepHistory) { core.info(`✅ Force push`); diff --git a/src/git.ts b/src/git.ts index d18c99c..9f4d523 100644 --- a/src/git.ts +++ b/src/git.ts @@ -67,8 +67,8 @@ export async function commit(allowEmptyCommit: boolean, author: string, message: await git(args); } -export async function showStat(count: number): Promise { - return await git(['show', `--stat-count=${count}`, 'HEAD']).then(output => { +export async function showStat(): Promise { + return await git(['show', `--stat-count=2000`, 'HEAD']).then(output => { return output; }); } diff --git a/src/main.ts b/src/main.ts index 145270f..5340d10 100644 --- a/src/main.ts +++ b/src/main.ts @@ -58,6 +58,8 @@ async function run() { core.info(`🏃 Copying ${path.join(currentdir, buildDir)} contents to ${tmpdir}`); await copySync(path.join(currentdir, buildDir), tmpdir, { + overwrite: true, + errorOnExist: false, dereference: true }); @@ -91,16 +93,17 @@ async function run() { core.info(`📐 Updating index of working tree`); await git.add('.'); - core.info(`📦 Committing changes`); if (allowEmptyCommit) { core.info(`✅ Allow empty commit`); } + const authorPrs: addressparser.Address = addressparser(author)[0]; - core.info(`🔨 Configuring git author as ${authorPrs.name} <${authorPrs.address}>`); + core.startGroup(`📦 Committing changes as ${authorPrs.name} <${authorPrs.address}> author`); await git.commit(allowEmptyCommit, `${authorPrs.name} <${authorPrs.address}>`, commitMessage); - await git.showStat(10).then(output => { + await git.showStat().then(output => { core.info(output); }); + core.endGroup(); core.info(`🏃 Pushing ${buildDir} directory to ${targetBranch} branch on ${repo} repo`); if (!keepHistory) {