diff options
author | Michael Muré <batolettre@gmail.com> | 2021-04-09 13:01:14 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2021-04-09 13:01:14 +0200 |
commit | 1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7 (patch) | |
tree | f6d71c1f29cf06ccab9e4ae434b19ab17caa4385 /bug/operation_iterator.go | |
parent | 0fd570171d171aa574d7f01d6033a9c01d668465 (diff) | |
parent | bc5f618eba812859bf87ce2c31b278bd518d4555 (diff) | |
download | git-bug-1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7.tar.gz git-bug-1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7.zip |
Merge remote-tracking branch 'origin/master' into dev-gh-bridge
Diffstat (limited to 'bug/operation_iterator.go')
-rw-r--r-- | bug/operation_iterator.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/bug/operation_iterator.go b/bug/operation_iterator.go deleted file mode 100644 index f42b1776..00000000 --- a/bug/operation_iterator.go +++ /dev/null @@ -1,72 +0,0 @@ -package bug - -type OperationIterator struct { - bug *Bug - packIndex int - opIndex int -} - -func NewOperationIterator(bug Interface) *OperationIterator { - return &OperationIterator{ - bug: bugFromInterface(bug), - packIndex: 0, - opIndex: -1, - } -} - -func (it *OperationIterator) Next() bool { - // Special case of the staging area - if it.packIndex == len(it.bug.packs) { - pack := it.bug.staging - it.opIndex++ - return it.opIndex < len(pack.Operations) - } - - if it.packIndex >= len(it.bug.packs) { - return false - } - - pack := it.bug.packs[it.packIndex] - - it.opIndex++ - - if it.opIndex < len(pack.Operations) { - return true - } - - // Note: this iterator doesn't handle the empty pack case - it.opIndex = 0 - it.packIndex++ - - // Special case of the non-empty staging area - if it.packIndex == len(it.bug.packs) && len(it.bug.staging.Operations) > 0 { - return true - } - - return it.packIndex < len(it.bug.packs) -} - -func (it *OperationIterator) Value() Operation { - // Special case of the staging area - if it.packIndex == len(it.bug.packs) { - pack := it.bug.staging - - if it.opIndex >= len(pack.Operations) { - panic("Iterator is not valid anymore") - } - - return pack.Operations[it.opIndex] - } - - if it.packIndex >= len(it.bug.packs) { - panic("Iterator is not valid anymore") - } - - pack := it.bug.packs[it.packIndex] - - if it.opIndex >= len(pack.Operations) { - panic("Iterator is not valid anymore") - } - - return pack.Operations[it.opIndex] -} |