Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
fix(shipit-deploy): skip fetching git in case when repositoryUrl was …
Browse files Browse the repository at this point in the history
…not provided (closes #207) (#226)
  • Loading branch information
SleepWalker authored and gregberge committed Dec 3, 2018
1 parent 1d995dc commit 4ae0f89
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
24 changes: 15 additions & 9 deletions packages/shipit-deploy/src/tasks/deploy/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const fetchTask = shipit => {
shipit.log('Create workspace...')
/* eslint-disable no-param-reassign */
if (shipit.config.shallowClone) {
const tmpDir = await tmp.dir({mode: "0755"})
const tmpDir = await tmp.dir({ mode: '0755' })
shipit.workspace = tmpDir.path
} else {
shipit.workspace = shipit.config.workspace
Expand Down Expand Up @@ -174,14 +174,20 @@ const fetchTask = shipit => {
}

await createWorkspace()
await initRepository()
await setGitConfig()
await addRemote()
await fetch()
await checkout()
await reset()
await merge()
await updateSubmodules()

if (shipit.config.repositoryUrl) {
await initRepository()
await setGitConfig()
await addRemote()
await fetch()
await checkout()
await reset()
await merge()
await updateSubmodules()
} else {
shipit.log(chalk.yellow('Skip fetching repo. No repositoryUrl provided'))
}

shipit.emit('fetched')
})
}
Expand Down
15 changes: 14 additions & 1 deletion packages/shipit-deploy/src/tasks/deploy/fetch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ jest.mock('tmp-promise')

describe('deploy:fetch task', () => {
let shipit
let log

beforeEach(() => {
log = jest.fn()
shipit = new Shipit({
environment: 'test',
log: jest.fn(),
log,
})

fetchTask(shipit)
Expand Down Expand Up @@ -129,4 +131,15 @@ describe('deploy:fetch task', () => {
expect(shipit.local).toBeCalledWith('git checkout master', opts)
expect(shipit.local).toBeCalledWith('git branch --list master', opts)
})

it('should skip fetching if no repositoryUrl provided', async () => {
delete shipit.config.repositoryUrl

await start(shipit, 'deploy:fetch')

expect(shipit.local).not.toHaveBeenCalled()
expect(log).toBeCalledWith(
expect.stringContaining('Skip fetching repo. No repositoryUrl provided'),
)
})
})

0 comments on commit 4ae0f89

Please sign in to comment.