Skip to content
This repository was archived by the owner on Aug 24, 2024. It is now read-only.

Commit 43cabb2

Browse files
committed
cleanup code and fix errors
1 parent ced3d97 commit 43cabb2

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

migration1/after/bug/bug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func read(repo repository.ClockedRepo, identityResolver identity.Resolver, ref s
207207
err = json.Unmarshal(data, &opp)
208208

209209
if err != nil {
210-
return nil, errors.Wrap(err, "failed to decode OperationPack json")
210+
return nil, err
211211
}
212212

213213
// tag the pack with the commit hash

migration1/after/bug/operation_pack.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
const oldFormatVersion = 1
1313
const newFormatVersion = 2
1414

15+
var ErrInvalidFormatVersion = errors.New("unknown format version")
16+
1517
// OperationPack represent an ordered set of operation to apply
1618
// to a Bug. These operations are stored in a single Git commit.
1719
//
@@ -47,7 +49,7 @@ func (opp *OperationPack) UnmarshalJSON(data []byte) error {
4749
}
4850

4951
if aux.Version != oldFormatVersion {
50-
return fmt.Errorf("unknown format version %v", aux.Version)
52+
return ErrInvalidFormatVersion
5153
}
5254

5355
opp.FormatVersion = aux.Version

migration1/migration1.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ func (m *Migration1) migrate(repo afterrepo.ClockedRepo) error {
3131
// Iterating through all the bugs in the repo
3232
for streamedBug := range afterbug.ReadAllLocal(repo) {
3333
if streamedBug.Err != nil {
34-
fmt.Printf("Got error when reading bug: %q\n", streamedBug.Err)
34+
if streamedBug.Err != afterbug.ErrInvalidFormatVersion {
35+
fmt.Printf("Got error when reading bug: %q\n", streamedBug.Err)
36+
} else {
37+
fmt.Printf("skipping bug, already updated")
38+
}
3539
continue
3640
}
3741

migration1/migration1_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ func TestMigrate01(t *testing.T) {
7171

7272
bugs1 := aftertestbug.ReadAllLocal(repo2)
7373
bug1 := (<-bugs1).Bug
74-
fmt.Printf("%+v", bug1)
7574
operations := aftertestbug.NewOperationIterator(bug1)
7675
require.Equal(t, true, operations.Next(), "unable to get first operation")
7776

root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func runRootCmd(env *Env, migrations []Migration) error {
5858
env.err.Printf("Error applying migration: %v\n", err)
5959
os.Exit(1)
6060
}
61+
env.out.Println()
6162
}
6263
env.out.Println("\nDone!")
6364
return nil

0 commit comments

Comments
 (0)