From 01ed9a06b20d32b148446d715d6e1beb3050d069 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 Feb 2021 15:55:03 -0700 Subject: Tidy up cmdClass --- backend.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'backend.go') diff --git a/backend.go b/backend.go index 0486e98..c91d0ac 100644 --- a/backend.go +++ b/backend.go @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Luke Shumaker +// Copyright (C) 2017-2018, 2021 Luke Shumaker // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -89,17 +89,11 @@ func (b *Backend) Do(cmd Cmd) error { return b.err } - switch cmd.fiCmdClass() { - case cmdClassCommand: + switch { + case !cmdIs(cmd, cmdClassInCommit): _, b.inCommit = cmd.(CmdCommit) - case cmdClassCommit: - if !b.inCommit { - panic(errors.Errorf("Cannot issue commit sub-command outside of a commit: %[1]T(%#[1]v)", cmd)) - } - case cmdClassComment: - /* do nothing */ - default: - panic(errors.Errorf("invalid cmdClass: %d", cmd.fiCmdClass())) + case !b.inCommit && !cmdIs(cmd, cmdClassCommand): + panic(errors.Errorf("Cannot issue commit sub-command outside of a commit: %[1]T(%#[1]v)", cmd)) } err := cmd.fiCmdWrite(b.fastImportWrite) -- cgit v1.2.3