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.

39 lines
920 B

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