Skip to content

Commit

Permalink
fix(prepare): clean up remote origin-with-token after git push (#479)
Browse files Browse the repository at this point in the history
* fix(prepare): clean up remote `origin-with-token` after git push

* fix: update test snapshot
  • Loading branch information
Eunjae Lee authored Dec 1, 2019
1 parent 51e5ab2 commit c81d247
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/shipjs/src/helper/__tests__/gitPush.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('gitPush', () => {
" $ git remote add origin-with-token https://xxx@github.com/my/repo",
]
`);
expect(run).toHaveBeenCalledTimes(3);
expect(run).toHaveBeenCalledTimes(4);
expect(run.mock.calls[0][0]).toMatchInlineSnapshot(`
Object {
"command": "git remote add origin-with-token https://abcdef@github.com/my/repo",
Expand All @@ -59,6 +59,14 @@ describe('gitPush', () => {
"dryRun": false,
}
`);
expect(run.mock.calls[3][0]).toMatchInlineSnapshot(`
Object {
"command": "git remote remove origin-with-token",
"dir": ".",
"dryRun": false,
"printCommand": false,
}
`);
});

it('works without token', () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/shipjs/src/helper/gitPush.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export default function gitPush({ remote, refs, dir, dryRun }) {
refs.forEach(ref => {
run({ command: `git push origin-with-token ${ref}`, dir, dryRun });
});
run({
command: `git remote remove origin-with-token`,
dir,
dryRun,
printCommand: false,
});
} else {
refs.forEach(ref => {
run({
Expand Down

0 comments on commit c81d247

Please sign in to comment.