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

Refactor repo commit list #23690

Merged
merged 2 commits into from
Mar 27, 2023
Merged

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Mar 24, 2023

Before

  • The check of if PullRequest.BaseRepo.Name doesn't make sense, because the $commitLink is always constructed below
  • Many if blocks make the HTML tags (likely) not match in IDE. Although the rendered result matches, it's very unfriendly to editors or code analyzer, and it's difficult to read.

After

Move the $commitLink assignment ahead.

Simplify the code, resolve the above problems.

@codecov-commenter

This comment was marked as off-topic.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 24, 2023
@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 Mar 27, 2023
@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Mar 27, 2023
@lunny lunny added this to the 1.20.0 milestone Mar 27, 2023
Comment on lines +16 to +17
{{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}}

Copy link
Member

Choose a reason for hiding this comment

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

Why declare it so far above the first usage?
Why not below #34?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's not that far. The code block looks like this:

{{$commitLink:=....}}
<span class="ui float right shabox">{{$commitLink}}</span>  ## The Line 18
<span class="gt-mono commit-summar"..>{{$commitLink}}</span> ## The Line 50

So you can see that now commitLink is at the same level of other blocks.

If we put it below line 34, it would look like

<span class="ui float right shabox">
    {{$commitLink := ...}}
    {{$commitLink}}
</span>
<span class="gt-mono commit-summar"..>
    {{$commitLink}}
</span>

It looks like crossed the code blocks, it doesn't look good to me.

Comment on lines -33 to -36
{{if $.comment.Issue.PullRequest.BaseRepo.Name}}
<a href="{{$.comment.Issue.PullRequest.BaseRepo.Link}}/commit/{{PathEscape .ID.String}}" rel="nofollow" class="{{$class}}">
{{else}}
<span class="{{$class}}">
Copy link
Member

Choose a reason for hiding this comment

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

Under what condition was that block false?
I don't find any that makes sense, so I'd say this is a reasonable simplification…

@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 Mar 27, 2023
@delvh delvh added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 27, 2023
@zeripath zeripath merged commit ec261b6 into go-gitea:main Mar 27, 2023
@wxiaoguang wxiaoguang deleted the reformat-commit-list branch March 27, 2023 14:51
@lunny lunny removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 27, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 28, 2023
* upstream/main:
  Fix issue due date edit toggle bug (go-gitea#23723)
  Fix profile page email display, respect settings (go-gitea#23747)
  Update Gitea version in docs (go-gitea#23755)
  Fix SVG close tag, improve commit graph page UI alignment (go-gitea#23751)
  Remove incorrect HTML self close tag (go-gitea#23748)
  Refactor repo commit list (go-gitea#23690)
  Fix tags view (go-gitea#23243)
  Add commit info in action page (go-gitea#23210)
  Use GitHub Actions compatible globbing for `branches`, `tag`, `path` filter (go-gitea#22804)
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 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/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants