Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion packages/shipjs/src/flow/release.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadConfig } from 'shipjs-lib';
import { getCurrentBranch, loadConfig } from 'shipjs-lib';

import printHelp from '../step/release/printHelp';
import printDryRunBanner from '../step/printDryRunBanner';
Expand All @@ -15,6 +15,7 @@ import createGitHubRelease from '../step/release/createGitHubRelease';
import notifyReleaseSuccess from '../step/release/notifyReleaseSuccess';
import checkGitHubToken from '../step/checkGitHubToken';
import finished from '../step/release/finished';
import pull from '../step/pull';
import { detectYarn } from '../util';

async function release({ help = false, dir = '.', dryRun = false }) {
Expand Down Expand Up @@ -43,6 +44,8 @@ async function release({ help = false, dir = '.', dryRun = false }) {
runPublish({ isYarn, config, releaseTag, dir, dryRun });
await runAfterPublish({ version, releaseTag, config, dir, dryRun });
const { tagName } = createGitTag({ version, config, dir, dryRun });
const currentBranch = getCurrentBranch(dir);
pull({ remote, currentBranch, dir, dryRun, rebase: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated to pass options instead, no?

gitPush({ tagName, config, dir, dryRun });
await createGitHubRelease({ version, config, dir, dryRun });
await notifyReleaseSuccess({
Expand Down
27 changes: 27 additions & 0 deletions packages/shipjs/src/step/__tests__/pull.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { run } from '../../util';
import pull from '../pull';

const remote = 'origin-with-token';
const currentBranch = 'main';

describe('pull', () => {
it('works', () => {
pull({ remote, currentBranch, dir: '.', dryRun: false });
expect(run).toHaveBeenCalledTimes(1);
expect(run).toHaveBeenCalledWith({
command: 'git pull origin-with-token main',
dir: '.',
dryRun: false,
});
});

it('works with rebase flag', () => {
pull({ remote, currentBranch, dir: '.', dryRun: false, rebase: true });
expect(run).toHaveBeenCalledTimes(1);
expect(run).toHaveBeenCalledWith({
command: 'git pull --rebase origin-with-token main',
dir: '.',
dryRun: false,
});
});
});
10 changes: 8 additions & 2 deletions packages/shipjs/src/step/pull.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import runStep from './runStep';
import { run } from '../util';

export default ({ remote, currentBranch, dir, dryRun }) =>
export default ({ remote, currentBranch, dir, dryRun, rebase = false }) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or allow more flexibility and pass any flag?

runStep({ title: 'Updating from remote.' }, () => {
run({ command: `git pull ${remote} ${currentBranch}`, dir, dryRun });
run({
command: `git pull${
rebase ? ' --rebase' : ''
} ${remote} ${currentBranch}`,
dir,
dryRun,
});
});