diff --git a/packages/shipjs/src/flow/release.js b/packages/shipjs/src/flow/release.js index 2f69598d..31e97a59 100644 --- a/packages/shipjs/src/flow/release.js +++ b/packages/shipjs/src/flow/release.js @@ -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'; @@ -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 }) { @@ -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 }); gitPush({ tagName, config, dir, dryRun }); await createGitHubRelease({ version, config, dir, dryRun }); await notifyReleaseSuccess({ diff --git a/packages/shipjs/src/step/__tests__/pull.spec.js b/packages/shipjs/src/step/__tests__/pull.spec.js new file mode 100644 index 00000000..9ac4d8d9 --- /dev/null +++ b/packages/shipjs/src/step/__tests__/pull.spec.js @@ -0,0 +1,33 @@ +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 option', () => { + pull({ + remote, + currentBranch, + dir: '.', + dryRun: false, + options: '--rebase', + }); + expect(run).toHaveBeenCalledTimes(1); + expect(run).toHaveBeenCalledWith({ + command: 'git pull --rebase origin-with-token main', + dir: '.', + dryRun: false, + }); + }); +}); diff --git a/packages/shipjs/src/step/pull.js b/packages/shipjs/src/step/pull.js index 52792055..9474a1a4 100644 --- a/packages/shipjs/src/step/pull.js +++ b/packages/shipjs/src/step/pull.js @@ -1,7 +1,13 @@ import runStep from './runStep'; import { run } from '../util'; -export default ({ remote, currentBranch, dir, dryRun }) => +export default ({ remote, currentBranch, dir, dryRun, options }) => runStep({ title: 'Updating from remote.' }, () => { - run({ command: `git pull ${remote} ${currentBranch}`, dir, dryRun }); + run({ + command: `git pull${ + options ? ` ${options.trim()}` : '' + } ${remote} ${currentBranch}`, + dir, + dryRun, + }); });