const AbstractGitState = require('./AbstractGitState') class TagState extends AbstractGitState { async apply() { if ( !(await this.check()) ) { const repo = await this._repo() await repo.create_tag(this._config.tag) } } async check() { const repo = await this._repo() try { await repo.get_tag(this._config.tag) return true } catch (e) { return false } } async reverse() { if ( await this.check() ) { const repo = await this._repo() await repo.delete_tag(this._config.tag) } } failure_message() { return `The tag "${this._config.tag}" does not exist in the Git repo "${this._config.path}" on host "${this._host.name}."` } check_message() { return this.failure_message() } } module.exports = exports = TagState