Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
44d7587
lamport: match wikipedia algorithm
MichaelMure Nov 8, 2020
fb0c5fd
repo: expose all lamport clocks, move clocks in their own folder
MichaelMure Nov 8, 2020
5ae8a13
identity: Id from data, not git + hold multiple lamport clocks
MichaelMure Nov 8, 2020
7163b22
bug: Id from first operation data, not git + remove root link
MichaelMure Nov 8, 2020
ab57d74
deal with the previous changes
MichaelMure Nov 8, 2020
b01aa18
identity: PR fixes
MichaelMure Nov 8, 2020
2bf2b2d
entity: unique function to generate IDs
MichaelMure Nov 8, 2020
497ec13
bug: debug
MichaelMure Nov 8, 2020
2788c5f
bug: don't store the id in Bug, match how it's done for Identity
MichaelMure Nov 29, 2020
d96284d
Change the comment ID to use both bug and comment ID references.
vincetiu8 Jul 9, 2020
fcf4391
bug: fix tests
MichaelMure Nov 29, 2020
db70743
entity: generalize the combined Ids, use 64 length
MichaelMure Nov 30, 2020
bb8a214
command: fix "comment edit" usage
MichaelMure Dec 10, 2020
5f6a391
entity: add error to signal invalid format
MichaelMure Dec 21, 2020
5c4e7de
repository: partially add two new functions to RepoData
MichaelMure Dec 21, 2020
9cca74c
entity: add embryo of a generic, DAG-enabled entity
MichaelMure Dec 21, 2020
51ece14
entity: clocks and write
MichaelMure Dec 21, 2020
4ef92ef
entity: total ordering of operations
MichaelMure Dec 25, 2020
8d63c98
WIP
MichaelMure Jan 3, 2021
dc5059b
entity: more progress on merging and signing
MichaelMure Jan 24, 2021
fe4237d
entity: readAll and more testing
MichaelMure Jan 25, 2021
e35c7c4
entity: more testing and bug fixing
MichaelMure Feb 5, 2021
32c55a4
entity: use BFS instead of DFS to get the proper topological order
MichaelMure Feb 7, 2021
26a4b03
entity: test all merge scenario
MichaelMure Feb 7, 2021
2bdb1b6
entity: working commit signatures
MichaelMure Feb 9, 2021
f5b92dc
require go 1.15
MichaelMure Feb 9, 2021
f741669
entity: remove the pack lamport time that doesn't bring anything actu…
MichaelMure Feb 9, 2021
ef05c15
entity: implement remove
MichaelMure Feb 10, 2021
59e9981
entity: expose create and edit lamport clocks
MichaelMure Feb 11, 2021
71e22d9
entity: clock loader
MichaelMure Feb 11, 2021
94f06cd
entity: pass the identity resolver instead of defining it once
MichaelMure Feb 14, 2021
99b9dd8
entity: support different author in staging operations
MichaelMure Feb 14, 2021
3f6ef50
bug: migrate to the DAG entity structure!
MichaelMure Feb 14, 2021
4b9862e
entity: make sure merge commit don't have operations
MichaelMure Feb 14, 2021
d0d7be8
minor cleanups
MichaelMure Feb 14, 2021
1ced77a
fix merge
MichaelMure Feb 14, 2021
45e540c
bug: wrap dag.Entity into a full Bug in MergeAll
MichaelMure Feb 14, 2021
bd09541
entity: no sign-post needed
MichaelMure Feb 20, 2021
f1d4a19
bug: nonce on all operation to prevent id collision
MichaelMure Mar 14, 2021
214abe4
WIP operation with files
MichaelMure Feb 20, 2021
5215634
entity: add support for storing files
MichaelMure Mar 21, 2021
aa0449a
Merge remote-tracking branch 'origin/master' into dag-entity
MichaelMure Mar 29, 2021
cb9b065
entity: more comments
MichaelMure Apr 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x]
go-version: [1.15.x]
platform: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.platform }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ git-bug
dist
coverage.txt
.idea/
.git_bak*
49 changes: 4 additions & 45 deletions api/graphql/models/lazy_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/lamport"
"github.com/MichaelMure/git-bug/util/timestamp"
)

// IdentityWrapper is an interface used by the GraphQL resolvers to handle an identity.
Expand All @@ -21,11 +19,8 @@ type IdentityWrapper interface {
Login() (string, error)
AvatarUrl() (string, error)
Keys() ([]*identity.Key, error)
ValidKeysAtTime(time lamport.Time) ([]*identity.Key, error)
DisplayName() string
IsProtected() (bool, error)
LastModificationLamport() (lamport.Time, error)
LastModification() (timestamp.Timestamp, error)
}

var _ IdentityWrapper = &lazyIdentity{}
Expand Down Expand Up @@ -69,6 +64,10 @@ func (li *lazyIdentity) Name() string {
return li.excerpt.Name
}

func (li *lazyIdentity) DisplayName() string {
return li.excerpt.DisplayName()
}

func (li *lazyIdentity) Email() (string, error) {
id, err := li.load()
if err != nil {
Expand Down Expand Up @@ -101,18 +100,6 @@ func (li *lazyIdentity) Keys() ([]*identity.Key, error) {
return id.Keys(), nil
}

func (li *lazyIdentity) ValidKeysAtTime(time lamport.Time) ([]*identity.Key, error) {
id, err := li.load()
if err != nil {
return nil, err
}
return id.ValidKeysAtTime(time), nil
}

func (li *lazyIdentity) DisplayName() string {
return li.excerpt.DisplayName()
}

func (li *lazyIdentity) IsProtected() (bool, error) {
id, err := li.load()
if err != nil {
Expand All @@ -121,22 +108,6 @@ func (li *lazyIdentity) IsProtected() (bool, error) {
return id.IsProtected(), nil
}

func (li *lazyIdentity) LastModificationLamport() (lamport.Time, error) {
id, err := li.load()
if err != nil {
return 0, err
}
return id.LastModificationLamport(), nil
}

func (li *lazyIdentity) LastModification() (timestamp.Timestamp, error) {
id, err := li.load()
if err != nil {
return 0, err
}
return id.LastModification(), nil
}

var _ IdentityWrapper = &loadedIdentity{}

type loadedIdentity struct {
Expand All @@ -163,18 +134,6 @@ func (l loadedIdentity) Keys() ([]*identity.Key, error) {
return l.Interface.Keys(), nil
}

func (l loadedIdentity) ValidKeysAtTime(time lamport.Time) ([]*identity.Key, error) {
return l.Interface.ValidKeysAtTime(time), nil
}

func (l loadedIdentity) IsProtected() (bool, error) {
return l.Interface.IsProtected(), nil
}

func (l loadedIdentity) LastModificationLamport() (lamport.Time, error) {
return l.Interface.LastModificationLamport(), nil
}

func (l loadedIdentity) LastModification() (timestamp.Timestamp, error) {
return l.Interface.LastModification(), nil
}
12 changes: 6 additions & 6 deletions api/graphql/resolvers/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (createOperationResolver) ID(_ context.Context, obj *bug.CreateOperation) (
}

func (createOperationResolver) Author(_ context.Context, obj *bug.CreateOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author), nil
return models.NewLoadedIdentity(obj.Author()), nil
}

func (createOperationResolver) Date(_ context.Context, obj *bug.CreateOperation) (*time.Time, error) {
Expand All @@ -36,7 +36,7 @@ func (addCommentOperationResolver) ID(_ context.Context, obj *bug.AddCommentOper
}

func (addCommentOperationResolver) Author(_ context.Context, obj *bug.AddCommentOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author), nil
return models.NewLoadedIdentity(obj.Author()), nil
}

func (addCommentOperationResolver) Date(_ context.Context, obj *bug.AddCommentOperation) (*time.Time, error) {
Expand All @@ -57,7 +57,7 @@ func (editCommentOperationResolver) Target(_ context.Context, obj *bug.EditComme
}

func (editCommentOperationResolver) Author(_ context.Context, obj *bug.EditCommentOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author), nil
return models.NewLoadedIdentity(obj.Author()), nil
}

func (editCommentOperationResolver) Date(_ context.Context, obj *bug.EditCommentOperation) (*time.Time, error) {
Expand All @@ -74,7 +74,7 @@ func (labelChangeOperationResolver) ID(_ context.Context, obj *bug.LabelChangeOp
}

func (labelChangeOperationResolver) Author(_ context.Context, obj *bug.LabelChangeOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author), nil
return models.NewLoadedIdentity(obj.Author()), nil
}

func (labelChangeOperationResolver) Date(_ context.Context, obj *bug.LabelChangeOperation) (*time.Time, error) {
Expand All @@ -91,7 +91,7 @@ func (setStatusOperationResolver) ID(_ context.Context, obj *bug.SetStatusOperat
}

func (setStatusOperationResolver) Author(_ context.Context, obj *bug.SetStatusOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author), nil
return models.NewLoadedIdentity(obj.Author()), nil
}

func (setStatusOperationResolver) Date(_ context.Context, obj *bug.SetStatusOperation) (*time.Time, error) {
Expand All @@ -112,7 +112,7 @@ func (setTitleOperationResolver) ID(_ context.Context, obj *bug.SetTitleOperatio
}

func (setTitleOperationResolver) Author(_ context.Context, obj *bug.SetTitleOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author), nil
return models.NewLoadedIdentity(obj.Author()), nil
}

func (setTitleOperationResolver) Date(_ context.Context, obj *bug.SetTitleOperation) (*time.Time, error) {
Expand Down
13 changes: 0 additions & 13 deletions api/graphql/resolvers/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ type rootQueryResolver struct {
cache *cache.MultiRepoCache
}

func (r rootQueryResolver) DefaultRepository(_ context.Context) (*models.Repository, error) {
repo, err := r.cache.DefaultRepo()

if err != nil {
return nil, err
}

return &models.Repository{
Cache: r.cache,
Repo: repo,
}, nil
}

func (r rootQueryResolver) Repository(_ context.Context, ref *string) (*models.Repository, error) {
var repo *cache.RepoCache
var err error
Expand Down
4 changes: 2 additions & 2 deletions bridge/core/auth/credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestCredential(t *testing.T) {
repo := repository.NewMockRepoForTest()
repo := repository.NewMockRepo()

storeToken := func(val string, target string) *Token {
token := NewToken(target, val)
Expand Down Expand Up @@ -102,7 +102,7 @@ func sameIds(t *testing.T, a []Credential, b []Credential) {
}

func testCredentialSerial(t *testing.T, original Credential) Credential {
repo := repository.NewMockRepoForTest()
repo := repository.NewMockRepo()

original.SetMetadata("test", "value")

Expand Down
2 changes: 1 addition & 1 deletion bridge/github/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
continue
}

opAuthor := op.GetAuthor()
opAuthor := op.Author()
client, err := ge.getClientForIdentity(opAuthor.Id())
if err != nil {
continue
Expand Down
2 changes: 1 addition & 1 deletion bridge/github/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase {
}
}

func TestPushPull(t *testing.T) {
func TestGithubPushPull(t *testing.T) {
// repo owner
envUser := os.Getenv("GITHUB_TEST_USER")

Expand Down
2 changes: 2 additions & 0 deletions bridge/github/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ func (gi *githubImporter) ensurePerson(repo *cache.RepoCache, actor *actor) (*ca
email,
string(actor.Login),
string(actor.AvatarUrl),
nil,
map[string]string{
metaKeyGithubLogin: string(actor.Login),
},
Expand Down Expand Up @@ -598,6 +599,7 @@ func (gi *githubImporter) getGhost(repo *cache.RepoCache) (*cache.IdentityCache,
"",
string(q.User.Login),
string(q.User.AvatarUrl),
nil,
map[string]string{
metaKeyGithubLogin: string(q.User.Login),
},
Expand Down
63 changes: 29 additions & 34 deletions bridge/github/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/MichaelMure/git-bug/bridge/core"
Expand All @@ -19,8 +18,23 @@ import (
"github.com/MichaelMure/git-bug/util/interrupt"
)

func Test_Importer(t *testing.T) {
author := identity.NewIdentity("Michael Muré", "[email protected]")
func TestGithubImporter(t *testing.T) {
envToken := os.Getenv("GITHUB_TOKEN_PRIVATE")
if envToken == "" {
t.Skip("Env var GITHUB_TOKEN_PRIVATE missing")
}

repo := repository.CreateGoGitTestRepo(false)
defer repository.CleanupTestRepos(repo)

backend, err := cache.NewRepoCache(repo)
require.NoError(t, err)

defer backend.Close()
interrupt.RegisterCleaner(backend.Close)

author, err := identity.NewIdentity(repo, "Michael Muré", "[email protected]")
require.NoError(t, err)

tests := []struct {
name string
Expand Down Expand Up @@ -127,20 +141,6 @@ func Test_Importer(t *testing.T) {
},
}

repo := repository.CreateGoGitTestRepo(false)
defer repository.CleanupTestRepos(repo)

backend, err := cache.NewRepoCache(repo)
require.NoError(t, err)

defer backend.Close()
interrupt.RegisterCleaner(backend.Close)

envToken := os.Getenv("GITHUB_TOKEN_PRIVATE")
if envToken == "" {
t.Skip("Env var GITHUB_TOKEN_PRIVATE missing")
}

login := "test-identity"
author.SetMetadata(metaKeyGithubLogin, login)

Expand Down Expand Up @@ -178,33 +178,28 @@ func Test_Importer(t *testing.T) {
require.NoError(t, err)

ops := b.Snapshot().Operations
assert.Len(t, tt.bug.Operations, len(b.Snapshot().Operations))
require.Len(t, tt.bug.Operations, len(b.Snapshot().Operations))

for i, op := range tt.bug.Operations {
require.IsType(t, ops[i], op)
require.Equal(t, op.Author().Name(), ops[i].Author().Name())

switch op.(type) {
switch op := op.(type) {
case *bug.CreateOperation:
assert.Equal(t, op.(*bug.CreateOperation).Title, ops[i].(*bug.CreateOperation).Title)
assert.Equal(t, op.(*bug.CreateOperation).Message, ops[i].(*bug.CreateOperation).Message)
assert.Equal(t, op.(*bug.CreateOperation).Author.Name(), ops[i].(*bug.CreateOperation).Author.Name())
require.Equal(t, op.Title, ops[i].(*bug.CreateOperation).Title)
require.Equal(t, op.Message, ops[i].(*bug.CreateOperation).Message)
case *bug.SetStatusOperation:
assert.Equal(t, op.(*bug.SetStatusOperation).Status, ops[i].(*bug.SetStatusOperation).Status)
assert.Equal(t, op.(*bug.SetStatusOperation).Author.Name(), ops[i].(*bug.SetStatusOperation).Author.Name())
require.Equal(t, op.Status, ops[i].(*bug.SetStatusOperation).Status)
case *bug.SetTitleOperation:
assert.Equal(t, op.(*bug.SetTitleOperation).Was, ops[i].(*bug.SetTitleOperation).Was)
assert.Equal(t, op.(*bug.SetTitleOperation).Title, ops[i].(*bug.SetTitleOperation).Title)
assert.Equal(t, op.(*bug.SetTitleOperation).Author.Name(), ops[i].(*bug.SetTitleOperation).Author.Name())
require.Equal(t, op.Was, ops[i].(*bug.SetTitleOperation).Was)
require.Equal(t, op.Title, ops[i].(*bug.SetTitleOperation).Title)
case *bug.LabelChangeOperation:
assert.ElementsMatch(t, op.(*bug.LabelChangeOperation).Added, ops[i].(*bug.LabelChangeOperation).Added)
assert.ElementsMatch(t, op.(*bug.LabelChangeOperation).Removed, ops[i].(*bug.LabelChangeOperation).Removed)
assert.Equal(t, op.(*bug.LabelChangeOperation).Author.Name(), ops[i].(*bug.LabelChangeOperation).Author.Name())
require.ElementsMatch(t, op.Added, ops[i].(*bug.LabelChangeOperation).Added)
require.ElementsMatch(t, op.Removed, ops[i].(*bug.LabelChangeOperation).Removed)
case *bug.AddCommentOperation:
assert.Equal(t, op.(*bug.AddCommentOperation).Message, ops[i].(*bug.AddCommentOperation).Message)
assert.Equal(t, op.(*bug.AddCommentOperation).Author.Name(), ops[i].(*bug.AddCommentOperation).Author.Name())
require.Equal(t, op.Message, ops[i].(*bug.AddCommentOperation).Message)
case *bug.EditCommentOperation:
assert.Equal(t, op.(*bug.EditCommentOperation).Message, ops[i].(*bug.EditCommentOperation).Message)
assert.Equal(t, op.(*bug.EditCommentOperation).Author.Name(), ops[i].(*bug.EditCommentOperation).Author.Name())
require.Equal(t, op.Message, ops[i].(*bug.EditCommentOperation).Message)

default:
panic("unknown operation type")
Expand Down
2 changes: 1 addition & 1 deletion bridge/gitlab/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out
continue
}

opAuthor := op.GetAuthor()
opAuthor := op.Author()
client, err := ge.getIdentityClient(opAuthor.Id())
if err != nil {
continue
Expand Down
2 changes: 1 addition & 1 deletion bridge/gitlab/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase {
}
}

func TestPushPull(t *testing.T) {
func TestGitlabPushPull(t *testing.T) {
// token must have 'repo' and 'delete_repo' scopes
envToken := os.Getenv("GITLAB_API_TOKEN")
if envToken == "" {
Expand Down
1 change: 1 addition & 0 deletions bridge/gitlab/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ func (gi *gitlabImporter) ensurePerson(repo *cache.RepoCache, id int) (*cache.Id
user.PublicEmail,
user.Username,
user.AvatarURL,
nil,
map[string]string{
// because Gitlab
metaKeyGitlabId: strconv.Itoa(id),
Expand Down
Loading