Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Requests: Add proto and ref manager logic #8178

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

N-o-Z
Copy link
Member

@N-o-Z N-o-Z commented Sep 17, 2024

Closes #8177

Change Description

Create proto data models and logic in ref manager

@N-o-Z N-o-Z requested review from itaigilo and a team September 17, 2024 21:36
@N-o-Z N-o-Z self-assigned this Sep 17, 2024
Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

13 passed

Copy link

E2E Test Results - Quickstart

10 passed

@N-o-Z N-o-Z added the exclude-changelog PR description should not be included in next release changelog label Sep 17, 2024
Copy link
Contributor

@itaigilo itaigilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

Some comments, but most are minor, so approving to not block -
But I'd be happy to see CreatedAt renamed.

@@ -260,6 +260,34 @@ type RangeID string
// ImportID represents an import process id in the ref-store
type ImportID string

type PullRequestID string

func (id PullRequestID) String() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a safer approach than casting.
We use this method in many places in our code

type PullUpdateFunc func(request *PullRequest) (*PullRequest, error)

type PullRequest struct {
CreatedAt time.Time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the other objects in this package (Repo and Commit) this is called CreationDate.
Please align with this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// Destination - destination branch of pull request
Destination string
// CommitID - The commit ID that of the source at the time of the merge. Relevant only for merged PRs
CommitID string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe MergedCommitID or something like this, to be more explicit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

importsPrefix = "imports"
repoMetadataPrefix = "repo-metadata"
pullRequestsPrefix = "pulls"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@@ -69,10 +69,6 @@ func SettingsPath(key string) string {
return kv.FormatPath(settingsPrefix, key)
}

func LinkedAddressPath(key string) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

t.Run("update_pull_request_exists", func(t *testing.T) {
require.NoError(t, r.CreatePullRequest(ctx, repository, expected.ID, &expected.PullRequest))

err := r.UpdatePullRequest(ctx, repository, expected.ID, func(request *graveler.PullRequest) (*graveler.PullRequest, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, prefer creating a new object instead of modifying an existing one.
In this case, the one that will add a new test after this will expect to have "some title" as the title of expected, but it'll be different.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, considering this is a unit test let's defer this to later

err = graveler.ErrPullRequestNotFound
}
if err != nil {
return nil, nil, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we also do it in other places, but note that this means that the manager might return kv errors (where I would expect it to return graveler errors).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, but should be handled in higher layers

@N-o-Z N-o-Z enabled auto-merge (squash) September 18, 2024 15:00
@N-o-Z N-o-Z merged commit 963061e into master Sep 18, 2024
37 checks passed
@N-o-Z N-o-Z deleted the task/pulls-proto-and-ref-manager-8177 branch September 18, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude-changelog PR description should not be included in next release changelog pull-requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pull Requests MVP - Create data models and ref manager code
2 participants