From fb668e468abceefcf576dc27a4e5284381ec0215 Mon Sep 17 00:00:00 2001 From: Technote Date: Sun, 7 Feb 2021 23:38:24 +0900 Subject: [PATCH 1/3] chore: update packages --- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 199dafa..d5b83f4 100644 --- a/package.json +++ b/package.json @@ -38,13 +38,13 @@ "@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.0.0", + "@technote-space/github-action-helper": "^5.1.0", "moment": "^2.29.1" }, "devDependencies": { "@commitlint/cli": "^11.0.0", "@commitlint/config-conventional": "^11.0.0", - "@technote-space/github-action-test-helper": "^0.6.13", + "@technote-space/github-action-test-helper": "^0.7.1", "@types/jest": "^26.0.20", "@types/node": "^14.14.25", "@typescript-eslint/eslint-plugin": "^4.14.2", diff --git a/yarn.lock b/yarn.lock index 0f5e27d..b39eef2 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.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@technote-space/github-action-helper/-/github-action-helper-5.0.0.tgz#dcd1be20c1295a16ac34d6b5751f12a659613963" - integrity sha512-+4KqG6z596vIyDr41Jt48ORur0ZM7gblwYRSQd9nLbNXaU6JRsoHRJ07WiULg6UILpH9LeVghSlnj7cllM4npw== +"@technote-space/github-action-helper@^5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@technote-space/github-action-helper/-/github-action-helper-5.1.0.tgz#165eb548dae7b51263351c50cde3fdedaf0b0f40" + integrity sha512-E4GBqEkCGNrZTMuUMfYVNoE3Oy8VD6V1FmlYhpZ1Pim4eeVIZ9XoC064cpfYx+SsQFUJlItmGTB9lR9u3buTnA== dependencies: "@actions/core" "^1.2.6" "@actions/github" "^4.0.0" @@ -798,10 +798,10 @@ "@actions/core" "^1.2.6" sprintf-js "^1.1.2" -"@technote-space/github-action-test-helper@^0.6.13": - version "0.6.13" - resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.6.13.tgz#258905379835157c64c3ee4062152d246ee0342b" - integrity sha512-IrxOQ4hpqHb3dQDJUXEyZSbOzbFATZi9cWugtBCng6gPXJP2fx11GLJjXAf+/lVyV5PwyEVec8uZxk0jWnG11g== +"@technote-space/github-action-test-helper@^0.7.1": + version "0.7.1" + resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.7.1.tgz#83a9376294b97729753e20bb38449abb24d8276e" + integrity sha512-cqPUIiuvduiz6vzF95iT+GlzQmAfMpPIDnIMNpAyFd5Wb4z/k3sRpE7F3VkMUQRqQdRKa5KH7wgLmgcuDlE0rg== dependencies: "@actions/core" "^1.2.6" "@actions/github" "^4.0.0" From d13ad7ccdb07f8c6fde7f49d7fd4bf8a9708616e Mon Sep 17 00:00:00 2001 From: Technote Date: Sun, 7 Feb 2021 23:41:20 +0900 Subject: [PATCH 2/3] feat: update config setting to suppress warning --- __tests__/utils/command.test.ts | 57 ++++++++--- __tests__/utils/process1.test.ts | 36 ++++++- __tests__/utils/process2.test.ts | 167 ++++++++++++++++++++++++++----- src/utils/command.ts | 20 ++-- src/utils/process.ts | 4 +- 5 files changed, 231 insertions(+), 53 deletions(-) diff --git a/__tests__/utils/command.test.ts b/__tests__/utils/command.test.ts index 255c799..68318bf 100644 --- a/__tests__/utils/command.test.ts +++ b/__tests__/utils/command.test.ts @@ -100,9 +100,14 @@ describe('clone', () => { }, }), { prBranchName: 'test-branch', + commitName: 'GitHub Actions', + commitEmail: 'example@example.com', })); execCalledWith(mockExec, [ + 'git config \'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\' || :', @@ -112,6 +117,12 @@ describe('clone', () => { ]); stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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', @@ -350,6 +361,9 @@ describe('getChangedFiles', () => { }); stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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', @@ -366,10 +380,11 @@ describe('getChangedFiles', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/hello-world/test-branch] branch...', - '[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 \'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 merge --no-edit origin/hello-world/test-branch', ' >> Auto-merging merge.txt', ' >> CONFLICT (content): Merge conflict in merge.txt', @@ -426,6 +441,9 @@ describe('getChangedFiles', () => { }); stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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', @@ -440,10 +458,11 @@ describe('getChangedFiles', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/hello-world/test-branch] branch...', - '[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 \'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 merge --no-edit origin/hello-world/test-branch', ' >> Already up to date.', '::endgroup::', @@ -540,6 +559,9 @@ describe('getChangedFiles', () => { }); stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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', @@ -554,10 +576,11 @@ describe('getChangedFiles', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/hello-world/test-branch] branch...', - '[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 \'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 merge --no-edit origin/hello-world/test-branch', ' >> Already up to date.', '::endgroup::', @@ -811,11 +834,12 @@ describe('resolveConflicts', () => { })); execCalledWith(mockExec, [ + 'git config \'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\'', ]); @@ -846,13 +870,17 @@ describe('resolveConflicts', () => { })); execCalledWith(mockExec, [ + 'git config \'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 || :', `rm -rdf ${workDir}`, + 'git config \'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\' || :', @@ -900,13 +928,17 @@ describe('resolveConflicts', () => { })); execCalledWith(mockExec, [ + 'git config \'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 || :', `rm -rdf ${workDir}`, + 'git config \'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\' || :', @@ -916,6 +948,7 @@ describe('resolveConflicts', () => { 'yarn upgrade', 'git add --all', 'git status --short -uno', + 'git config \'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 e451b84..e04dc4f 100644 --- a/__tests__/utils/process1.test.ts +++ b/__tests__/utils/process1.test.ts @@ -115,6 +115,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -126,10 +129,11 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'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 merge --no-edit origin/master', '> Running commands...', '> Checking diff...', @@ -195,6 +199,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -221,6 +228,7 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -276,6 +284,12 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'init.defaultBranch\' master', + ' >> stdout', + '[command]git config \'user.name\' \'GitHub Actions\'', + ' >> stdout', + '[command]git config \'user.email\' \'example@example.com\'', + ' >> stdout', '[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\'', @@ -425,6 +439,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -436,15 +453,17 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'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 merge --no-edit origin/master', '> Running commands...', '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -628,6 +647,12 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'init.defaultBranch\' master', + ' >> stdout', + '[command]git config \'user.name\' \'GitHub Actions\'', + ' >> stdout', + '[command]git config \'user.email\' \'example@example.com\'', + ' >> stdout', '[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\'', @@ -700,6 +725,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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/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 6efe844..783d5ac 100644 --- a/__tests__/utils/process2.test.ts +++ b/__tests__/utils/process2.test.ts @@ -114,6 +114,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -140,6 +143,7 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -198,6 +202,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -280,6 +287,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -308,6 +318,9 @@ describe('execute', () => { '::endgroup::', '::group::Target PullRequest Ref [change/new-topic2]', '> Fetching...', + '[command]git config \'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', @@ -384,6 +397,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -405,6 +421,7 @@ describe('execute', () => { '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -474,6 +491,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -485,15 +505,17 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'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 merge --no-edit origin/master', '> Running commands...', '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -540,6 +562,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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:refs/remotes/origin/test\'', '[command]git reset --hard', @@ -558,6 +583,7 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -611,6 +637,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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 reset --hard', @@ -624,10 +653,11 @@ describe('execute', () => { '[command]ls -la', '::endgroup::', '::group::Merging [origin/feature/new-feature] branch...', - '[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 \'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 merge --no-edit origin/feature/new-feature', '::endgroup::', '::group::Running commands...', @@ -636,6 +666,7 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -703,6 +734,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -714,15 +748,17 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'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 merge --no-edit origin/master', '> Running commands...', '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -798,6 +834,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [feature/new-topic3]', '> Fetching...', + '[command]git config \'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', @@ -820,6 +859,7 @@ describe('execute', () => { '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -880,6 +920,12 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'init.defaultBranch\' develop', + ' >> 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/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -898,14 +944,16 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'init.defaultBranch\' develop', ' >> 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...', @@ -967,6 +1015,12 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'init.defaultBranch\' 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/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -985,14 +1039,16 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'init.defaultBranch\' 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...', @@ -1069,6 +1125,9 @@ describe('execute', () => { '::endgroup::', '::group::Target PullRequest Ref [master]', '> Fetching...', + '[command]git config \'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', @@ -1091,6 +1150,7 @@ describe('execute', () => { '> Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '> Committing...', @@ -1148,6 +1208,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [feature/new-topic3]', '> Fetching...', + '[command]git config \'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', @@ -1227,6 +1290,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -1238,10 +1304,11 @@ describe('execute', () => { '[command]git merge --no-edit origin/change/new-topic1', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'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 merge --no-edit origin/master', '> Running commands...', '[command]yarn upgrade', @@ -1255,6 +1322,9 @@ describe('execute', () => { '::endgroup::', '::group::Target PullRequest Ref [master]', '> Fetching...', + '[command]git config \'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', @@ -1329,6 +1399,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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-21031067:refs/remotes/origin/Hello-World/test-21031067\'', '[command]git reset --hard', @@ -1362,10 +1435,11 @@ describe('execute', () => { '[command]git diff \'HEAD..origin/feature/new-feature\' --name-only', '::endgroup::', '::group::Merging [origin/feature/new-feature] branch...', - '[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 \'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 merge --no-edit origin/feature/new-feature', ' >> Already up to date.', '::endgroup::', @@ -1421,6 +1495,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'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', @@ -1435,10 +1512,11 @@ describe('execute', () => { ' >> Automatic merge failed; fix conflicts and then commit the result.', '[command]ls -la', '> Merging [origin/master] branch...', - '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'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 merge --no-edit origin/master', ' >> Auto-merging merge.txt', ' >> CONFLICT (content): Merge conflict in merge.txt', @@ -1451,16 +1529,20 @@ describe('execute', () => { '[command]git diff \'HEAD..origin/master\' --name-only', '> This PR is not mergeable.', '> Merging [origin/master] branch...', - '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'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 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 \'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', @@ -1496,6 +1578,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'init.defaultBranch\' master', + '[command]git config \'user.name\' test-actor', + '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'', '[command]git init \'.\'', '[command]git remote add origin', '[command]git fetch --no-tags origin \'refs/heads/test/change:refs/remotes/origin/test/change\'', @@ -1537,6 +1622,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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/change:refs/remotes/origin/test/change\'', '[command]git reset --hard', @@ -1555,6 +1643,7 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -1596,6 +1685,9 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'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/change:refs/remotes/origin/test/change\'', '[command]git reset --hard', @@ -1614,6 +1706,7 @@ describe('execute', () => { '::group::Checking diff...', '[command]git add --all', '[command]git status --short -uno', + '[command]git config \'init.defaultBranch\' master', '[command]git config \'user.name\' \'GitHub Actions\'', '[command]git config \'user.email\' \'example@example.com\'', '::endgroup::', @@ -1658,6 +1751,12 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Fetching...', + '[command]git config \'init.defaultBranch\' master', + ' >> stdout', + '[command]git config \'user.name\' \'GitHub Actions\'', + ' >> stdout', + '[command]git config \'user.email\' \'example@example.com\'', + ' >> stdout', '[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\'', @@ -1772,6 +1871,12 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'init.defaultBranch\' 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/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -1790,14 +1895,16 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'init.defaultBranch\' 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...', @@ -1876,6 +1983,12 @@ describe('execute', () => { stdoutCalledWith(mockStdout, [ '::group::Target PullRequest Ref [change/new-topic1]', '> Fetching...', + '[command]git config \'init.defaultBranch\' 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/change/new-topic1:refs/remotes/origin/change/new-topic1\'', @@ -1894,14 +2007,16 @@ describe('execute', () => { '[command]ls -la', ' >> stdout', '> Merging [origin/master] branch...', - '[command]git remote add origin', - ' >> stdout', - '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'', + '[command]git config \'init.defaultBranch\' 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 9e79b3b..56bd7d1 100644 --- a/src/utils/command.ts +++ b/src/utils/command.ts @@ -33,10 +33,13 @@ 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 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(), { @@ -164,12 +167,10 @@ const initDirectory = async(helper: GitHelper, logger: Logger): Promise => await helper.runCommand(getWorkspace(), {command: 'rm', args: ['-rdf', getWorkspace()]}); }; -export const config = async(helper: GitHelper, logger: Logger, context: ActionContext): Promise => await helper.config(getWorkspace(), getCommitName(context), getCommitEmail(context)); - -export const merge = async(branch: string, helper: GitHelper, logger: Logger, context: ActionContext): Promise => { +export const merge = async(branch: string, helper: GitHelper, logger: Logger, octokit: Octokit, 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 config(helper, logger, context); const results = await helper.runCommand(getWorkspace(), { command: 'git merge', @@ -186,8 +187,8 @@ export const abortMerge = async(helper: GitHelper, logger: Logger): Promise => { - await config(helper, logger, context); +export const commit = async(helper: GitHelper, logger: Logger, octokit: Octokit, context: ActionContext): Promise => { + await config(helper, logger, octokit, context); logger.startProcess('Committing...'); await helper.makeCommit(getWorkspace(), getCommitMessage(context)); @@ -330,7 +331,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, context)) { + if (!await merge(getContextBranch(context), helper, logger, octokit, context)) { await abortMerge(helper, logger); return {files: [], output: [], aborted: true}; } @@ -346,6 +347,7 @@ 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)); @@ -356,7 +358,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, context)) { + if (await merge(getContextBranch(context), helper, logger, octokit, context)) { // succeeded to merge await push(branchName, helper, logger, context); } else { @@ -366,7 +368,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, context); + await commit(helper, logger, octokit, 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 2c9683c..79c40a0 100644 --- a/src/utils/process.ts +++ b/src/utils/process.ts @@ -152,7 +152,7 @@ const createCommit = async(addComment: boolean, isClose: boolean, logger: Logger return getResult('not changed', 'There is no diff', context); } - await commit(helper, logger, context); + await commit(helper, logger, octokit, context); if (context.isBatchProcess) { if (!(await getRefDiff(getPrBaseRef(context), helper, logger, context)).length) { // Close if there is no diff @@ -217,7 +217,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, context); + await commit(helper, logger, octokit, context); if (!(await getRefDiff(getPrHeadRef(context), helper, logger, context)).length) { // Close if there is no diff await closePR(branchName, logger, context); From 163c5a5d42593b2e67330a5464126fe63af5fb9e Mon Sep 17 00:00:00 2001 From: Technote Date: Sun, 7 Feb 2021 23:42:54 +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 d5b83f4..4073d78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/github-action-pr-helper", - "version": "2.1.9", + "version": "2.2.0", "description": "PullRequest Helper for GitHub Actions.", "keywords": [ "github",