-
Notifications
You must be signed in to change notification settings - Fork 5
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
radicle-surf: Repository.blob_at() to retrieve a blob using its oid. #124
Open
keepsimple1
wants to merge
1
commit into
main
Choose a base branch
from
blob-id
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input
commit
is not required if we only wanted to retrieve the blob content. It is here as we also need to retrieve theBlob.commit
that created the blob (oid).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't expecting to have the
commit
as a parameter, so what if we changed the result type to justBlobRef<'a>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, and I chose to have the
commit
parameter for a couple of reasons:To be consistent in the API (similar to
blob()
), including the return typeBlob
. The intent ofBlob.commit
was helping the caller to identify thelast_commit
easily without having to do another HTTP call. That is the same for bothblob()
andblob_at()
.From the zulip discussion linked in Description, the caller would (most likely) have the commit info available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reading of the discussion was that we should be able to get a blob without the commit[0]. So if something doesn't know about a commit but does have a blob id, then it can just retrieve the blob content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referring to the original request message.
Yeah, like we discussed so far, there are two options that I can see:
a) Get the blob content only (input:
Oid
). If the caller wanted to find the commit that created the blob, they make another HTTP call. This is not consistent with existingblob()
method.b) Get the blob content and the commit that created the blob. (input:
Oid
and aCommit
that has the blob. ) . Both info are retrieved in one call. This is consistent with existingblob()
method.For the blob content part, b) does more involved work than a), because it also retrieves the commit.
It's a trade-off. My preference is to go with option b) based on the reasons I mentioned earlier. And if we did want to go with a), I would suggest to re-visit
Blob
struct and see if it makes sense to separateBlob.commit
out, and then changeblob()
to be consistent withblob_at()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure and within that thread, I mentioned how I imagined the URL being
'.../blob/<oid>'
:)I don't mind going down this route, but I don't understand why we have to go fetch the commit that created the blob. Can you explain why that's necessary?
I'd expect that we just check the Blob's
Oid
exists with theCommit
's tree, either via diff or using a tree walk.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because this existing
Blob
struct and its API:radicle-git/radicle-surf/src/blob.rs
Lines 52 to 54 in 6de53f7