Skip to content

release: v4.4.0 #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions __tests__/git-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('GitHelper', () => {
}));

execCalledWith(mockExec, [
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' || :',
]);
});

Expand All @@ -87,7 +87,7 @@ describe('GitHelper', () => {
}));

execCalledWith(mockExec, [
'git clone \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' > /dev/null 2>&1 || :',
'git clone \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' || :',
'git fetch \'https://octocat:[email protected]/hello/world.git\' \'+refs/pull/123/merge\' > /dev/null 2>&1',
'git checkout -qf FETCH_HEAD',
]);
Expand All @@ -104,7 +104,7 @@ describe('GitHelper', () => {

execCalledWith(mockExec, [
'git init \'.\'',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
'git fetch --no-tags origin \'refs/tags/v1.2.3:refs/tags/v1.2.3\' || :',
'git checkout -qf 1234567890',
]);
Expand All @@ -118,7 +118,7 @@ describe('GitHelper', () => {
await helper.checkout(workDir, context());

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
'git fetch --no-tags origin \'refs/heads/test-ref:refs/remotes/origin/test-ref\' || :',
'git checkout -qf test-sha',
]);
Expand All @@ -130,7 +130,7 @@ describe('GitHelper', () => {
await helper.checkout(workDir, context({ref: 'refs/pull/123/merge'}));

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
'git fetch --no-tags origin \'refs/pull/123/merge:refs/remotes/origin/pull/123/merge\' || :',
'git checkout -qf test-sha',
]);
Expand All @@ -142,7 +142,7 @@ describe('GitHelper', () => {
await helper.checkout(workDir, context({ref: 'refs/tags/v1.2.3'}));

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
'git fetch --no-tags origin \'refs/tags/v1.2.3:refs/tags/v1.2.3\' || :',
'git checkout -qf test-sha',
]);
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('GitHelper', () => {
await helper.addOrigin(workDir, context());

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
]);
});

Expand All @@ -195,7 +195,7 @@ describe('GitHelper', () => {
execCalledWith(mockExec, [
`rm -rdf '${workDir}'`,
'git init \'.\'',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
]);
});
});
Expand All @@ -207,7 +207,7 @@ describe('GitHelper', () => {
await helper.fetchOrigin(workDir, context());

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
'git fetch origin || :',
]);
});
Expand All @@ -218,7 +218,7 @@ describe('GitHelper', () => {
await helper.fetchOrigin(workDir, context(), ['--no-tags']);

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
'git fetch --no-tags origin || :',
]);
});
Expand All @@ -229,7 +229,7 @@ describe('GitHelper', () => {
await helper.fetchOrigin(workDir, context(), undefined, ['+refs/pull/*/merge:refs/remotes/pull/*/merge', '+refs/heads/hoge:refs/remotes/origin/hoge']);

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
'git fetch origin \'+refs/pull/*/merge:refs/remotes/pull/*/merge\' \'+refs/heads/hoge:refs/remotes/origin/hoge\' || :',
]);
});
Expand All @@ -242,7 +242,7 @@ describe('GitHelper', () => {
await helper.fetchBranch(workDir, 'test-branch', context());

execCalledWith(mockExec, [
'git fetch --prune --no-recurse-submodules \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'+refs/heads/test-branch:refs/remotes/origin/test-branch\' > /dev/null 2>&1 || :',
'git fetch --prune --no-tags --no-recurse-submodules \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'+refs/heads/test-branch:refs/remotes/origin/test-branch\' || :',
]);
});
});
Expand Down Expand Up @@ -530,7 +530,7 @@ describe('GitHelper', () => {
await helper.deleteTag(workDir, 'delete-tag', context());

execCalledWith(mockExec, [
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag > /dev/null 2>&1 || :',
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag || :',
'git tag -d delete-tag || :',
]);
});
Expand All @@ -544,7 +544,7 @@ describe('GitHelper', () => {
], context());

execCalledWith(mockExec, [
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag1 tags/delete-tag2 > /dev/null 2>&1 || :',
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag1 tags/delete-tag2 || :',
'git tag -d delete-tag1 delete-tag2 || :',
]);
});
Expand All @@ -561,8 +561,8 @@ describe('GitHelper', () => {
], context(), 3);

execCalledWith(mockExec, [
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag1 tags/delete-tag2 tags/delete-tag3 > /dev/null 2>&1 || :',
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag4 refs/tags/delete-tag5 > /dev/null 2>&1 || :',
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag1 tags/delete-tag2 tags/delete-tag3 || :',
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/delete-tag4 refs/tags/delete-tag5 || :',
'git tag -d delete-tag1 delete-tag2 delete-tag3 || :',
'git tag -d delete-tag4 delete-tag5 || :',
]);
Expand All @@ -576,10 +576,10 @@ describe('GitHelper', () => {
await helper.copyTag(workDir, 'new-tag', 'from-tag', context());

execCalledWith(mockExec, [
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/new-tag > /dev/null 2>&1 || :',
'git push \'https://octocat:[email protected]/hello/world.git\' --delete tags/new-tag || :',
'git tag -d new-tag || :',
'git tag new-tag from-tag',
'git push \'https://octocat:[email protected]/hello/world.git\' refs/tags/new-tag > /dev/null 2>&1',
'git push \'https://octocat:[email protected]/hello/world.git\' refs/tags/new-tag',
]);
});
});
Expand Down Expand Up @@ -653,7 +653,7 @@ describe('GitHelper', () => {
await helper.push(workDir, 'test-branch', context(), {withTag: true, args: ['--prune', '--verbose']});

execCalledWith(mockExec, [
'git push --tags --prune --verbose \'https://octocat:[email protected]/hello/world.git\' \'test-branch:refs/heads/test-branch\' > /dev/null 2>&1 || :',
'git push --tags --prune --verbose \'https://octocat:[email protected]/hello/world.git\' \'test-branch:refs/heads/test-branch\' || :',
]);
});

Expand All @@ -663,7 +663,7 @@ describe('GitHelper', () => {
await helper.push(workDir, 'test-branch', context());

execCalledWith(mockExec, [
'git push \'https://octocat:[email protected]/hello/world.git\' \'test-branch:refs/heads/test-branch\' > /dev/null 2>&1 || :',
'git push \'https://octocat:[email protected]/hello/world.git\' \'test-branch:refs/heads/test-branch\' || :',
]);
});
});
Expand All @@ -675,7 +675,7 @@ describe('GitHelper', () => {
await helper.forcePush(workDir, 'test-branch', context());

execCalledWith(mockExec, [
'git push --force \'https://octocat:[email protected]/hello/world.git\' \'test-branch:refs/heads/test-branch\' > /dev/null 2>&1 || :',
'git push --force \'https://octocat:[email protected]/hello/world.git\' \'test-branch:refs/heads/test-branch\' || :',
]);
});
});
Expand Down Expand Up @@ -813,19 +813,19 @@ describe('GitHelper', () => {
await helper.switchBranch(workDir, 'abc');

execCalledWith(mockExec, [
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' || :',
'git checkout -b abc origin/abc || :',
'git checkout abc || :',
'git clone \'--branch=test\' \'--depth=3\' origin \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'--depth=3\' origin \'.\' || :',
'git checkout -b abc origin/abc || :',
'git checkout abc || :',
'git clone \'--branch=test\' \'--depth=3\' test \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'--depth=3\' test \'.\' || :',
'git checkout -b abc test/abc || :',
'git checkout abc || :',
'git clone \'--branch=test\' \'--depth=3\' origin \'.\' || :',
'git checkout -b abc origin/abc || :',
'git checkout abc || :',
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' || :',
'git checkout -b abc origin/abc || :',
'git checkout abc || :',
]);
Expand All @@ -849,7 +849,7 @@ describe('GitHelper with params 1', () => {
}));

execCalledWith(mockExec, [
'git clone \'--branch=test\' \'--depth=1\' \'https://octocat:[email protected]/hello/world.git\' \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'--depth=1\' \'https://octocat:[email protected]/hello/world.git\' \'.\' || :',
]);
});
});
Expand Down Expand Up @@ -880,7 +880,7 @@ describe('GitHelper with params 2', () => {
}));

execCalledWith(mockExec, [
'git clone \'--branch=test\' \'https://octocat:[email protected]/hello/world.git\' \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'https://octocat:[email protected]/hello/world.git\' \'.\' || :',
]);
});
});
Expand All @@ -902,7 +902,7 @@ describe('GitHelper without params', () => {
}));

execCalledWith(mockExec, [
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' > /dev/null 2>&1 || :',
'git clone \'--branch=test\' \'--depth=3\' \'https://octocat:[email protected]/hello/world.git\' \'.\' || :',
]);
});
});
Expand All @@ -926,7 +926,7 @@ describe('Debug', () => {
await expect(helper.addOrigin(workDir, context())).rejects.toThrow('command [git remote add origin] exited with code 123.');

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1 || :',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' || :',
]);
stdoutCalledWith(mockStdout, [
'[command]git remote add origin',
Expand All @@ -948,7 +948,7 @@ describe('Debug', () => {
await expect(helper.addOrigin(workDir, context())).rejects.toThrow('command [git remote add origin] exited with code 123.');

execCalledWith(mockExec, [
'git remote add origin \'https://octocat:[email protected]/hello/world.git\' > /dev/null 2>&1',
'git remote add origin \'https://octocat:[email protected]/hello/world.git\'',
]);
stdoutCalledWith(mockStdout, [
'[command]git remote add origin',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@technote-space/github-action-helper",
"version": "4.3.2",
"version": "4.4.0",
"description": "Helper for GitHub Action.",
"keywords": [
"github",
Expand Down
16 changes: 8 additions & 8 deletions src/git-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default class GitHelper {
await this.runCommand(workDir, {
command: 'git remote add',
args: [this.getRemoteName(), getGitUrlWithToken(context, this.token)],
quiet: this.isQuiet(),
stderrToStdout: this.isQuiet(),
altCommand: `git remote add ${this.getRemoteName()}`,
suppressError: this.shouldSuppressError(),
});
Expand Down Expand Up @@ -189,7 +189,7 @@ export default class GitHelper {
await this.runCommand(workDir, {
command: 'git clone',
args: [`--branch=${branch}`, this.cloneDepth, this.getRemote(context), '.'],
quiet: this.isQuiet(),
stderrToStdout: this.isQuiet(),
altCommand: `git clone --branch=${branch}`,
suppressError: this.shouldSuppressError(),
});
Expand All @@ -205,7 +205,7 @@ export default class GitHelper {
{
command: 'git clone',
args: [this.cloneDepth, this.getRemote(context), '.'],
quiet: this.isQuiet(),
stderrToStdout: this.isQuiet(),
altCommand: 'git clone',
suppressError: this.shouldSuppressError(),
},
Expand Down Expand Up @@ -299,8 +299,8 @@ export default class GitHelper {
const branchName = getBranch(branch, false);
await this.runCommand(workDir, {
command: 'git fetch',
args: ['--prune', '--no-recurse-submodules', this.cloneDepth, this.getRemote(context), `+refs/heads/${branchName}:refs/remotes/${this.getRemoteName()}/${branchName}`],
quiet: this.isQuiet(),
args: ['--prune', '--no-tags', '--no-recurse-submodules', this.cloneDepth, this.getRemote(context), `+refs/heads/${branchName}:refs/remotes/${this.getRemoteName()}/${branchName}`],
stderrToStdout: this.isQuiet(),
altCommand: `git fetch --prune --no-recurse-submodules${this.cloneDepth} ${this.getRemoteName()} +refs/heads/${branchName}:refs/remotes/${this.getRemoteName()}/${branchName}`,
suppressError: this.shouldSuppressError(),
});
Expand Down Expand Up @@ -476,7 +476,7 @@ export default class GitHelper {
arrayChunk((typeof tags === 'string' ? [tags] : tags).map(getTagRef), splitSize).map(tags => ({
command: 'git push',
args: [this.getRemote(context), '--delete', ...tags],
quiet: this.isQuiet(),
stderrToStdout: this.isQuiet(),
altCommand: `git push ${this.getRemoteName()} --delete ${tags.join(' ')}`,
suppressError: this.shouldSuppressError(),
})),
Expand All @@ -501,7 +501,7 @@ export default class GitHelper {
{
command: 'git push',
args: [this.getRemote(context), `refs/tags/${newTag}`],
quiet: this.isQuiet(),
stderrToStdout: this.isQuiet(),
altCommand: `git push ${this.getRemoteName()} refs/tags/${newTag}`,
},
]);
Expand Down Expand Up @@ -561,7 +561,7 @@ export default class GitHelper {
await this.runCommand(workDir, {
command: 'git push',
args: args.concat([this.getRemote(context), `${branch}:refs/heads/${branch}`]),
quiet: this.isQuiet(),
stderrToStdout: this.isQuiet(),
altCommand: `git push ${args.concat([this.getRemoteName(), `${branch}:refs/heads/${branch}`]).join(' ')}`,
suppressError: this.shouldSuppressError(),
});
Expand Down