Skip to content

Commit f8ed9ea

Browse files
authored
Merge branch 'release/v1.23' into backport-testfixtures
2 parents 2064d07 + 74159a8 commit f8ed9ea

File tree

8 files changed

+96
-176
lines changed

8 files changed

+96
-176
lines changed

package-lock.json

Lines changed: 8 additions & 166 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"eslint": "8.57.0",
8787
"eslint-import-resolver-typescript": "3.7.0",
8888
"eslint-plugin-array-func": "4.0.0",
89-
"eslint-plugin-github": "5.1.3",
89+
"eslint-plugin-github": "5.0.2",
9090
"eslint-plugin-import-x": "4.5.0",
9191
"eslint-plugin-no-jquery": "3.1.0",
9292
"eslint-plugin-no-use-extend-native": "0.5.0",

templates/base/alert_details.tmpl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{{.Message}}
2+
{{if .Details}}
23
<details>
34
<summary>{{.Summary}}</summary>
4-
<code>
5-
{{.Details | SanitizeHTML}}
6-
</code>
5+
<code>{{.Details | SanitizeHTML}}</code>
76
</details>
7+
{{else}}
8+
<div>
9+
{{.Summary}}
10+
</div>
11+
{{end}}

templates/repo/commit_statuses.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{{if .Statuses}}
22
{{if and (eq (len .Statuses) 1) .Status.TargetURL}}
3-
<a class="tw-align-middle {{.AdditionalClasses}} tw-no-underline" data-tippy="commit-statuses" href="{{.Status.TargetURL}}">
3+
<a class="flex-text-inline tw-no-underline {{.AdditionalClasses}}" data-tippy="commit-statuses" href="{{.Status.TargetURL}}">
44
{{template "repo/commit_status" .Status}}
55
</a>
66
{{else}}
7-
<span class="tw-align-middle {{.AdditionalClasses}}" data-tippy="commit-statuses" tabindex="0">
7+
<span class="flex-text-inline {{.AdditionalClasses}}" data-tippy="commit-statuses" tabindex="0">
88
{{template "repo/commit_status" .Status}}
99
</span>
1010
{{end}}

templates/repo/issue/view_content/comments.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,9 @@
365365
{{if .Review}}{{$reviewType = .Review.Type}}{{end}}
366366
{{if not .OriginalAuthor}}
367367
{{/* Some timeline avatars need a offset to correctly align with their speech bubble.
368-
The condition depends on whether the comment has contents/attachments or reviews */}}
369-
<a class="timeline-avatar{{if or .Content .Attachments (and .Review .Review.CodeComments)}} timeline-avatar-offset{{end}}"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
368+
The condition depends on whether the comment has contents/attachments,
369+
review's comment is also controlled/rendered by issue comment's Content field */}}
370+
<a class="timeline-avatar{{if or .Content .Attachments}} timeline-avatar-offset{{end}}"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
370371
{{ctx.AvatarUtils.Avatar .Poster 40}}
371372
</a>
372373
{{end}}

templates/repo/latest_commit.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
33
{{else}}
44
{{if .LatestCommitUser}}
5-
{{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "tw-mr-1"}}
5+
{{ctx.AvatarUtils.Avatar .LatestCommitUser 24}}
66
{{if and .LatestCommitUser.FullName DefaultShowFullName}}
77
<a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
88
{{else}}
99
<a class="muted author-wrapper" title="{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
1010
{{end}}
1111
{{else}}
1212
{{if .LatestCommit.Author}}
13-
{{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24 "tw-mr-1"}}
13+
{{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}}
1414
<span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span>
1515
{{end}}
1616
{{end}}

tests/integration/pull_create_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strings"
1313
"testing"
1414

15+
auth_model "code.gitea.io/gitea/models/auth"
1516
"code.gitea.io/gitea/modules/git"
1617
"code.gitea.io/gitea/modules/test"
1718
"code.gitea.io/gitea/tests"
@@ -83,6 +84,30 @@ func testPullCreateDirectly(t *testing.T, session *TestSession, baseRepoOwner, b
8384
return resp
8485
}
8586

87+
func testPullCreateFailure(t *testing.T, session *TestSession, baseRepoOwner, baseRepoName, baseBranch, headRepoOwner, headRepoName, headBranch, title string) *httptest.ResponseRecorder {
88+
headCompare := headBranch
89+
if headRepoOwner != "" {
90+
if headRepoName != "" {
91+
headCompare = fmt.Sprintf("%s/%s:%s", headRepoOwner, headRepoName, headBranch)
92+
} else {
93+
headCompare = fmt.Sprintf("%s:%s", headRepoOwner, headBranch)
94+
}
95+
}
96+
req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/compare/%s...%s", baseRepoOwner, baseRepoName, baseBranch, headCompare))
97+
resp := session.MakeRequest(t, req, http.StatusOK)
98+
99+
// Submit the form for creating the pull
100+
htmlDoc := NewHTMLParser(t, resp.Body)
101+
link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action")
102+
assert.True(t, exists, "The template has changed")
103+
req = NewRequestWithValues(t, "POST", link, map[string]string{
104+
"_csrf": htmlDoc.GetCSRF(),
105+
"title": title,
106+
})
107+
resp = session.MakeRequest(t, req, http.StatusBadRequest)
108+
return resp
109+
}
110+
86111
func TestPullCreate(t *testing.T) {
87112
onGiteaRun(t, func(t *testing.T, u *url.URL) {
88113
session := loginUser(t, "user1")
@@ -245,3 +270,46 @@ func TestCreateAgitPullWithReadPermission(t *testing.T) {
245270
})
246271
})
247272
}
273+
274+
/*
275+
Setup: user2 has repository, user1 forks it
276+
---
277+
278+
1. User2 blocks User1
279+
2. User1 adds changes to fork
280+
3. User1 attempts to create a pull request
281+
4. User1 sees alert that the action is not allowed because of the block
282+
*/
283+
func TestCreatePullWhenBlocked(t *testing.T) {
284+
RepoOwner := "user2"
285+
ForkOwner := "user16"
286+
onGiteaRun(t, func(t *testing.T, u *url.URL) {
287+
// Setup
288+
// User1 forks repo1 from User2
289+
sessionFork := loginUser(t, ForkOwner)
290+
testRepoFork(t, sessionFork, RepoOwner, "repo1", ForkOwner, "forkrepo1", "")
291+
292+
// 1. User2 blocks user1
293+
// sessionBase := loginUser(t, "user2")
294+
token := getUserToken(t, RepoOwner, auth_model.AccessTokenScopeWriteUser)
295+
296+
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/blocks/%s", ForkOwner)).
297+
AddTokenAuth(token)
298+
MakeRequest(t, req, http.StatusNotFound)
299+
req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/user/blocks/%s", ForkOwner)).
300+
AddTokenAuth(token)
301+
MakeRequest(t, req, http.StatusNoContent)
302+
303+
// 2. User1 adds changes to fork
304+
testEditFile(t, sessionFork, ForkOwner, "forkrepo1", "master", "README.md", "Hello, World (Edited)\n")
305+
306+
// 3. User1 attempts to create a pull request
307+
testPullCreateFailure(t, sessionFork, RepoOwner, "repo1", "master", ForkOwner, "forkrepo1", "master", "This is a pull title")
308+
309+
// Teardown
310+
// Unblock user
311+
req = NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/user/blocks/%s", ForkOwner)).
312+
AddTokenAuth(token)
313+
MakeRequest(t, req, http.StatusNoContent)
314+
})
315+
}

web_src/css/repo.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ td .commit-summary {
120120
align-items: center;
121121
overflow: hidden;
122122
text-overflow: ellipsis;
123+
gap: 0.25em;
123124
}
124125

125126
@media (max-width: 767.98px) {
@@ -1701,6 +1702,10 @@ tbody.commit-list {
17011702
white-space: nowrap;
17021703
}
17031704

1705+
.latest-commit .message-wrapper {
1706+
max-width: calc(100% - 2.5rem);
1707+
}
1708+
17041709
/* in the commit list, messages can wrap so we can use inline */
17051710
.commit-list .message-wrapper {
17061711
display: inline;

0 commit comments

Comments
 (0)