Skip to content

Add new branch RPCs and change existing RPCs#2283

Merged
doriable merged 5 commits intomainfrom
BSR-2146-new-rpcs
Jul 12, 2023
Merged

Add new branch RPCs and change existing RPCs#2283
doriable merged 5 commits intomainfrom
BSR-2146-new-rpcs

Conversation

@doriable
Copy link
Member

@doriable doriable commented Jul 11, 2023

Adds a new RPC for branches, GetDefaultBranch, which returns the current default
branch mapped to BSR main.

Adds three new fields to RepositoryCommit:

  • tag_count -- number of tags associated with the BSR commit
  • git_commit_metadata_count -- number of git commits with metadata associated with the BSR commit
  • git_commit_no_metadata_count -- number of git commit labels without metadata associated with the BSR commit

Adds pagination of ListGitMetadataForReference.

Adds a new RPC for reference, ListGitCommitsNoMetadataForReference, which returns
a paginated list of git commit labels that do not have git metadata.

Copy link
Member

@unmultimedio unmultimedio left a comment

Choose a reason for hiding this comment

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

More to the why of these RPC, why not adding a filter to the existing rpc ListRepositoryBranches, like bool default_branch to "list" only the default one. And when listing the non-default, it could be filtered out by the client using the is_main_branch from L29.

option idempotency_level = NO_SIDE_EFFECTS;
}
// GetDefaultBranch returns the branch name that is mapped to the main/BSR_HEAD.
rpc GetDefaultBranch(GetDefaultBranchRequest) returns (GetDefaultBranchResponse) {
Copy link
Member

Choose a reason for hiding this comment

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

This RPC name conflicts with L28-29 in which we say it's not "default" but "main" :/

I like "default" better though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah that's true :< Hmm... yeah, I want to use the term default... tbh, I wish we could change the other RPC structure, lol... but it might be late for that. I think Default is a lot more explicit and clear for this use case though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Had an offline discussion, we also decided to go with Current, since this makes it clear it's the current/latest default branch, and does not reflect the history of default branches if it's ever been changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the is_main_branch be removed? I think it may no longer be necessary with the addition of this new rpc. It also feels weird to have a field dedicated to indicate true only for one branch that is default(main).

Copy link
Contributor

@seankimdev seankimdev Jul 12, 2023

Choose a reason for hiding this comment

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

And when listing the non-default, it could be filtered out by the client using the is_main_branch from L29.

ah sorry I missed this part @unmultimedio wrote. I guess it would be necessary if we decide to go in that direction. Let's chat in the meeting.

Copy link
Contributor

@seankimdev seankimdev left a comment

Choose a reason for hiding this comment

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

Looks good to me

}
// ListGitCommitsNoMetadataForReference takes a string reference and returns all the git commit
// labels without metadata associated with the resolved reference commit.
rpc ListGitCommitsNoMetadataForReference(ListGitCommitsNoMetadataForReferenceRequest) returns (ListGitCommitsNoMetadataForReferenceResponse) {
Copy link
Member

Choose a reason for hiding this comment

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

I assume this RPC would be invoked when ListGitCommitMetadataForReference returns empty for a given reference?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, so in the world where a user has buf push'd a BSR commit, that BSR commit reference will not have any git metadata, but may still have meaningful GIT_COMMIT_SHA labels that need to be displayed, so this RPC would be invoked for that circumstance.

Comment on lines +54 to +57
// Number of git commits with metadata associated with the BSR commit.
int64 git_commit_metadata_count = 13;
// Number of git commits without metadata associated with the BSR commit.
int64 git_commit_no_metadata_count = 14;
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused with this one, so if a commit has 2 git commits associated with it, it still has 2 git commit labels. Unless I'm missing something, I think git_commit_no_metadata_count is not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it's for the circumstance where the BSR commit has no git commit metadata associated with it, but still has git commit labels on it -- we would want to count those.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure how this is going to play out. For a BSR commit that was previously push, with, say 3 tags:

buf push --tag foo --tag bar --tag someGitCommitSHA1

and then sync runs, and the content is the same, attaching two git metadatas to the same BSR commit:

someGitCommitSHA2
someGitCommitSHA3

I guess the commit object would have:

{
  tag_count: 5, // foo, bar, and the 3 git shas
  git_commit_metadata_count: 2, // someGitCommitSHA2 and someGitCommitSHA3
  git_commit_no_metadata_count: 1 // someGitCommitSHA1
}

Am I right?

Comment on lines +54 to +57
// Number of git commits with metadata associated with the BSR commit.
int64 git_commit_metadata_count = 13;
// Number of git commits without metadata associated with the BSR commit.
int64 git_commit_no_metadata_count = 14;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure how this is going to play out. For a BSR commit that was previously push, with, say 3 tags:

buf push --tag foo --tag bar --tag someGitCommitSHA1

and then sync runs, and the content is the same, attaching two git metadatas to the same BSR commit:

someGitCommitSHA2
someGitCommitSHA3

I guess the commit object would have:

{
  tag_count: 5, // foo, bar, and the 3 git shas
  git_commit_metadata_count: 2, // someGitCommitSHA2 and someGitCommitSHA3
  git_commit_no_metadata_count: 1 // someGitCommitSHA1
}

Am I right?

@doriable
Copy link
Member Author

@unmultimedio Yes, this is exactly correct.

@doriable doriable merged commit 447b808 into main Jul 12, 2023
@doriable doriable deleted the BSR-2146-new-rpcs branch July 12, 2023 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants