From 93b1e47bc3a1268b8cd132be5d916ddc586aac88 Mon Sep 17 00:00:00 2001 From: Technote Date: Mon, 8 Feb 2021 01:10:20 +0900 Subject: [PATCH 1/3] chore: update packages --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 42fd4a8..d5f7116 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@actions/github": "^4.0.0", "@octokit/openapi-types": "^4.0.1", "@technote-space/filter-github-action": "^0.5.16", - "@technote-space/github-action-helper": "^5.1.1", + "@technote-space/github-action-helper": "^5.2.0", "moment": "^2.29.1" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 0f8071d..43b590d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -777,10 +777,10 @@ "@actions/core" "^1.2.6" "@actions/github" "^4.0.0" -"@technote-space/github-action-helper@^5.1.1": - version "5.1.1" - resolved "https://registry.yarnpkg.com/@technote-space/github-action-helper/-/github-action-helper-5.1.1.tgz#deae7d28d7280bd4ff65624e30e3c45390627e4e" - integrity sha512-16y4mN7+LFVjTdf12NlprDQdvEOqZWrCDQjNd+x8pxdjTeYdvW9Asip7RB6ouuM3XSDteneHAb6s4Qk4cyyaxg== +"@technote-space/github-action-helper@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@technote-space/github-action-helper/-/github-action-helper-5.2.0.tgz#022e6c32f858910fd97492145f41a184934f4e12" + integrity sha512-VnMQ6Bm6UeBjWJCgPI87ZeXj48bgzLMIhDhziSA7hWYKCQChLGnjztbu9Xagmi+VgwjI6R2IHfsw5oMwvpXf9w== dependencies: "@actions/core" "^1.2.6" "@actions/github" "^4.0.0" From 46fa749f1535bfc5563522eeb5cb271c89e10302 Mon Sep 17 00:00:00 2001 From: Technote Date: Mon, 8 Feb 2021 01:10:56 +0900 Subject: [PATCH 2/3] fix: default branch config --- __tests__/index.test.ts | 2 + __tests__/utils/command.test.ts | 55 ++------- __tests__/utils/process1.test.ts | 50 ++++---- __tests__/utils/process2.test.ts | 192 +++++++++---------------------- src/utils/command.ts | 24 ++-- src/utils/process.ts | 6 +- 6 files changed, 104 insertions(+), 225 deletions(-) diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index cc07235..04fd030 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -188,6 +188,8 @@ describe('main', () => { '::endgroup::', '==================================================', '', + '[command]git config --global \'init.defaultBranch\' master', + ' >> stdout', '::group::Total:0 Succeeded:0 Failed:0 Skipped:0', '::set-output name=result::skipped', '::endgroup::', diff --git a/__tests__/utils/command.test.ts b/__tests__/utils/command.test.ts index 164001b..b447a58 100644 --- a/__tests__/utils/command.test.ts +++ b/__tests__/utils/command.test.ts @@ -105,9 +105,6 @@ describe('clone', () => { })); execCalledWith(mockExec, [ - 'git config --global \'init.defaultBranch\' master', - 'git config \'user.name\' \'GitHub Actions\'', - 'git config \'user.email\' \'example@example.com\'', 'git init \'.\'', 'git remote add origin \'https://octocat:test-token@github.com/hello/world.git\' || :', 'git fetch --no-tags origin \'refs/heads/hello-world/test-branch:refs/remotes/origin/hello-world/test-branch\' || :', @@ -117,12 +114,6 @@ describe('clone', () => { ]); stdoutCalledWith(mockStdout, [ '::group::Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - ' >> stdout', - '[command]git config \'user.name\' \'GitHub Actions\'', - ' >> stdout', - '[command]git config \'user.email\' \'example@example.com\'', - ' >> stdout', '[command]git init \'.\'', ' >> stdout', '[command]git remote add origin', @@ -361,9 +352,6 @@ describe('getChangedFiles', () => { }); stdoutCalledWith(mockStdout, [ '::group::Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/hello-world/test-branch:refs/remotes/origin/hello-world/test-branch\'', '[command]git reset --hard', @@ -380,11 +368,10 @@ describe('getChangedFiles', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/hello-world/test-branch] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/hello-world/test-branch:refs/remotes/origin/hello-world/test-branch\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/hello-world/test-branch', ' >> Auto-merging merge.txt', ' >> CONFLICT (content): Merge conflict in merge.txt', @@ -441,9 +428,6 @@ describe('getChangedFiles', () => { }); stdoutCalledWith(mockStdout, [ '::group::Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/hello-world/test-branch:refs/remotes/origin/hello-world/test-branch\'', '[command]git reset --hard', @@ -458,11 +442,10 @@ describe('getChangedFiles', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/hello-world/test-branch] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/hello-world/test-branch:refs/remotes/origin/hello-world/test-branch\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/hello-world/test-branch', ' >> Already up to date.', '::endgroup::', @@ -559,9 +542,6 @@ describe('getChangedFiles', () => { }); stdoutCalledWith(mockStdout, [ '::group::Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/hello-world/test-branch:refs/remotes/origin/hello-world/test-branch\'', '[command]git reset --hard', @@ -576,11 +556,10 @@ describe('getChangedFiles', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/hello-world/test-branch] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/hello-world/test-branch:refs/remotes/origin/hello-world/test-branch\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/hello-world/test-branch', ' >> Already up to date.', '::endgroup::', @@ -834,12 +813,11 @@ describe('resolveConflicts', () => { })); execCalledWith(mockExec, [ - 'git config --global \'init.defaultBranch\' master', - 'git config \'user.name\' \'GitHub Actions\'', - 'git config \'user.email\' \'example@example.com\'', 'git init \'.\'', 'git remote add origin \'https://octocat:test-token@github.com/hello/world.git\' || :', 'git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\' || :', + 'git config \'user.name\' \'GitHub Actions\'', + 'git config \'user.email\' \'example@example.com\'', 'git merge --no-edit origin/feature/new-feature || :', 'git push origin \'test:refs/heads/test\'', ]); @@ -870,17 +848,13 @@ describe('resolveConflicts', () => { })); execCalledWith(mockExec, [ - 'git config --global \'init.defaultBranch\' master', - 'git config \'user.name\' \'GitHub Actions\'', - 'git config \'user.email\' \'example@example.com\'', 'git init \'.\'', 'git remote add origin \'https://octocat:test-token@github.com/hello/world.git\' || :', 'git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\' || :', - 'git merge --no-edit origin/feature/new-feature || :', - `rm -rdf ${workDir}`, - 'git config --global \'init.defaultBranch\' master', 'git config \'user.name\' \'GitHub Actions\'', 'git config \'user.email\' \'example@example.com\'', + 'git merge --no-edit origin/feature/new-feature || :', + `rm -rdf ${workDir}`, 'git init \'.\'', 'git remote add origin \'https://octocat:test-token@github.com/hello/world.git\' || :', 'git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\' || :', @@ -928,17 +902,13 @@ describe('resolveConflicts', () => { })); execCalledWith(mockExec, [ - 'git config --global \'init.defaultBranch\' master', - 'git config \'user.name\' \'GitHub Actions\'', - 'git config \'user.email\' \'example@example.com\'', 'git init \'.\'', 'git remote add origin \'https://octocat:test-token@github.com/hello/world.git\' || :', 'git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\' || :', - 'git merge --no-edit origin/feature/new-feature || :', - `rm -rdf ${workDir}`, - 'git config --global \'init.defaultBranch\' master', 'git config \'user.name\' \'GitHub Actions\'', 'git config \'user.email\' \'example@example.com\'', + 'git merge --no-edit origin/feature/new-feature || :', + `rm -rdf ${workDir}`, 'git init \'.\'', 'git remote add origin \'https://octocat:test-token@github.com/hello/world.git\' || :', 'git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\' || :', @@ -948,7 +918,6 @@ describe('resolveConflicts', () => { 'yarn upgrade', 'git add --all', 'git status --short -uno', - 'git config --global \'init.defaultBranch\' master', 'git config \'user.name\' \'GitHub Actions\'', 'git config \'user.email\' \'example@example.com\'', 'git commit -qm \'commit message\'', diff --git a/__tests__/utils/process1.test.ts b/__tests__/utils/process1.test.ts index 07961a5..21cd389 100644 --- a/__tests__/utils/process1.test.ts +++ b/__tests__/utils/process1.test.ts @@ -113,11 +113,9 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', '[command]git reset --hard', @@ -129,11 +127,10 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'user.name\' test-actor', + '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git merge --no-edit origin/master', '> Running commands...', '> Checking diff...', @@ -198,10 +195,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -228,7 +223,6 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -283,13 +277,9 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', ' >> stdout', - '[command]git config \'user.name\' \'GitHub Actions\'', - ' >> stdout', - '[command]git config \'user.email\' \'example@example.com\'', - ' >> stdout', + '::group::Fetching...', '[command]git remote add origin', ' >> stdout', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-21031067:refs/remotes/origin/Hello-World/test-21031067\'', @@ -374,6 +364,8 @@ describe('execute', () => { }, 'develop'))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' develop', + ' >> stdout', '::group::Target PullRequest Ref [change/new-topic1]', '> Closing PullRequest... [change/new-topic1]', '> Deleting reference... [refs/heads/change/new-topic1]', @@ -437,11 +429,9 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', '[command]git reset --hard', @@ -453,17 +443,15 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/master', '> Running commands...', '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -514,6 +502,8 @@ describe('execute', () => { }, 'develop'))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' develop', + ' >> stdout', '::group::Target PullRequest Ref [change/new-topic1]', '> Closing PullRequest... [change/new-topic1]', '> Deleting reference... [refs/heads/change/new-topic1]', @@ -549,6 +539,8 @@ describe('execute', () => { }))).rejects.toThrow('There are failed processes.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', + ' >> stdout', '::group::Target PullRequest Ref [change/new-topic1]', '::endgroup::', '::group::Target PullRequest Ref [change/new-topic2]', @@ -578,6 +570,8 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', + ' >> stdout', '::group::Target PullRequest Ref [feature/new-topic3]', '::endgroup::', '::group::Target PullRequest Ref [feature/new-topic4]', @@ -608,6 +602,8 @@ describe('execute', () => { await expect(execute(octokit, getActionContext(context('', 'schedule'), {}))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', + ' >> stdout', '::group::Target PullRequest Ref [master]', '::endgroup::', '::group::Total:3 Succeeded:0 Failed:1 Skipped:2', @@ -646,13 +642,9 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', ' >> stdout', - '[command]git config \'user.name\' \'GitHub Actions\'', - ' >> stdout', - '[command]git config \'user.email\' \'example@example.com\'', - ' >> stdout', + '::group::Fetching...', '[command]git remote add origin', ' >> stdout', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-21031067:refs/remotes/origin/Hello-World/test-21031067\'', @@ -724,10 +716,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/change:refs/remotes/origin/test/change\'', '[command]git reset --hard', diff --git a/__tests__/utils/process2.test.ts b/__tests__/utils/process2.test.ts index 7b37580..0ab538a 100644 --- a/__tests__/utils/process2.test.ts +++ b/__tests__/utils/process2.test.ts @@ -113,10 +113,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -143,7 +141,6 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -201,10 +198,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -285,11 +280,9 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/test-1:refs/remotes/origin/test/test-1\'', '[command]git reset --hard', @@ -318,9 +311,6 @@ describe('execute', () => { '::endgroup::', '::group::Target PullRequest Ref [change/new-topic2]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/test-2:refs/remotes/origin/test/test-2\'', '[command]git reset --hard', @@ -395,11 +385,9 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/test-branch:refs/remotes/origin/test/test-branch\'', '[command]git reset --hard', @@ -421,7 +409,6 @@ describe('execute', () => { '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -489,11 +476,9 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', '[command]git reset --hard', @@ -505,17 +490,15 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/master', '> Running commands...', '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -561,10 +544,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test:refs/remotes/origin/test\'', '[command]git reset --hard', @@ -583,7 +564,6 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -636,10 +616,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\'', '[command]git reset --hard', @@ -653,11 +631,10 @@ describe('execute', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/feature/new-feature] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/feature/new-feature', '::endgroup::', '::group::Running commands...', @@ -666,7 +643,6 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -732,11 +708,9 @@ describe('execute', () => { }))).rejects.toThrow(); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', '[command]git reset --hard', @@ -748,17 +722,15 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/master', '> Running commands...', '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -832,11 +804,9 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [feature/new-topic3]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-branch:refs/remotes/origin/Hello-World/test-branch\'', '[command]git reset --hard', @@ -859,7 +829,6 @@ describe('execute', () => { '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -918,14 +887,10 @@ describe('execute', () => { }, 'develop'))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ - '::group::Target PullRequest Ref [change/new-topic1]', - '> Fetching...', '[command]git config --global \'init.defaultBranch\' develop', ' >> stdout', - '[command]git config \'user.name\' test-actor', - ' >> stdout', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', - ' >> stdout', + '::group::Target PullRequest Ref [change/new-topic1]', + '> Fetching...', '[command]git remote add origin', ' >> stdout', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -944,16 +909,14 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' develop', + '[command]git remote add origin', + ' >> stdout', + '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', ' >> stdout', '[command]git config \'user.name\' test-actor', ' >> stdout', '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', ' >> stdout', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', - ' >> stdout', '[command]git merge --no-edit origin/master', ' >> stdout', '> Running commands...', @@ -1013,14 +976,10 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ - '::group::Target PullRequest Ref [change/new-topic1]', - '> Fetching...', '[command]git config --global \'init.defaultBranch\' master', ' >> stdout', - '[command]git config \'user.name\' test-actor', - ' >> stdout', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', - ' >> stdout', + '::group::Target PullRequest Ref [change/new-topic1]', + '> Fetching...', '[command]git remote add origin', ' >> stdout', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -1039,16 +998,14 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', + '[command]git remote add origin', + ' >> stdout', + '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', ' >> stdout', '[command]git config \'user.name\' test-actor', ' >> stdout', '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', ' >> stdout', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', - ' >> stdout', '[command]git merge --no-edit origin/master', ' >> stdout', '> Running commands...', @@ -1119,15 +1076,13 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '::endgroup::', '::group::Target PullRequest Ref [change/new-topic2]', '::endgroup::', '::group::Target PullRequest Ref [master]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', '[command]git reset --hard', @@ -1150,7 +1105,6 @@ describe('execute', () => { '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -1206,11 +1160,9 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [feature/new-topic3]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-branch:refs/remotes/origin/Hello-World/test-branch\'', '[command]git reset --hard', @@ -1288,11 +1240,9 @@ describe('execute', () => { }))).rejects.toThrow('There are failed processes.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', '[command]git reset --hard', @@ -1304,11 +1254,10 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/master', '> Running commands...', '[command]yarn upgrade', @@ -1322,9 +1271,6 @@ describe('execute', () => { '::endgroup::', '::group::Target PullRequest Ref [master]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/change/test-0:refs/remotes/origin/change/test-0\'', '[command]git reset --hard', @@ -1398,10 +1344,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -1435,11 +1379,10 @@ describe('execute', () => { '[command]git diff \'HEAD..origin/feature/new-feature\' --name-only', '::endgroup::', '::group::Merging [origin/feature/new-feature] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\'', + '[command]git config \'user.name\' \'GitHub Actions\'', + '[command]git config \'user.email\' \'example@example.com\'', '[command]git merge --no-edit origin/feature/new-feature', ' >> Already up to date.', '::endgroup::', @@ -1493,11 +1436,9 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ + '[command]git config --global \'init.defaultBranch\' master', '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', '[command]git reset --hard', @@ -1512,11 +1453,10 @@ describe('execute', () => { ' >> Automatic merge failed; fix conflicts and then commit the result.', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'user.name\' test-actor', + '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git merge --no-edit origin/master', ' >> Auto-merging merge.txt', ' >> CONFLICT (content): Merge conflict in merge.txt', @@ -1529,20 +1469,16 @@ describe('execute', () => { '[command]git diff \'HEAD..origin/master\' --name-only', '> This PR is not mergeable.', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'user.name\' test-actor', + '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git merge --no-edit origin/master', ' >> Auto-merging merge.txt', ' >> CONFLICT (content): Merge conflict in merge.txt', ' >> Automatic merge failed; fix conflicts and then commit the result.', '> Initializing working directory...', '[command]rm -rdf [Working Directory]', - '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', '[command]git checkout -b master origin/master', @@ -1577,10 +1513,8 @@ describe('execute', () => { }))).rejects.toThrow('remote branch [test/change] not found.'); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' test-actor', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', + '::group::Fetching...', '[command]git init \'.\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/change:refs/remotes/origin/test/change\'', @@ -1621,10 +1555,8 @@ describe('execute', () => { }))).rejects.toThrow('command [git push origin test/change:refs/heads/test/change] exited with code undefined.'); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/change:refs/remotes/origin/test/change\'', '[command]git reset --hard', @@ -1643,7 +1575,6 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -1684,10 +1615,8 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', - '[command]git config \'user.name\' \'GitHub Actions\'', - '[command]git config \'user.email\' \'example@example.com\'', + '::group::Fetching...', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/change:refs/remotes/origin/test/change\'', '[command]git reset --hard', @@ -1706,7 +1635,6 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', - '[command]git config --global \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -1750,13 +1678,9 @@ describe('execute', () => { })); stdoutCalledWith(mockStdout, [ - '::group::Fetching...', '[command]git config --global \'init.defaultBranch\' master', ' >> stdout', - '[command]git config \'user.name\' \'GitHub Actions\'', - ' >> stdout', - '[command]git config \'user.email\' \'example@example.com\'', - ' >> stdout', + '::group::Fetching...', '[command]git remote add origin', ' >> stdout', '[command]git fetch --no-tags origin \'refs/heads/Hello-World/test-21031067:refs/remotes/origin/Hello-World/test-21031067\'', @@ -1869,14 +1793,10 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ - '::group::Target PullRequest Ref [change/new-topic1]', - '> Fetching...', '[command]git config --global \'init.defaultBranch\' master', ' >> stdout', - '[command]git config \'user.name\' test-actor', - ' >> stdout', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', - ' >> stdout', + '::group::Target PullRequest Ref [change/new-topic1]', + '> Fetching...', '[command]git remote add origin', ' >> stdout', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -1895,16 +1815,14 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', + '[command]git remote add origin', + ' >> stdout', + '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', ' >> stdout', '[command]git config \'user.name\' test-actor', ' >> stdout', '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', ' >> stdout', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', - ' >> stdout', '[command]git merge --no-edit origin/master', ' >> stdout', '> Running commands...', @@ -1981,14 +1899,10 @@ describe('execute', () => { }))).rejects.toThrow('There is a failed process.'); stdoutCalledWith(mockStdout, [ - '::group::Target PullRequest Ref [change/new-topic1]', - '> Fetching...', '[command]git config --global \'init.defaultBranch\' master', ' >> stdout', - '[command]git config \'user.name\' test-actor', - ' >> stdout', - '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', - ' >> stdout', + '::group::Target PullRequest Ref [change/new-topic1]', + '> Fetching...', '[command]git remote add origin', ' >> stdout', '[command]git fetch --no-tags origin \'refs/heads/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -2007,16 +1921,14 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git config --global \'init.defaultBranch\' master', + '[command]git remote add origin', + ' >> stdout', + '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', ' >> stdout', '[command]git config \'user.name\' test-actor', ' >> stdout', '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', ' >> stdout', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', - ' >> stdout', '[command]git merge --no-edit origin/master', ' >> stdout', '> Running commands...', diff --git a/src/utils/command.ts b/src/utils/command.ts index 56bd7d1..62170e3 100644 --- a/src/utils/command.ts +++ b/src/utils/command.ts @@ -33,13 +33,18 @@ const {getRepository, isPush} = ContextHelper; export const getApiHelper = (octokit: Octokit, context: ActionContext, logger?: Logger): ApiHelper => new ApiHelper(octokit, context.actionContext, logger); -export const config = async(helper: GitHelper, logger: Logger, octokit: Octokit, context: ActionContext): Promise => await helper.config(getWorkspace(), getCommitName(context), getCommitEmail(context), await getDefaultBranch(octokit, context)); +export const userConfig = async(helper: GitHelper, context: ActionContext): Promise => await helper.config(getWorkspace(), { + name: getCommitName(context), + email: getCommitEmail(context), +}); +export const branchConfig = async(helper: GitHelper, octokit: Octokit, context: ActionContext): Promise => await helper.config(getWorkspace(), { + defaultBranch: await getDefaultBranch(octokit, context), +}); export const clone = async(helper: GitHelper, logger: Logger, octokit: Octokit, context: ActionContext): Promise => { const branchName = await getPrBranchName(helper, octokit, context); logger.startProcess('Fetching...'); helper.useOrigin(true); - await config(helper, logger, octokit, context); await helper.fetchOrigin(getWorkspace(), context.actionContext, ['--no-tags'], [getRefspec(branchName)]); await helper.runCommand(getWorkspace(), { @@ -167,10 +172,10 @@ const initDirectory = async(helper: GitHelper, logger: Logger): Promise => await helper.runCommand(getWorkspace(), {command: 'rm', args: ['-rdf', getWorkspace()]}); }; -export const merge = async(branch: string, helper: GitHelper, logger: Logger, octokit: Octokit, context: ActionContext): Promise => { +export const merge = async(branch: string, helper: GitHelper, logger: Logger, context: ActionContext): Promise => { logger.startProcess('Merging [%s] branch...', getLocalRefspec(branch)); - await config(helper, logger, octokit, context); await helper.fetchOrigin(getWorkspace(), context.actionContext, ['--no-tags'], [getRefspec(branch)]); + await userConfig(helper, context); const results = await helper.runCommand(getWorkspace(), { command: 'git merge', @@ -187,8 +192,8 @@ export const abortMerge = async(helper: GitHelper, logger: Logger): Promise => { - await config(helper, logger, octokit, context); +export const commit = async(helper: GitHelper, logger: Logger, context: ActionContext): Promise => { + await userConfig(helper, context); logger.startProcess('Committing...'); await helper.makeCommit(getWorkspace(), getCommitMessage(context)); @@ -331,7 +336,7 @@ export const getChangedFiles = async(helper: GitHelper, logger: Logger, octokit: }> => { await clone(helper, logger, octokit, context); if (await checkBranch(helper, logger, octokit, context)) { - if (!await merge(getContextBranch(context), helper, logger, octokit, context)) { + if (!await merge(getContextBranch(context), helper, logger, context)) { await abortMerge(helper, logger); return {files: [], output: [], aborted: true}; } @@ -347,7 +352,6 @@ export const getChangedFilesForRebase = async(helper: GitHelper, logger: Logger, await initDirectory(helper, logger); const branchName = getContextBranch(context); - await config(helper, logger, octokit, context); await helper.fetchOrigin(getWorkspace(), context.actionContext, ['--no-tags'], [getRefspec(branchName)]); await helper.switchBranch(getWorkspace(), branchName); await helper.createBranch(getWorkspace(), await getPrBranchName(helper, octokit, context)); @@ -358,7 +362,7 @@ export const getChangedFilesForRebase = async(helper: GitHelper, logger: Logger, export const closePR = async(branchName: string, logger: Logger, context: ActionContext, message?: string): Promise => getApiHelper(getOctokit(getApiToken()), context, logger).closePR(branchName, message ?? context.actionDetail.prCloseMessage); export const resolveConflicts = async(branchName: string, helper: GitHelper, logger: Logger, octokit: Octokit, context: ActionContext): Promise => { - if (await merge(getContextBranch(context), helper, logger, octokit, context)) { + if (await merge(getContextBranch(context), helper, logger, context)) { // succeeded to merge await push(branchName, helper, logger, context); } else { @@ -368,7 +372,7 @@ export const resolveConflicts = async(branchName: string, helper: GitHelper, log await closePR(branchName, logger, context); return 'has been closed because there is no diff'; } - await commit(helper, logger, octokit, context); + await commit(helper, logger, context); await forcePush(branchName, helper, logger, context); await getApiHelper(getOctokit(getApiToken()), context, logger).pullsCreateOrUpdate(branchName, { title: await getPrTitle(helper, octokit, context), diff --git a/src/utils/process.ts b/src/utils/process.ts index 79c40a0..7df2185 100644 --- a/src/utils/process.ts +++ b/src/utils/process.ts @@ -15,6 +15,7 @@ import { resolveConflicts, findPR, getDefaultBranch, + branchConfig, } from './command'; import { replaceDirectory, @@ -152,7 +153,7 @@ const createCommit = async(addComment: boolean, isClose: boolean, logger: Logger return getResult('not changed', 'There is no diff', context); } - await commit(helper, logger, octokit, context); + await commit(helper, logger, context); if (context.isBatchProcess) { if (!(await getRefDiff(getPrBaseRef(context), helper, logger, context)).length) { // Close if there is no diff @@ -217,7 +218,7 @@ const noDiffProcess = async(branchName: string, isClose: boolean, logger: Logger const diffProcess = async(files: string[], output: CommandOutput[], branchName: string, isClose: boolean, logger: Logger, helper: GitHelper, octokit: Octokit, context: ActionContext): Promise<{ mergeable: boolean; result?: ProcessResult }> => { // Commit local diffs - await commit(helper, logger, octokit, context); + await commit(helper, logger, context); if (!(await getRefDiff(getPrHeadRef(context), helper, logger, context)).length) { // Close if there is no diff await closePR(branchName, logger, context); @@ -393,6 +394,7 @@ const runCreatePrAll = async(octokit: Octokit, context: ActionContext): Promise< const runCreatePrClosed = async(octokit: Octokit, context: ActionContext): Promise => runCreatePr(true, getPulls, octokit, context); export const execute = async(octokit: Octokit, context: ActionContext): Promise => { + await branchConfig(getHelper(context), octokit, context); if (isClosePR(context)) { await runCreatePrClosed(octokit, context); } else if (isPush(context.actionContext)) { From 4fa0f11d31e41d9294471da5ac322d10046fbb29 Mon Sep 17 00:00:00 2001 From: Technote Date: Mon, 8 Feb 2021 01:12:32 +0900 Subject: [PATCH 3/3] feat: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5f7116..1c3d08c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/github-action-pr-helper", - "version": "2.2.1", + "version": "2.2.2", "description": "PullRequest Helper for GitHub Actions.", "keywords": [ "github",