maestro/app/classes/state/git/PullState.js
2020-08-13 20:47:34 -05:00

40 lines
933 B
JavaScript

const AbstractGitState = require('./AbstractGitState')
class PullState extends AbstractGitState {
#ran_once = false
static get services() {
return [...super.services, 'output']
}
async apply() {
if ( !(await this.check()) ) {
const repo = await this._repo()
await repo.pull(this._config.target)
this.#ran_once = true
}
}
async check() {
return this.#ran_once // TODO support a better check here
}
async reverse() {
this.output.warn('Pull state does not currently support automatic reversal.')
}
failure_message() {
return `The Git repo at "${this._config.path}" on host "${this._host.name}" will be pulled.`
}
check_message() {
return this.failure_message()
}
display() {
return `Pull refs in repo ${this._config.path}...`
}
}
module.exports = exports = PullState