shipit
shipit copied to clipboard
[feature request] Allow configuring cloneDepth
Problem
When you start deploying a branch and someone push to that branch immediately after that, you will see the deploy fails ( when shallowClone: true
).
Checking out commit-ish "2e9d5dc95b5c48a2bbe4c7607df253881a65cfef"
Running "git checkout 2e9d5dc95b5c48a2bbe4c7607df253881a65cfef" on local.
@ fatal: reference is not a tree: 2e9d5dc95b5c48a2bbe4c7607df253881a65cfef
'deploy:fetch' errored after 4.08 s
Error: Command failed: git checkout 2e9d5dc95b5c48a2bbe4c7607df253881a65cfef
fatal: reference is not a tree: 2e9d5dc95b5c48a2bbe4c7607df253881a65cfef
at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Socket.<anonymous> (internal/child_process.js:439:11)
at Socket.emit (events.js:315:20)
at Pipe.<anonymous> (net.js:673:12)
error Command failed with exit code 1.
This happens since I was using shallowClone: true
and it makes sense.
https://github.com/shipitjs/shipit/blob/5e9b5fb4396e75cbe43382781c0b06491a66ad3c/packages/shipit-deploy/src/tasks/deploy/fetch.js#L121
Solution
I want to avoid shallowClone: false
because we do not need to fully cloning the repo ( and could be slow for some bigger project ),
I think it would be better to have something like cloneDepth: 10
( cloneDepth: 1
and cloneDepth: Infinity
would be equivalent to the current shallowClone
behavior ).
const { cloneDepth } = shipit.config
const unlimitedDepth = cloneDepth === undefined || cloneDepth === Infinity
const fetchDepth = unlimitedDepth ? '' : ` --depth=${cloneDepth}`
Concern
If shallowClone
option is dropped and substituted, this will be a breaking change