Merge branch 'go-gitea:main' into pacman-packages

This commit is contained in:
Dancheg97 2023-07-09 12:34:07 +03:00 committed by GitHub
commit b5218eb4b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 793 additions and 374 deletions

View File

@ -22,7 +22,7 @@ plugins:
- eslint-plugin-wc
env:
es2022: true
es2024: true
node: true
overrides:
@ -156,7 +156,7 @@ rules:
import/no-restricted-paths: [0]
import/no-self-import: [2]
import/no-unassigned-import: [0]
import/no-unresolved: [2, {commonjs: true, ignore: ["\\?.+$"]}]
import/no-unresolved: [2, {commonjs: true, ignore: [\?.+$, ^vitest/]}]
import/no-unused-modules: [2, {unusedExports: true}]
import/no-useless-path-segments: [2, {commonjs: true}]
import/no-webpack-loader-syntax: [2]
@ -693,7 +693,7 @@ rules:
unicorn/prefer-dom-node-remove: [2]
unicorn/prefer-dom-node-text-content: [2]
unicorn/prefer-event-target: [2]
unicorn/prefer-export-from: [2, {ignoreUsedVariables: true}]
unicorn/prefer-export-from: [0]
unicorn/prefer-includes: [2]
unicorn/prefer-json-parse-buffer: [0]
unicorn/prefer-keyboard-event-key: [2]

View File

@ -119,7 +119,7 @@ services:
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
- "2222:2222"
+ depends_on:
+ - db
+

View File

@ -15,6 +15,8 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"xorm.io/builder"
)
// ErrBranchNotExist represents an error that branch with such name does not exist.
@ -378,3 +380,22 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to str
return committer.Commit()
}
// FindRecentlyPushedNewBranches return at most 2 new branches pushed by the user in 6 hours which has no opened PRs created
func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64) (BranchList, error) {
branches := make(BranchList, 0, 2)
subQuery := builder.Select("head_branch").From("pull_request").
InnerJoin("issue", "issue.id = pull_request.issue_id").
Where(builder.Eq{
"pull_request.head_repo_id": repoID,
"issue.is_closed": false,
})
err := db.GetEngine(ctx).
Where("pusher_id=? AND is_deleted=?", userID, false).
And("updated_unix >= ?", time.Now().Add(-time.Hour*6).Unix()).
NotIn("name", subQuery).
OrderBy("branch.updated_unix DESC").
Limit(2).
Find(&branches)
return branches, err
}

View File

@ -528,6 +528,18 @@ func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) strin
return fmt.Sprintf("%s/%s/compare/%s...%s", url.PathEscape(repo.OwnerName), url.PathEscape(repo.Name), util.PathEscapeSegments(oldCommitID), util.PathEscapeSegments(newCommitID))
}
func (repo *Repository) ComposeBranchCompareURL(baseRepo *Repository, branchName string) string {
if baseRepo == nil {
baseRepo = repo
}
var cmpBranchEscaped string
if repo.ID != baseRepo.ID {
cmpBranchEscaped = fmt.Sprintf("%s/%s:", url.PathEscape(repo.OwnerName), url.PathEscape(repo.Name))
}
cmpBranchEscaped = fmt.Sprintf("%s%s", cmpBranchEscaped, util.PathEscapeSegments(branchName))
return fmt.Sprintf("%s/compare/%s...%s", baseRepo.Link(), util.PathEscapeSegments(baseRepo.DefaultBranch), cmpBranchEscaped)
}
// IsOwnedBy returns true when user owns this repository
func (repo *Repository) IsOwnedBy(userID int64) bool {
return repo.OwnerID == userID

View File

@ -1767,6 +1767,8 @@ pulls.auto_merge_canceled_schedule_comment = `canceled auto merging this pull re
pulls.delete.title = Delete this pull request?
pulls.delete.text = Do you really want to delete this pull request? (This will permanently remove all content. Consider closing it instead, if you intend to keep it archived)
pulls.recently_pushed_new_branches = You pushed on branch <strong>%[1]s</strong> %[2]s
milestones.new = New Milestone
milestones.closed = Closed %s
milestones.update_ago = Updated %s

997
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,16 +24,16 @@
"easymde": "2.18.0",
"esbuild-loader": "3.0.1",
"escape-goat": "4.0.0",
"fast-glob": "3.2.12",
"fast-glob": "3.3.0",
"jquery": "3.7.0",
"jquery.are-you-sure": "1.9.0",
"katex": "0.16.8",
"license-checker-webpack-plugin": "0.2.1",
"lightningcss-loader": "2.1.0",
"mermaid": "10.2.3",
"mermaid": "10.2.4",
"mini-css-extract-plugin": "2.7.6",
"minimatch": "9.0.2",
"monaco-editor": "0.39.0",
"minimatch": "9.0.3",
"monaco-editor": "0.40.0",
"monaco-editor-webpack-plugin": "7.0.1",
"pdfobject": "2.2.12",
"pretty-ms": "8.0.0",
@ -48,17 +48,16 @@
"vue-bar-graph": "2.0.0",
"vue-loader": "17.2.2",
"vue3-calendar-heatmap": "2.0.5",
"webpack": "5.88.0",
"webpack": "5.88.1",
"webpack-cli": "5.1.4",
"wrap-ansi": "8.1.0"
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "3.2.1",
"@playwright/test": "1.35.1",
"@rollup/pluginutils": "5.0.2",
"@stoplight/spectral-cli": "6.8.0",
"@vitejs/plugin-vue": "4.2.3",
"eslint": "8.43.0",
"eslint": "8.44.0",
"eslint-plugin-array-func": "3.1.8",
"eslint-plugin-custom-elements": "0.0.8",
"eslint-plugin-import": "2.27.5",
@ -78,8 +77,9 @@
"stylelint-declaration-strict-value": "1.9.2",
"stylelint-stylistic": "0.4.2",
"svgo": "3.0.2",
"updates": "14.2.8",
"vitest": "0.32.2"
"updates": "14.3.2",
"vite-string-plugin": "1.1.0",
"vitest": "0.33.0"
},
"browserslist": [
"defaults",

View File

@ -977,6 +977,18 @@ func renderCode(ctx *context.Context) {
return
}
if ctx.Doer != nil {
if err := ctx.Repo.Repository.GetBaseRepo(ctx); err != nil {
ctx.ServerError("GetBaseRepo", err)
return
}
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID)
if err != nil {
ctx.ServerError("GetRecentlyPushedBranches", err)
return
}
}
var treeNames []string
paths := make([]string, 0, 5)
if len(ctx.Repo.TreePath) > 0 {

View File

@ -1,5 +1,5 @@
{{if .CanWriteProjects}}
<div class="gt-tr">
<div class="gt-text-right">
<a class="ui small green button" href="{{$.Link}}/new">{{.locale.Tr "repo.projects.new"}}</a>
</div>
<div class="divider"></div>

View File

@ -33,7 +33,7 @@
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
<button class="btn interact-bg show-create-branch-modal gt-p-3"
data-modal="#create-branch-modal"
data-branch-from="{{$.DefaultBranchBranch}}"
data-branch-from="{{$.DefaultBranchBranch.DBBranch.Name}}"
data-branch-from-urlcomponent="{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}"
data-tooltip-content="{{$.locale.Tr "repo.branch.new_branch_from" ($.DefaultBranchBranch.DBBranch.Name)}}"
>

View File

@ -9,7 +9,7 @@
SSH
</button>
{{end}}
<input id="repo-clone-url" size="20" class="js-clone-url gt-br-0" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
<input id="repo-clone-url" size="20" class="js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
<button class="ui basic small compact icon button" id="clipboard-btn" data-tooltip-content="{{.locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url" aria-label="{{.locale.Tr "copy_url"}}">
{{svg "octicon-copy" 14}}
</button>

View File

@ -0,0 +1,11 @@
{{range .RecentlyPushedNewBranches}}
<div class="ui positive message gt-df gt-ac">
<div class="gt-f1">
{{$timeSince := TimeSince .UpdatedUnix.AsTime $.locale}}
{{$.locale.Tr "repo.pulls.recently_pushed_new_branches" (PathEscapeSegments .Name) $timeSince | Safe}}
</div>
<a aria-role="button" class="ui compact positive button gt-m-0" href="{{$.Repository.ComposeBranchCompareURL $.Repository.BaseRepo (PathEscapeSegments .Name)}}">
{{$.locale.Tr "repo.pulls.compare_changes"}}
</a>
</div>
{{end}}

View File

@ -189,7 +189,7 @@
</div>
</div>
{{if .Commit.Signature}}
<div class="ui bottom attached message gt-tl gt-df gt-ac gt-sb commit-header-row gt-fw {{$class}}">
<div class="ui bottom attached message gt-text-left gt-df gt-ac gt-sb commit-header-row gt-fw {{$class}}">
<div class="gt-df gt-ac">
{{if .Verification.Verified}}
{{if ne .Verification.SigningUser.ID 0}}

View File

@ -214,7 +214,7 @@
<button class="ui button green show-form">{{.locale.Tr "repo.pulls.new"}}</button>
</div>
{{else if .Repository.IsArchived}}
<div class="ui warning message">
<div class="ui warning message gt-text-center">
{{if .Repository.ArchivedUnix.IsZero}}
{{.locale.Tr "repo.archive.title"}}
{{else}}

View File

@ -6,7 +6,7 @@
<div class="sixteen wide column content">
{{template "base/alert" .}}
{{if .Repository.IsArchived}}
<div class="ui warning message">
<div class="ui warning message gt-text-center">
{{if .Repository.ArchivedUnix.IsZero}}
{{.locale.Tr "repo.archive.title"}}
{{else}}

View File

@ -121,7 +121,7 @@
<div class="header">
{{$.locale.Tr "repo.already_forked" .Name}}
</div>
<div class="content gt-tl">
<div class="content gt-text-left">
<div class="ui list">
{{range $.UserAndOrgForks}}
<div class="ui item gt-py-3">

View File

@ -3,6 +3,7 @@
{{template "repo/header" .}}
<div class="ui container {{if .IsBlame}}fluid padded{{end}}">
{{template "base/alert" .}}
{{template "repo/code/recently_pushed_new_branches" .}}
{{if and (not .HideRepoInfo) (not .IsBlame)}}
<div class="ui repo-description">
<div id="repo-desc">
@ -28,9 +29,9 @@
</div>
{{end}}
</div>
<div class="gt-df gt-ac gt-fw gt-mt-3" id="repo-topics">
{{range .Topics}}<a class="ui repo-topic large label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}}
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}<button id="manage_topic" class="btn interact-fg gt-ml-2 gt-font-12">{{.locale.Tr "repo.topic.manage_topics"}}</button>{{end}}
<div class="gt-df gt-ac gt-fw gt-gap-2" id="repo-topics">
{{range .Topics}}<a class="ui repo-topic large label topic gt-m-0" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}}
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}<button id="manage_topic" class="btn interact-fg gt-font-12">{{.locale.Tr "repo.topic.manage_topics"}}</button>{{end}}
</div>
{{end}}
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
@ -52,7 +53,7 @@
</div>
{{end}}
{{if .Repository.IsArchived}}
<div class="ui warning message">
<div class="ui warning message gt-text-center">
{{if .Repository.ArchivedUnix.IsZero}}
{{.locale.Tr "repo.archive.title"}}
{{else}}

View File

@ -125,7 +125,7 @@
</div>
</div>
{{else if .Repository.IsArchived}}
<div class="ui warning message">
<div class="ui warning message gt-text-center">
{{if .Issue.IsPull}}
{{.locale.Tr "repo.archive.pull.nocomment"}}
{{else}}
@ -135,7 +135,7 @@
{{end}}
{{else}} {{/* not .IsSigned */}}
{{if .Repository.IsArchived}}
<div class="ui warning message">
<div class="ui warning message gt-text-center">
{{if .Issue.IsPull}}
{{.locale.Tr "repo.archive.pull.nocomment"}}
{{else}}

View File

@ -16,10 +16,10 @@
{{svg (printf "gitea-%s" .Name) 184}}
{{end}}
<div class="content">
<div class="header gt-tc">
<div class="header gt-text-center">
{{.Title}}
</div>
<div class="description gt-tc">
<div class="description gt-text-center">
{{(printf "repo.migrate.%s.description" .Name) | $.locale.Tr}}
</div>
</div>

View File

@ -1,7 +1,7 @@
{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit")}}
<div class="repo-setting-content">
{{if .Repository.IsArchived}}
<div class="ui warning message">
<div class="ui warning message gt-text-center">
{{.locale.Tr "repo.settings.archive.branchsettings_unavailable"}}
</div>
{{else}}

View File

@ -1,7 +1,7 @@
{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit")}}
<div class="repo-setting-content">
{{if .Repository.IsArchived}}
<div class="ui warning message">
<div class="ui warning message gt-text-center">
{{.locale.Tr "repo.settings.archive.tagsettings_unavailable"}}
</div>
{{else}}

View File

@ -1,6 +1,6 @@
{{if .EscapeStatus}}
{{if .EscapeStatus.HasInvisible}}
<div class="ui error message unicode-escape-prompt gt-tl">
<div class="ui error message unicode-escape-prompt gt-text-left">
<button class="close icon hide-panel button" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
<div class="header">
{{$.root.locale.Tr "repo.invisible_runes_header"}}
@ -11,7 +11,7 @@
{{end}}
</div>
{{else if .EscapeStatus.HasAmbiguous}}
<div class="ui warning message unicode-escape-prompt gt-tl">
<div class="ui warning message unicode-escape-prompt gt-text-left">
<button class="close icon hide-panel button" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button>
<div class="header">
{{$.root.locale.Tr "repo.ambiguous_runes_header"}}

View File

@ -22,7 +22,7 @@
<div id="captcha" data-captcha-type="m-captcha" class="m-captcha" data-sitekey="{{.McaptchaSitekey}}" data-instance-url="{{.McaptchaURL}}"></div>
</div>
{{else if eq .CaptchaType "cfturnstile"}}
<div class="inline field captcha-field gt-tc">
<div class="inline field captcha-field gt-text-center">
<div id="captcha" data-captcha-type="cf-turnstile" data-sitekey="{{.CfTurnstileSitekey}}"></div>
</div>
{{end}}{{end}}

View File

@ -120,9 +120,9 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) {
req := NewRequest(t, "GET", redirectURL)
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Equal(t,
test.FlashMessage,
assert.Contains(t,
strings.TrimSpace(htmlDoc.doc.Find(".ui.message").Text()),
test.FlashMessage,
)
}
}

View File

@ -1,20 +1,6 @@
import {defineConfig} from 'vitest/dist/config.js';
import {readFile} from 'node:fs/promises';
import {dataToEsm} from '@rollup/pluginutils';
import {extname} from 'node:path';
import vue from '@vitejs/plugin-vue';
function stringPlugin() {
return {
name: 'string-plugin',
enforce: 'pre',
async load(id) {
const path = id.split('?')[0];
if (extname(path) !== '.svg') return null;
return dataToEsm(await readFile(path, 'utf8'));
}
};
}
import {defineConfig} from 'vitest/config';
import vuePlugin from '@vitejs/plugin-vue';
import {stringPlugin} from 'vite-string-plugin';
export default defineConfig({
test: {
@ -26,10 +12,9 @@ export default defineConfig({
allowOnly: true,
passWithNoTests: true,
watch: false,
outputDiffLines: Infinity,
},
plugins: [
stringPlugin(),
vue(),
vuePlugin(),
],
});

View File

@ -8,10 +8,6 @@ Gitea's private styles use `g-` prefix.
.gt-dif { display: inline-flex !important; }
.gt-dib { display: inline-block !important; }
.gt-ac { align-items: center !important; }
.gt-ab { align-items: baseline !important; }
.gt-tc { text-align: center !important; }
.gt-tl { text-align: left !important; }
.gt-tr { text-align: right !important; } /* TODO: rename these to "gt-text-right", etc. there are only a few */
.gt-jc { justify-content: center !important; }
.gt-js { justify-content: flex-start !important; }
.gt-je { justify-content: flex-end !important; }
@ -22,7 +18,6 @@ Gitea's private styles use `g-` prefix.
.gt-vm { vertical-align: middle !important; }
.gt-w-100 { width: 100% !important; }
.gt-h-100 { height: 100% !important; }
.gt-br-0 { border-radius: 0 !important; }
.gt-mono {
font-family: var(--fonts-monospace) !important;
@ -90,6 +85,10 @@ Gitea's private styles use `g-` prefix.
.gt-float-right { float: right !important; }
.gt-clear-both { clear: both !important; }
.gt-text-center { text-align: center !important; }
.gt-text-left { text-align: left !important; }
.gt-text-right { text-align: right !important; }
.gt-font-light { font-weight: var(--font-weight-light) !important; }
.gt-font-normal { font-weight: var(--font-weight-normal) !important; }
.gt-font-medium { font-weight: var(--font-weight-medium) !important; }

View File

@ -190,6 +190,7 @@
.repository #clone-panel #repo-clone-url {
width: 320px;
border-radius: 0;
}
@media (min-width: 768px) and (max-width: 991.98px) {
@ -230,6 +231,7 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
}
@media (max-width: 767.68px) {
@ -2655,7 +2657,7 @@
height: 30px;
}
.repo-button-row .button.dropdown {
.repo-button-row .button.dropdown:not(.icon) {
padding-right: 22px !important; /* normal buttons have !important paddings, so we need to override it for dropdown (Add File) icons */
}
@ -2776,7 +2778,6 @@ tbody.commit-list {
#repo-topics .repo-topic {
font-weight: var(--font-weight-normal);
cursor: pointer;
margin: 2px;
}
#new-dependency-drop-list.ui.selection.dropdown {

View File

@ -237,7 +237,7 @@ export function initGlobalDropzone() {
// Create a "Copy Link" element, to conveniently copy the image
// or file link as Markdown to the clipboard
const copyLinkElement = document.createElement('div');
copyLinkElement.className = 'gt-tc';
copyLinkElement.className = 'gt-text-center';
// The a element has a hardcoded cursor: pointer because the default is overridden by .dropzone
copyLinkElement.innerHTML = `<a href="#" style="cursor: pointer;">${svg('octicon-copy', 14, 'copy link')} Copy link</a>`;
copyLinkElement.addEventListener('click', (e) => {

View File

@ -24,7 +24,7 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
</div>
</div>
</div>
<div class="comment-diff-data gt-tl gt-p-3 is-loading"></div>
<div class="comment-diff-data gt-text-left gt-p-3 is-loading"></div>
</div>`);
$dialog.appendTo($('body'));
$dialog.find('.dialog-header-options').dropdown({