diff options
author | Michael Muré <batolettre@gmail.com> | 2019-02-16 17:32:30 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-03-01 22:40:24 +0100 |
commit | d2483d83dd52365741f51eca106aa18c4e8d6420 (patch) | |
tree | b1265d1874005952febe8d469435827a4947ba7b /bug/bug.go | |
parent | cd7ed7ff9e3250c10e97fe16c934b5a6151527bb (diff) | |
download | git-bug-d2483d83dd52365741f51eca106aa18c4e8d6420.tar.gz |
identity: I can compile again !!
Diffstat (limited to 'bug/bug.go')
-rw-r--r-- | bug/bug.go | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -321,6 +321,11 @@ func (bug *Bug) Validate() error { return fmt.Errorf("first operation should be a Create op") } + // The bug ID should be the hash of the first commit + if len(bug.packs) > 0 && string(bug.packs[0].commitHash) != bug.id { + return fmt.Errorf("bug id should be the first commit hash") + } + // Check that there is no more CreateOp op it := NewOperationIterator(bug) createCount := 0 @@ -349,7 +354,8 @@ func (bug *Bug) HasPendingOp() bool { // Commit write the staging area in Git and move the operations to the packs func (bug *Bug) Commit(repo repository.ClockedRepo) error { - if bug.staging.IsEmpty() { + + if !bug.NeedCommit() { return fmt.Errorf("can't commit a bug with no pending operation") } @@ -466,6 +472,17 @@ func (bug *Bug) Commit(repo repository.ClockedRepo) error { return nil } +func (bug *Bug) CommitAsNeeded(repo repository.ClockedRepo) error { + if !bug.NeedCommit() { + return nil + } + return bug.Commit(repo) +} + +func (bug *Bug) NeedCommit() bool { + return !bug.staging.IsEmpty() +} + func makeMediaTree(pack OperationPack) []repository.TreeEntry { var tree []repository.TreeEntry counter := 0 |