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 --- cmd.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'cmd.go') diff --git a/cmd.go b/cmd.go index 1665081..d1358a8 100644 --- a/cmd.go +++ b/cmd.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 @@ -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 +} -- cgit v1.2.3