Include commit information in CI builds. Fixes #158

This commit is contained in:
Tulir Asokan
2020-06-03 20:32:53 +03:00
parent 7b75d763ed
commit 09385713de
5 changed files with 59 additions and 6 deletions

View File

@@ -105,6 +105,8 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) {
handler.CommandLogoutMatrix(ce)
case "help":
handler.CommandHelp(ce)
case "version":
handler.CommandVersion(ce)
case "reconnect":
handler.CommandReconnect(ce)
case "disconnect":
@@ -174,6 +176,21 @@ func (handler *CommandHandler) CommandDevTest(_ *CommandEvent) {
}
const cmdVersionHelp = `version - View the bridge version`
func (handler *CommandHandler) CommandVersion(ce *CommandEvent) {
version := fmt.Sprintf("%s+dev.unknown", Version)
if Tag == Version {
version = fmt.Sprintf("[%s](%s/releases/%s) (%s)", Version, URL, Tag, BuildTime)
} else if len(Commit) > 8 {
if !strings.HasSuffix(Version, "+dev") {
Version += "+dev"
}
version = fmt.Sprintf("%s.[%s](%s/commit/%s) (%s)", Version, Commit[:8], URL, Commit, BuildTime)
}
ce.Reply(fmt.Sprintf("[%s](%s) %s", Name, URL, version))
}
const cmdSetPowerLevelHelp = `set-pl [user ID] <power level> - Change the power level in a portal room. Only for bridge admins.`
func (handler *CommandHandler) CommandSetPowerLevel(ce *CommandEvent) {