diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2021-02-01 15:55:03 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2021-02-01 17:23:29 -0700 |
commit | 01ed9a06b20d32b148446d715d6e1beb3050d069 (patch) | |
tree | 8b0ef328859804e7b6bafb8f1495817fc31bb756 /cmd.go | |
parent | 328f9cc1ac0ebee9499dc8d50bd84f71897d4df7 (diff) |
Tidy up cmdClass
Diffstat (limited to 'cmd.go')
-rw-r--r-- | cmd.go | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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 @@ -41,10 +41,11 @@ type fiWriter interface { type cmdClass int const ( - cmdClassCommand cmdClass = 1 // may be a top-level command - cmdClassCommit cmdClass = 2 // may be used within in a commit + cmdClassCommand cmdClass = 1 << iota // can be a top-level command + cmdClassInCommit // can be used within in a commit + cmdClassInCommand // can be used in-between lines of another multi-line command - cmdClassComment cmdClass = cmdClassCommand | cmdClassCommit + cmdClassComment = cmdClassCommand | cmdClassInCommit | cmdClassInCommand // "can be used anywhere in the stream that comments are accepted" ) // Cmd is a command that may be found in a fast-import stream. @@ -53,3 +54,7 @@ type Cmd interface { fiCmdWrite(fiWriter) error fiCmdClass() cmdClass } + +func cmdIs(cmd Cmd, class cmdClass) bool { + return cmd.fiCmdClass()&class != 0 +} |