-
Notifications
You must be signed in to change notification settings - Fork 899
WIP - Notes #140
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
WIP - Notes #140
Conversation
|
I created NotesCollection, and moved all the retrieval of the notes into it. It feels better not to clutter Commit with that stuff.
I think so. However, I'm not sure about the way I'm doing it at the moment (see the enumerator of NoteCollection).
Yep, done. I actually felt it was needed before reading your comment 😄
commit.Notes.Default can be a possibility. However, it made me think about what is the default namespace for LibGit2Sharp. In git commandline, you can change the default namespace by modifying the GIT_NOTES_REF env variable. Thus, the current implementation I tried relies on a hardcoded default to "refs/notes/commits". |
How does libgit2 handle other places where git commandline respects env variables? Related: libgit2/libgit2#649
It looks like |
I tried to play with it, but it was the same. Maybe it's just that I don't see what you mean, so if you (or someone else) has time to play with the code, I would be grateful.
I added a comment on libgit2/libgit2#649 about that. In the meantime, I think passing the namespace to be in control of what the default is, is the best option. On a separate topic, I implemented add/delete/modify notes behavior on the NoteCollection object. @nulltoken, @dahlbyk, would you be so kind as to review it please (at the API level only; I will add the doc when the API is stable)? I was also wondering if we should have a Notes namespace at the However, I understand you may have better insight on the use cases than I have, so if you think it would be better, please tell me, and I can try to implement Notes on top of the |
add/delete/modify look good. Should IMO |
I would favor a different approach. The way I see it is that, from a high-level perspective, a So I'd rather see a In order to facilitate the implementation of the git log scenario, we could indeed add a I'd see something similar to this: Commit commit = repo.Head.Tip;
/* Enumerate notes for this object in the default namespace
*
* Would return 0 or 1 note.
*/
foreach (Note note in commit.Notes)
{
//...
}
/* Enumerate notes for this object in the "builds" namespace
*
* Would return 0 or 1 note.
*/
foreach (Note note in commit.Notes["builds"])
{
//...
}
/* Enumerate notes for this object from all namespaces
*
* Would return 0 or more notes.
*/
foreach (Note note in commit.Notes["*"])
{
//...
} As for the retrieval of the notes in the main Note note;
/* Retrieve note for specified object in the default namespace */
note = repo.Notes[objectId];
/* Retrieve note for specified object in the "builds" namespace */
note = repo.Notes[objectId, "builds"]; One thing I'm not completely comfortable with is the following remark from the doc
My proposal would be to wait for a specific request/use case related to binary notes. |
return true; | ||
} | ||
} | ||
} No newline at end of file |
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 think I can almost understand why you want a repo.Notes namespace. At least, I can feel there is an itch to scratch here 😄 If you don't mind, let me ask a few questions to make sure I understand:
I'm quite sure other questions will pop later. Once again, sorry for being a bit slow on the understanding part, I'm doing my best here ;) |
BTW, the doc states that "list [...] all note objects and the objects they annotate" which may tend to make the oid of the annotated object a part of the Equality contributor....
Huh...
Slow? Youmust be kidding me? I think the git notes are one of the most obscur part of git.
No you don't. You're just warming up. You're better than this! 😄 |
I pushed a spike based on your feedback. Could you please take a look and tell me what you think about that? Points of interest:
Anyway, as everything now goes through repo.Notes, it should be easy to change. |
|
@yorah I pushed a rebound @ https://github.com/nulltoken/libgit2sharp/tree/topic/notes2/rebound I've moved some code into some extensions methods. And I'd vote to delete it. Let's expose the Notes as is, ordered with the default Namespace in first position. Note: I've worked fast. It's not polished. Sorry for that.
@dahlbyk You will still be able to access the Notes related to the Commit, as a |
@dahlbyk But I'd really prefer not allow addition/updation of Notes through the Commit object. |
Because |
Yes, mostly. |
Hi. I'm still struggling a bit to code the "git notes list" behavior (not sure it's possible, but I'll let you know if I'm really stuck). In the meantime, what do you think about the last commits? |
Updated the branch with:
Missing/TODO is to rebase on next vNext to benefit from:
|
Done. @nulltoken, @dahlbyk, can you please perform a final review? |
Only thing you might add is a test that enumerates |
Thanks for the time you spent on this. Regarding the use case "Enumerating NoteCollection returns notes from the default namespace", you'll see that it is already tested in the test method
|
So it is - good thinking. 👏 |
I agree with @dahlbyk: Very nice job! Manually merged in vNext |
Released as part of v0.9.5 |
Hi, I started working on git notes. Here is the first draft, more to follow soon.
One of the issue I'm foreseeing, is about how to get all notes, from all namespaces (similar to the git log --show-notes=*). I don't know of a good way to do this (iterating through the refs first to find all the refs/notes/xxx ones?), so if you have an idea, feel free to share it!
Also, in terms of API, I was thinking about making Notes its own class (inheriting from IEnumerable), so that I could have the Delete and Modify methods on it.