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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ObjectDatabase.ShortenObjectId() #677
Conversation
|
馃憤 for either extension method or lazy property, perhaps just |
Actually I'm unsure about this. Below my rationale.
|
In my view, that it's dependent on the entire object database is a bit of an implementation detail. It's natural to ask a How about a real method (virtual rather than extension, for testability) on |
I'd have to contend the assertion that the dependance on the odb is an implementation detail. The only reason you're asking the object/library instead of taking an arbitrary prefix is this dependence. As this is something that needs to be calculated, rather than accessed, I don't think we should have something that looks like it's accessing underlying data. Something like Maybe something like |
Given that all the other properties on these objects are immutable, it seems a bit weird to have a method on the object that returns a calculated value that can change. Having a minimum prefix length might be nice for consumers who want to show at least N characters as long as the prefix is unique. Here would be my suggestions based on the suggestions above:
|
I took some time... And I'm still not convinced about making I'd rather go with string ObjectDatabase.ShortenObjectId(GitObject object, int? minLength) This wouldn't prevent the consumer from creating an extension method by himself. |
I've started to work on this. |
@@ -619,11 +664,15 @@ protected enum OdbBackendOperations | |||
/// This OdbBackend declares that it supports the Exists method. | |||
/// </summary> | |||
Exists = 64, | |||
/// <summary> |
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.
You could add a blank line here to be consistent.
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.
Fixed!
馃憤 |
bump. |
Sorry for the delay, @nulltoken. I have read this over (but not personally run it) and it looks completely correct to me. I do not see any defects. |
@phkelley 鉂わ笍 for the feedback |
Libgit2 exposes
git_object_short_id()
method. Let's make this available to LibGit2Sharp.Proposed signature would be
Of course, if anyone comes up with a better name for this method, we'll be very grateful 馃槈