I found it. It found me…
Whatever!
I came across the only documentation about cloning a git repo with the --depth
option, to create a “shallow” copy with the specified number of commits truncated from HEAD
.
if test <b>fetch != "fast";</b> then
log "full fetch"
run "git clone $repo $path/source"
else
log "fast fetch"
run "git clone <b>--depth=5</b> --branch $branch $repo $path/source"
fi
Found in the source code of pm2-deploy.
Apart from the IRRATIONAL INVERTED IF STATEMENT ™ there, it seems to do it’s job. (Why wouldn’t you simply test for the truthy condition and invert both branches?)
Usage in pm2 ecosystem.config.js
I found that you can just specify "fetch": "fast"
in your pm2 ecosystem configuration.
This means that it would fetch the last 5 commits from the HEAD
(as you can see above).
Good enough for me.
...
deploy : {
production : {
<b>fetch: 'fast',</b>
user: 'node',
host: '0.0.0.0',
ref: 'origin/master',
repo: '[email protected]:repo.git',
path: '/app',
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production'
}
}
...