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

Show git-notes #6984

Merged
merged 13 commits into from
May 24, 2019
Merged

Show git-notes #6984

merged 13 commits into from
May 24, 2019

Conversation

CyberShadow
Copy link
Contributor

This PR implements basic support for displaying notes created by git notes (or software supporting it, such as magit).

The notes are read from Git's default ref location (refs/notes/commits), and thus it is assumed that the ref is pushed at that location to Gitea.

The implementation here is minimal; if the idea is OK, I can do any necessary changes.

@CyberShadow CyberShadow force-pushed the show-git-notes branch 3 times, most recently from 434c841 to 5b8e243 Compare May 19, 2019 02:21
@codecov-io
Copy link

codecov-io commented May 19, 2019

Codecov Report

Merging #6984 into master will decrease coverage by <.01%.
The diff coverage is 29.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6984      +/-   ##
==========================================
- Coverage   41.49%   41.49%   -0.01%     
==========================================
  Files         440      441       +1     
  Lines       59459    59507      +48     
==========================================
+ Hits        24674    24692      +18     
- Misses      31566    31589      +23     
- Partials     3219     3226       +7
Impacted Files Coverage Δ
routers/repo/commit.go 24.23% <0%> (-0.77%) ⬇️
modules/templates/helper.go 47.35% <0%> (-1.08%) ⬇️
modules/git/notes.go 43.75% <43.75%> (ø)
models/repo_list.go 73.09% <0%> (+1.01%) ⬆️
models/unit.go 67.56% <0%> (+5.4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5a98a2...dcbef74. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 19, 2019
@lunny
Copy link
Member

lunny commented May 19, 2019

Any screenshot? And could you change the text on template to locale_en_US.ini?

@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label May 19, 2019
@lafriks lafriks added this to the 1.9.0 milestone May 19, 2019
@zeripath
Copy link
Contributor

I like the idea of this - however, is there any way to avoid reading the whole thing in memory and or making the page too big to render?

How about test the size of the note - if it's less than say 5Kb (most notes will be) then read it in otherwise provide a link that that the UI can asynchronously read. You can stick that as an API route and then you can test the note reading infrastructure relatively easy.

I think in general we should be more careful around ReadAll and page sizes.

@CyberShadow
Copy link
Contributor Author

Any screenshot?

Sure:

Although git displays notes directly beneath commit messages, I opted to place the notes outside the commit box in Gitea's UI, because their authorship is not tied to the commit's author/committer. Placing them right by the commit message would make it look like they were written by the same person as the rest of the commit.

And could you change the text on template to locale_en_US.ini?

Done.

I like the idea of this - however, is there any way to avoid reading the whole thing in memory and or making the page too big to render?

Sorry, could you please explain why you think this is necessary?

As far as I know, the typical use of git-notes is editable additions to commit messages. The git-notes manual states this as well, so, there's the implication that notes and commit messages shouldn't be treated too differently. I'm not familiar of a use case for git-notes which would involve placing large amounts of data in the notes objects.

Even though it's possible to create arbitrarily large git notes, it's also possible to create arbitrarily large commit messages. As far as I can see, Gitea will always display the entire commit message, without limiting it, and without providing a view to see it in its entirety. So, it doesn't make sense to me to do this for git notes without also doing it for commit messages, considering that there don't seem to be any pertinent distinctions between the two.

routers/repo/commit.go Outdated Show resolved Hide resolved
@lunny
Copy link
Member

lunny commented May 20, 2019

Could you display the author and time of the git note?

@CyberShadow
Copy link
Contributor Author

I think it's possible, by looking at the last commit in the notes ref history which updated the note's path.

Note that it would be more accurate to say that it would be the person who last edited the note, since if you want to add a note to a commit and a note already exists for that commit, you have no choice but to edit the existing note.

@CyberShadow
Copy link
Contributor Author

Could you display the author and time of the git note?

Done, how does this look?

@lafriks
Copy link
Member

lafriks commented May 21, 2019

Could this be added in frame together with commit message?

@CyberShadow
Copy link
Contributor Author

Something like this?

It doesn't look good in the dark theme, will likely need new CSS rules there.

@sapk
Copy link
Member

sapk commented May 21, 2019

AFAIK, notes are not signed by gpg so maybe it is better to display them under the signature.

@CyberShadow
Copy link
Contributor Author

CyberShadow commented May 21, 2019

You certainly can sign the notes (by making signed commits in the notes ref), but that's a completely distinct signature from the commit that the notes are annotating.

Edit: You're right, git-notes does not sign commits made in the notes ref even when commit signing is otherwise enabled, so this is not a circumstance that we need to worry about.

Copy link
Member

@sapk sapk left a comment

Choose a reason for hiding this comment

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

This PR could be improved by :

  • Filtering display of big note that could break ui
  • Add tests to validate GetNote func
  • Displaying that a note exist (like gpg lock) in commit list and a preview on passing over
  • I personally would prefer to display notes like GPG. Attached to the commit block to display that it is linked but under GPG (since itsn't verifed by it)

But this lay down some simple bases that works and could be improved later. And since it is not a main feature those changes are not blocking from my point of view. LGTM

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 21, 2019
@CyberShadow
Copy link
Contributor Author

Filtering display of big note that could break ui

I think that if we do this, it should also be done for commit messages.

Add tests to validate GetNote func

Test added :)

Displaying that a note exist (like gpg lock) in commit list and a preview on passing over

Good idea, I may submit a follow-up PR adding this.

I personally would prefer to display notes like GPG. Attached to the commit block to display that it is linked but under GPG (since itsn't verifed by it)

Do you have a mockup of your idea? Would it be essentially as the second screenshot I posted but without the gap between the blocks?

@sapk
Copy link
Member

sapk commented May 21, 2019

It should also be done for commit messages.

Yes but that is for an other PR. It could be good to do it directly for notes but that isn't a blocking point (at least for me) as I suppose that people using note will understand and it could be fixed later.

Do you have a mockup of your idea?

I have done some testing here : sapk-fork@2f453e7
image
The main problem is that bottom class style does a lot to the GPG commit formatting. For testing I had to use inline css to counter that. The closest class would be ui attached block header.
I suggest you to not take time on this until other people validate that they prefer this way ;-)

@lafriks
Copy link
Member

lafriks commented May 21, 2019

Yes I was thinking about something like what @sapk did

@CyberShadow
Copy link
Contributor Author

I like what you did with the header so I adapted that:

dark
light

I am not sure about gluing the note block to the commit block, for two reasons:

  1. I think it looks a bit too clumped-up, it's not obvious to me at a first glance where the information about the commit ends and information about the note begins.
  2. Hypothetically, a repository can contain multiple refs storing git notes. These can be due to having been written by different authors, or generated by different tools. It's possible that in the future users of Gitea might want to show notes from more than one ref (e.g. by having a list of refs as a per-repository config); in this case there probably should be one bubble per notes ref containing a note for the commit.

Of course you have the final word :)

@techknowlogick
Copy link
Member

@CyberShadow I like what you did in the screenshots, as it will allow showing that notes are GPG signed similar to how commits are (to be done in a future PR of course).

@lafriks
Copy link
Member

lafriks commented May 23, 2019

This looks really nice now

routers/repo/commit.go Outdated Show resolved Hide resolved
routers/repo/commit.go Outdated Show resolved Hide resolved
@lafriks
Copy link
Member

lafriks commented May 23, 2019

Those two small suggestions but otherwise looks good

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 24, 2019
@lafriks lafriks merged commit a98e085 into go-gitea:master May 24, 2019
@lafriks lafriks added the type/changelog Adds the changelog for a new Gitea version label May 24, 2019
@lafriks
Copy link
Member

lafriks commented May 24, 2019

Thanks for PR ;)

jeffliu27 pushed a commit to jeffliu27/gitea that referenced this pull request Jul 18, 2019
* Show git-notes

* Make git-notes heading text localizable

* Refactor git-notes data fetching to a separate function

* Display the author and time of git notes

* Move note bubble inside the commit bubble

* Revert "Move note bubble inside the commit bubble"

This reverts commit c0951fe.

* Add test for git-notes

* testing ui

* Polish CSS

* Apply suggestions from code review

Co-Authored-By: Lauris BH <lauris@nix.lv>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants