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

Commit 4ae0f89

Browse files
SleepWalkergregberge
authored andcommitted
fix(shipit-deploy): skip fetching git in case when repositoryUrl was not provided (closes #207) (#226)
1 parent 1d995dc commit 4ae0f89

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

packages/shipit-deploy/src/tasks/deploy/fetch.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const fetchTask = shipit => {
2222
shipit.log('Create workspace...')
2323
/* eslint-disable no-param-reassign */
2424
if (shipit.config.shallowClone) {
25-
const tmpDir = await tmp.dir({mode: "0755"})
25+
const tmpDir = await tmp.dir({ mode: '0755' })
2626
shipit.workspace = tmpDir.path
2727
} else {
2828
shipit.workspace = shipit.config.workspace
@@ -174,14 +174,20 @@ const fetchTask = shipit => {
174174
}
175175

176176
await createWorkspace()
177-
await initRepository()
178-
await setGitConfig()
179-
await addRemote()
180-
await fetch()
181-
await checkout()
182-
await reset()
183-
await merge()
184-
await updateSubmodules()
177+
178+
if (shipit.config.repositoryUrl) {
179+
await initRepository()
180+
await setGitConfig()
181+
await addRemote()
182+
await fetch()
183+
await checkout()
184+
await reset()
185+
await merge()
186+
await updateSubmodules()
187+
} else {
188+
shipit.log(chalk.yellow('Skip fetching repo. No repositoryUrl provided'))
189+
}
190+
185191
shipit.emit('fetched')
186192
})
187193
}

packages/shipit-deploy/src/tasks/deploy/fetch.test.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ jest.mock('tmp-promise')
66

77
describe('deploy:fetch task', () => {
88
let shipit
9+
let log
910

1011
beforeEach(() => {
12+
log = jest.fn()
1113
shipit = new Shipit({
1214
environment: 'test',
13-
log: jest.fn(),
15+
log,
1416
})
1517

1618
fetchTask(shipit)
@@ -129,4 +131,15 @@ describe('deploy:fetch task', () => {
129131
expect(shipit.local).toBeCalledWith('git checkout master', opts)
130132
expect(shipit.local).toBeCalledWith('git branch --list master', opts)
131133
})
134+
135+
it('should skip fetching if no repositoryUrl provided', async () => {
136+
delete shipit.config.repositoryUrl
137+
138+
await start(shipit, 'deploy:fetch')
139+
140+
expect(shipit.local).not.toHaveBeenCalled()
141+
expect(log).toBeCalledWith(
142+
expect.stringContaining('Skip fetching repo. No repositoryUrl provided'),
143+
)
144+
})
132145
})

0 commit comments

Comments
 (0)