Unitech / pm2-deploy

Deploy part of PM2
http://pm2.keymetrics.io/docs/usage/deployment/
MIT License
178 stars 71 forks source link

fix(deploy): fix git ref verify #175

Closed laoshu133 closed 4 years ago

laoshu133 commented 5 years ago

This problem is encountered when deploying with pm2 deploy ref ref_hash.

git rev-parse --quiet --verify ${ref_hash} does not check if ref_hash really exists, it only checks if the format is valid.

For example, the command can be executed under the current repo:

# true ref
git rev-parse --quiet --verify 4e9655c042fa43ea82506cf5f4fad583a880568d

# fake ref
git rev-parse --quiet --verify 4e9655c042fa43ea82506cf5f4fad583a8805680
mkornatz commented 4 years ago

+1. Just ran into this same issue. It looks like a branch can be supplied as the next param, but the documentation doesn't say anything about that. It'd be great to see this fix applied, or the docs updated with the proper way to specify a ref hash.

In order to work around this, we ended up adding a pre-deploy hook which runs a git fetch --all in order to be able to refer to the ref hash passed in the deploy command.