0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-28 08:23:02 +01:00

Merge branch 'main' into lunny/add_line_through_deleted_branch

This commit is contained in:
Lunny Xiao 2024-11-14 11:05:46 -08:00
commit c9f3fa758f
19 changed files with 45 additions and 24 deletions

View file

@ -261,6 +261,7 @@ func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID strin
} }
// InsertRun inserts a run // InsertRun inserts a run
// The title will be cut off at 255 characters if it's longer than 255 characters.
func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWorkflow) error { func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWorkflow) error {
ctx, committer, err := db.TxContext(ctx) ctx, committer, err := db.TxContext(ctx)
if err != nil { if err != nil {
@ -273,6 +274,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
return err return err
} }
run.Index = index run.Index = index
run.Title, _ = util.SplitStringAtByteN(run.Title, 255)
if err := db.Insert(ctx, run); err != nil { if err := db.Insert(ctx, run); err != nil {
return err return err
@ -399,6 +401,7 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
if len(cols) > 0 { if len(cols) > 0 {
sess.Cols(cols...) sess.Cols(cols...)
} }
run.Title, _ = util.SplitStringAtByteN(run.Title, 255)
affected, err := sess.Update(run) affected, err := sess.Update(run)
if err != nil { if err != nil {
return err return err

View file

@ -252,6 +252,7 @@ func GetRunnerByID(ctx context.Context, id int64) (*ActionRunner, error) {
// UpdateRunner updates runner's information. // UpdateRunner updates runner's information.
func UpdateRunner(ctx context.Context, r *ActionRunner, cols ...string) error { func UpdateRunner(ctx context.Context, r *ActionRunner, cols ...string) error {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
r.Name, _ = util.SplitStringAtByteN(r.Name, 255)
var err error var err error
if len(cols) == 0 { if len(cols) == 0 {
_, err = e.ID(r.ID).AllCols().Update(r) _, err = e.ID(r.ID).AllCols().Update(r)
@ -278,6 +279,7 @@ func CreateRunner(ctx context.Context, t *ActionRunner) error {
// Remove OwnerID to avoid confusion; it's not worth returning an error here. // Remove OwnerID to avoid confusion; it's not worth returning an error here.
t.OwnerID = 0 t.OwnerID = 0
} }
t.Name, _ = util.SplitStringAtByteN(t.Name, 255)
return db.Insert(ctx, t) return db.Insert(ctx, t)
} }

View file

@ -12,6 +12,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo" repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
webhook_module "code.gitea.io/gitea/modules/webhook" webhook_module "code.gitea.io/gitea/modules/webhook"
) )
@ -67,6 +68,7 @@ func CreateScheduleTask(ctx context.Context, rows []*ActionSchedule) error {
// Loop through each schedule row // Loop through each schedule row
for _, row := range rows { for _, row := range rows {
row.Title, _ = util.SplitStringAtByteN(row.Title, 255)
// Create new schedule row // Create new schedule row
if err = db.Insert(ctx, row); err != nil { if err = db.Insert(ctx, row); err != nil {
return err return err

View file

@ -21,6 +21,7 @@ import (
"code.gitea.io/gitea/modules/references" "code.gitea.io/gitea/modules/references"
api "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"xorm.io/builder" "xorm.io/builder"
) )
@ -138,6 +139,7 @@ func ChangeIssueTitle(ctx context.Context, issue *Issue, doer *user_model.User,
} }
defer committer.Close() defer committer.Close()
issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
if err = UpdateIssueCols(ctx, issue, "name"); err != nil { if err = UpdateIssueCols(ctx, issue, "name"); err != nil {
return fmt.Errorf("updateIssueCols: %w", err) return fmt.Errorf("updateIssueCols: %w", err)
} }
@ -386,6 +388,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
} }
// NewIssue creates new issue with labels for repository. // NewIssue creates new issue with labels for repository.
// The title will be cut off at 255 characters if it's longer than 255 characters.
func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *Issue, labelIDs []int64, uuids []string) (err error) { func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *Issue, labelIDs []int64, uuids []string) (err error) {
ctx, committer, err := db.TxContext(ctx) ctx, committer, err := db.TxContext(ctx)
if err != nil { if err != nil {
@ -399,6 +402,7 @@ func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *Issue, la
} }
issue.Index = idx issue.Index = idx
issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
if err = NewIssueWithIndex(ctx, issue.Poster, NewIssueOptions{ if err = NewIssueWithIndex(ctx, issue.Poster, NewIssueOptions{
Repo: repo, Repo: repo,

View file

@ -572,6 +572,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *Iss
} }
issue.Index = idx issue.Index = idx
issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
if err = NewIssueWithIndex(ctx, issue.Poster, NewIssueOptions{ if err = NewIssueWithIndex(ctx, issue.Poster, NewIssueOptions{
Repo: repo, Repo: repo,

View file

@ -242,6 +242,7 @@ func GetSearchOrderByBySortType(sortType string) db.SearchOrderBy {
} }
// NewProject creates a new Project // NewProject creates a new Project
// The title will be cut off at 255 characters if it's longer than 255 characters.
func NewProject(ctx context.Context, p *Project) error { func NewProject(ctx context.Context, p *Project) error {
if !IsTemplateTypeValid(p.TemplateType) { if !IsTemplateTypeValid(p.TemplateType) {
p.TemplateType = TemplateTypeNone p.TemplateType = TemplateTypeNone
@ -255,6 +256,8 @@ func NewProject(ctx context.Context, p *Project) error {
return util.NewInvalidArgumentErrorf("project type is not valid") return util.NewInvalidArgumentErrorf("project type is not valid")
} }
p.Title, _ = util.SplitStringAtByteN(p.Title, 255)
return db.WithTx(ctx, func(ctx context.Context) error { return db.WithTx(ctx, func(ctx context.Context) error {
if err := db.Insert(ctx, p); err != nil { if err := db.Insert(ctx, p); err != nil {
return err return err
@ -308,6 +311,7 @@ func UpdateProject(ctx context.Context, p *Project) error {
p.CardType = CardTypeTextOnly p.CardType = CardTypeTextOnly
} }
p.Title, _ = util.SplitStringAtByteN(p.Title, 255)
_, err := db.GetEngine(ctx).ID(p.ID).Cols( _, err := db.GetEngine(ctx).ID(p.ID).Cols(
"title", "title",
"description", "description",

View file

@ -156,6 +156,7 @@ func IsReleaseExist(ctx context.Context, repoID int64, tagName string) (bool, er
// UpdateRelease updates all columns of a release // UpdateRelease updates all columns of a release
func UpdateRelease(ctx context.Context, rel *Release) error { func UpdateRelease(ctx context.Context, rel *Release) error {
rel.Title, _ = util.SplitStringAtByteN(rel.Title, 255)
_, err := db.GetEngine(ctx).ID(rel.ID).AllCols().Update(rel) _, err := db.GetEngine(ctx).ID(rel.ID).AllCols().Update(rel)
return err return err
} }

View file

@ -142,6 +142,7 @@ func CreateRelease(gitRepo *git.Repository, rel *repo_model.Release, attachmentU
return err return err
} }
rel.Title, _ = util.SplitStringAtByteN(rel.Title, 255)
rel.LowerTagName = strings.ToLower(rel.TagName) rel.LowerTagName = strings.ToLower(rel.TagName)
if err = db.Insert(gitRepo.Ctx, rel); err != nil { if err = db.Insert(gitRepo.Ctx, rel); err != nil {
return err return err

View file

@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import {createApp, nextTick} from 'vue'; import {createApp, nextTick} from 'vue';
import $ from 'jquery';
import {SvgIcon} from '../svg.ts'; import {SvgIcon} from '../svg.ts';
import {GET} from '../modules/fetch.ts'; import {GET} from '../modules/fetch.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
const {appSubUrl, assetUrlPrefix, pageData} = window.config; const {appSubUrl, assetUrlPrefix, pageData} = window.config;
@ -102,7 +102,7 @@ const sfc = {
mounted() { mounted() {
const el = document.querySelector('#dashboard-repo-list'); const el = document.querySelector('#dashboard-repo-list');
this.changeReposFilter(this.reposFilter); this.changeReposFilter(this.reposFilter);
$(el).find('.dropdown').dropdown(); fomanticQuery(el.querySelector('.ui.dropdown')).dropdown();
nextTick(() => { nextTick(() => {
this.$refs.search.focus(); this.$refs.search.focus();
}); });

View file

@ -21,7 +21,7 @@ import {
import {chartJsColors} from '../utils/color.ts'; import {chartJsColors} from '../utils/color.ts';
import {sleep} from '../utils.ts'; import {sleep} from '../utils.ts';
import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm'; import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
import $ from 'jquery'; import {fomanticQuery} from '../modules/fomantic/base.ts';
const customEventListener = { const customEventListener = {
id: 'customEventListener', id: 'customEventListener',
@ -77,7 +77,7 @@ export default {
mounted() { mounted() {
this.fetchGraphData(); this.fetchGraphData();
$('#repo-contributors').dropdown({ fomanticQuery('#repo-contributors').dropdown({
onChange: (val) => { onChange: (val) => {
this.xAxisMin = this.xAxisStart; this.xAxisMin = this.xAxisStart;
this.xAxisMax = this.xAxisEnd; this.xAxisMax = this.xAxisEnd;

View file

@ -1,5 +1,5 @@
import $ from 'jquery';
import {getCurrentLocale} from '../utils.ts'; import {getCurrentLocale} from '../utils.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
const {pageData} = window.config; const {pageData} = window.config;
@ -71,6 +71,6 @@ export async function initCitationFileCopyContent() {
dropdownBtn.classList.remove('is-loading'); dropdownBtn.classList.remove('is-loading');
} }
$('#cite-repo-modal').modal('show'); fomanticQuery('#cite-repo-modal').modal('show');
}); });
} }

View file

@ -1,13 +1,12 @@
import $ from 'jquery'; import {applyAreYouSure, initAreYouSure} from '../vendor/jquery.are-you-sure.ts';
import {initAreYouSure} from '../vendor/jquery.are-you-sure.ts';
import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.ts'; import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.ts';
export function initGlobalFormDirtyLeaveConfirm() { export function initGlobalFormDirtyLeaveConfirm() {
initAreYouSure(window.jQuery); initAreYouSure(window.jQuery);
// Warn users that try to leave a page after entering data into a form. // Warn users that try to leave a page after entering data into a form.
// Except on sign-in pages, and for forms marked as 'ignore-dirty'. // Except on sign-in pages, and for forms marked as 'ignore-dirty'.
if (!$('.user.signin').length) { if (!document.querySelector('.page-content.user.signin')) {
$('form:not(.ignore-dirty)').areYouSure(); applyAreYouSure('form:not(.ignore-dirty)');
} }
} }

View file

@ -1,7 +1,7 @@
import $ from 'jquery';
import {svg} from '../../svg.ts'; import {svg} from '../../svg.ts';
import {htmlEscape} from 'escape-goat'; import {htmlEscape} from 'escape-goat';
import {createElementFromHTML} from '../../utils/dom.ts'; import {createElementFromHTML} from '../../utils/dom.ts';
import {fomanticQuery} from '../../modules/fomantic/base.ts';
const {i18n} = window.config; const {i18n} = window.config;
@ -17,7 +17,7 @@ export function confirmModal(content, {confirmButtonColor = 'primary'} = {}) {
</div> </div>
`); `);
document.body.append(modal); document.body.append(modal);
const $modal = $(modal); const $modal = fomanticQuery(modal);
$modal.modal({ $modal.modal({
onApprove() { onApprove() {
resolve(true); resolve(true);

View file

@ -1,5 +1,5 @@
import $ from 'jquery';
import {POST} from '../../modules/fetch.ts'; import {POST} from '../../modules/fetch.ts';
import {fomanticQuery} from '../../modules/fomantic/base.ts';
export function initCompReactionSelector() { export function initCompReactionSelector() {
for (const container of document.querySelectorAll('.issue-content, .diff-file-body')) { for (const container of document.querySelectorAll('.issue-content, .diff-file-body')) {
@ -29,7 +29,7 @@ export function initCompReactionSelector() {
if (data.html) { if (data.html) {
commentContainer.insertAdjacentHTML('beforeend', data.html); commentContainer.insertAdjacentHTML('beforeend', data.html);
const bottomReactionsDropdowns = commentContainer.querySelectorAll('.bottom-reactions .dropdown.select-reaction'); const bottomReactionsDropdowns = commentContainer.querySelectorAll('.bottom-reactions .dropdown.select-reaction');
$(bottomReactionsDropdowns).dropdown(); // re-init the dropdown fomanticQuery(bottomReactionsDropdowns).dropdown(); // re-init the dropdown
} }
}); });
} }

View file

@ -1,5 +1,5 @@
import $ from 'jquery';
import {htmlEscape} from 'escape-goat'; import {htmlEscape} from 'escape-goat';
import {fomanticQuery} from '../../modules/fomantic/base.ts';
const {appSubUrl} = window.config; const {appSubUrl} = window.config;
const looksLikeEmailAddressCheck = /^\S+@\S+$/; const looksLikeEmailAddressCheck = /^\S+@\S+$/;
@ -10,7 +10,7 @@ export function initCompSearchUserBox() {
const allowEmailInput = searchUserBox.getAttribute('data-allow-email') === 'true'; const allowEmailInput = searchUserBox.getAttribute('data-allow-email') === 'true';
const allowEmailDescription = searchUserBox.getAttribute('data-allow-email-description') ?? undefined; const allowEmailDescription = searchUserBox.getAttribute('data-allow-email-description') ?? undefined;
$(searchUserBox).search({ fomanticQuery(searchUserBox).search({
minCharacters: 2, minCharacters: 2,
apiSettings: { apiSettings: {
url: `${appSubUrl}/user/search_candidates?q={query}`, url: `${appSubUrl}/user/search_candidates?q={query}`,

View file

@ -1,5 +1,5 @@
import $ from 'jquery';
import {toggleElem} from '../utils/dom.ts'; import {toggleElem} from '../utils/dom.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
export function initRepoBranchButton() { export function initRepoBranchButton() {
initRepoCreateBranchButton(); initRepoCreateBranchButton();
@ -18,7 +18,7 @@ function initRepoCreateBranchButton() {
const fromSpanName = el.getAttribute('data-modal-from-span') || '#modal-create-branch-from-span'; const fromSpanName = el.getAttribute('data-modal-from-span') || '#modal-create-branch-from-span';
document.querySelector(fromSpanName).textContent = el.getAttribute('data-branch-from'); document.querySelector(fromSpanName).textContent = el.getAttribute('data-branch-from');
$(el.getAttribute('data-modal')).modal('show'); fomanticQuery(el.getAttribute('data-modal')).modal('show');
}); });
} }
} }

View file

@ -1,6 +1,6 @@
import $ from 'jquery';
import {hideElem, showElem} from '../utils/dom.ts'; import {hideElem, showElem} from '../utils/dom.ts';
import {GET} from '../modules/fetch.ts'; import {GET} from '../modules/fetch.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
export function initRepoGraphGit() { export function initRepoGraphGit() {
const graphContainer = document.querySelector('#git-graph-container'); const graphContainer = document.querySelector('#git-graph-container');
@ -83,8 +83,8 @@ export function initRepoGraphGit() {
} }
const flowSelectRefsDropdown = document.querySelector('#flow-select-refs-dropdown'); const flowSelectRefsDropdown = document.querySelector('#flow-select-refs-dropdown');
$(flowSelectRefsDropdown).dropdown('set selected', dropdownSelected); fomanticQuery(flowSelectRefsDropdown).dropdown('set selected', dropdownSelected);
$(flowSelectRefsDropdown).dropdown({ fomanticQuery(flowSelectRefsDropdown).dropdown({
clearable: true, clearable: true,
fullTextSeach: 'exact', fullTextSeach: 'exact',
onRemove(toRemove) { onRemove(toRemove) {

View file

@ -1,8 +1,8 @@
import $ from 'jquery';
import {stripTags} from '../utils.ts'; import {stripTags} from '../utils.ts';
import {hideElem, queryElemChildren, showElem} from '../utils/dom.ts'; import {hideElem, queryElemChildren, showElem} from '../utils/dom.ts';
import {POST} from '../modules/fetch.ts'; import {POST} from '../modules/fetch.ts';
import {showErrorToast} from '../modules/toast.ts'; import {showErrorToast} from '../modules/toast.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
const {appSubUrl} = window.config; const {appSubUrl} = window.config;
@ -73,7 +73,7 @@ export function initRepoTopicBar() {
} }
}); });
$(topicDropdown).dropdown({ fomanticQuery(topicDropdown).dropdown({
allowAdditions: true, allowAdditions: true,
forceSelection: false, forceSelection: false,
fullTextSearch: 'exact', fullTextSearch: 'exact',
@ -136,7 +136,7 @@ export function initRepoTopicBar() {
onLabelCreate(value) { onLabelCreate(value) {
value = value.toLowerCase().trim(); value = value.toLowerCase().trim();
this.attr('data-value', value).contents().first().replaceWith(value); this.attr('data-value', value).contents().first().replaceWith(value);
return $(this); return fomanticQuery(this);
}, },
onAdd(addedValue, _addedText, $addedChoice) { onAdd(addedValue, _addedText, $addedChoice) {
addedValue = addedValue.toLowerCase().trim(); addedValue = addedValue.toLowerCase().trim();

View file

@ -195,3 +195,7 @@ export function initAreYouSure($) {
}); });
}; };
} }
export function applyAreYouSure(selector: string) {
$(selector).areYouSure();
}