summaryrefslogtreecommitdiff
path: root/backend.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2021-02-01 15:55:03 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2021-02-01 17:23:29 -0700
commit01ed9a06b20d32b148446d715d6e1beb3050d069 (patch)
tree8b0ef328859804e7b6bafb8f1495817fc31bb756 /backend.go
parent328f9cc1ac0ebee9499dc8d50bd84f71897d4df7 (diff)
Tidy up cmdClass
Diffstat (limited to 'backend.go')
-rw-r--r--backend.go16
1 files changed, 5 insertions, 11 deletions
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 <lukeshu@lukeshu.com>
+// Copyright (C) 2017-2018, 2021 Luke Shumaker <lukeshu@lukeshu.com>
//
// 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)