You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
maestro/app/classes/state/git/PullState.js

40 lines
933 B

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