{{template "repo/header" .}}
diff --git a/web_src/js/features/repo-issue-content.ts b/web_src/js/features/repo-issue-content.ts index 7aaf9765eec..88672cc2553 100644 --- a/web_src/js/features/repo-issue-content.ts +++ b/web_src/js/features/repo-issue-content.ts @@ -3,8 +3,8 @@ import {svg} from '../svg.ts'; import {showErrorToast} from '../modules/toast.ts'; import {GET, POST} from '../modules/fetch.ts'; import {showElem} from '../utils/dom.ts'; +import {parseIssuePageInfo} from '../utils.ts'; -const {appSubUrl} = window.config; let i18nTextEdited; let i18nTextOptions; let i18nTextDeleteFromHistory; @@ -121,15 +121,14 @@ function showContentHistoryMenu(issueBaseUrl, $item, commentId) { } export async function initRepoIssueContentHistory() { - const issueIndex = $('#issueIndex').val(); - if (!issueIndex) return; + const issuePageInfo = parseIssuePageInfo(); + if (!issuePageInfo.issueNumber) return; const $itemIssue = $('.repository.issue .timeline-item.comment.first'); // issue(PR) main content const $comments = $('.repository.issue .comment-list .comment'); // includes: issue(PR) comments, review comments, code comments if (!$itemIssue.length && !$comments.length) return; - const repoLink = $('#repolink').val(); - const issueBaseUrl = `${appSubUrl}/${repoLink}/issues/${issueIndex}`; + const issueBaseUrl = `${issuePageInfo.repoLink}/issues/${issuePageInfo.issueNumber}`; try { const response = await GET(`${issueBaseUrl}/content-history/overview`); diff --git a/web_src/js/features/repo-issue.ts b/web_src/js/features/repo-issue.ts index 392af776f88..721a746aa2c 100644 --- a/web_src/js/features/repo-issue.ts +++ b/web_src/js/features/repo-issue.ts @@ -4,7 +4,7 @@ import {createTippy, showTemporaryTooltip} from '../modules/tippy.ts'; import {hideElem, showElem, toggleElem} from '../utils/dom.ts'; import {setFileFolding} from './file-fold.ts'; import {ComboMarkdownEditor, getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.ts'; -import {toAbsoluteUrl} from '../utils.ts'; +import {parseIssuePageInfo, toAbsoluteUrl} from '../utils.ts'; import {GET, POST} from '../modules/fetch.ts'; import {showErrorToast} from '../modules/toast.ts'; import {initRepoIssueSidebar} from './repo-issue-sidebar.ts'; @@ -57,13 +57,11 @@ function excludeLabel(item) { } export function initRepoIssueSidebarList() { - const repolink = $('#repolink').val(); - const repoId = $('#repoId').val(); + const issuePageInfo = parseIssuePageInfo(); const crossRepoSearch = $('#crossRepoSearch').val(); - const tp = $('#type').val(); - let issueSearchUrl = `${appSubUrl}/${repolink}/issues/search?q={query}&type=${tp}`; + let issueSearchUrl = `${issuePageInfo.repoLink}/issues/search?q={query}&type=${issuePageInfo.issueDependencySearchType}`; if (crossRepoSearch === 'true') { - issueSearchUrl = `${appSubUrl}/issues/search?q={query}&priority_repo_id=${repoId}&type=${tp}`; + issueSearchUrl = `${appSubUrl}/issues/search?q={query}&priority_repo_id=${issuePageInfo.repoId}&type=${issuePageInfo.issueDependencySearchType}`; } $('#new-dependency-drop-list') .dropdown({ diff --git a/web_src/js/types.ts b/web_src/js/types.ts index 9c601456bd9..f5c4a40bcac 100644 --- a/web_src/js/types.ts +++ b/web_src/js/types.ts @@ -37,6 +37,13 @@ export type IssuePathInfo = { indexString?: string, } +export type IssuePageInfo = { + repoLink: string, + repoId: number, + issueNumber: number, + issueDependencySearchType: string, +} + export type Issue = { id: number; number: number; diff --git a/web_src/js/utils.ts b/web_src/js/utils.ts index 066a7c7b546..4fed74e20f0 100644 --- a/web_src/js/utils.ts +++ b/web_src/js/utils.ts @@ -1,5 +1,5 @@ -import {encode, decode} from 'uint8-to-base64'; -import type {IssuePathInfo} from './types.ts'; +import {decode, encode} from 'uint8-to-base64'; +import type {IssuePageInfo, IssuePathInfo} from './types.ts'; // transform /path/to/file.ext to file.ext export function basename(path: string): string { @@ -43,6 +43,16 @@ export function parseIssueNewHref(href: string): IssuePathInfo { return {ownerName, repoName, pathType, indexString}; } +export function parseIssuePageInfo(): IssuePageInfo { + const el = document.querySelector('#issue-page-info'); + return { + issueNumber: parseInt(el?.getAttribute('data-issue-index')), + issueDependencySearchType: el?.getAttribute('data-issue-dependency-search-type') || '', + repoId: parseInt(el?.getAttribute('data-issue-repo-id')), + repoLink: el?.getAttribute('data-issue-repo-link') || '', + }; +} + // parse a URL, either relative '/path' or absolute 'https://localhost/path' export function parseUrl(str: string): URL { return new URL(str, str.startsWith('http') ? undefined : window.location.origin); From 35bcd667b23de29a7b0d0bf1090fb10961d3aca3 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Fri, 8 Nov 2024 10:53:06 +0800 Subject: [PATCH 4/6] Fix broken releases when re-pushing tags (#32435) Fix #32427 --- services/repository/push.go | 19 +++++++----- tests/integration/repo_tag_test.go | 47 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/services/repository/push.go b/services/repository/push.go index 36c7927ab61..06ad65e48fb 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -318,9 +318,10 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo } releases, err := db.Find[repo_model.Release](ctx, repo_model.FindReleasesOptions{ - RepoID: repo.ID, - TagNames: tags, - IncludeTags: true, + RepoID: repo.ID, + TagNames: tags, + IncludeDrafts: true, + IncludeTags: true, }) if err != nil { return fmt.Errorf("db.Find[repo_model.Release]: %w", err) @@ -407,13 +408,17 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo newReleases = append(newReleases, rel) } else { - rel.Title = parts[0] - rel.Note = note rel.Sha1 = commit.ID.String() rel.CreatedUnix = timeutil.TimeStamp(createdAt.Unix()) rel.NumCommits = commitsCount - if rel.IsTag && author != nil { - rel.PublisherID = author.ID + if rel.IsTag { + rel.Title = parts[0] + rel.Note = note + if author != nil { + rel.PublisherID = author.ID + } + } else { + rel.IsDraft = false } if err = repo_model.UpdateRelease(ctx, rel); err != nil { return fmt.Errorf("Update: %w", err) diff --git a/tests/integration/repo_tag_test.go b/tests/integration/repo_tag_test.go index d649f041ccf..0cd49ee4cd3 100644 --- a/tests/integration/repo_tag_test.go +++ b/tests/integration/repo_tag_test.go @@ -4,17 +4,20 @@ package integration import ( + "fmt" "net/http" "net/url" "testing" "code.gitea.io/gitea/models" + auth_model "code.gitea.io/gitea/models/auth" "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/services/release" "code.gitea.io/gitea/tests" @@ -117,3 +120,47 @@ func TestCreateNewTagProtected(t *testing.T) { assert.NoError(t, err) } } + +func TestRepushTag(t *testing.T) { + onGiteaRun(t, func(t *testing.T, u *url.URL) { + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) + owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) + session := loginUser(t, owner.LowerName) + token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository) + + httpContext := NewAPITestContext(t, owner.Name, repo.Name) + + dstPath := t.TempDir() + + u.Path = httpContext.GitPath() + u.User = url.UserPassword(owner.Name, userPassword) + + doGitClone(dstPath, u)(t) + + // create and push a tag + _, _, err := git.NewCommand(git.DefaultContext, "tag", "v2.0").RunStdString(&git.RunOpts{Dir: dstPath}) + assert.NoError(t, err) + _, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "--tags", "v2.0").RunStdString(&git.RunOpts{Dir: dstPath}) + assert.NoError(t, err) + // create a release for the tag + createdRelease := createNewReleaseUsingAPI(t, token, owner, repo, "v2.0", "", "Release of v2.0", "desc") + assert.False(t, createdRelease.IsDraft) + // delete the tag + _, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "--delete", "v2.0").RunStdString(&git.RunOpts{Dir: dstPath}) + assert.NoError(t, err) + // query the release by API and it should be a draft + req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/%s", owner.Name, repo.Name, "v2.0")) + resp := MakeRequest(t, req, http.StatusOK) + var respRelease *api.Release + DecodeJSON(t, resp, &respRelease) + assert.True(t, respRelease.IsDraft) + // re-push the tag + _, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "--tags", "v2.0").RunStdString(&git.RunOpts{Dir: dstPath}) + assert.NoError(t, err) + // query the release by API and it should not be a draft + req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/%s", owner.Name, repo.Name, "v2.0")) + resp = MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &respRelease) + assert.False(t, respRelease.IsDraft) + }) +} From 0f397ae09b028e3537d70659409ac6a1f069033e Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 8 Nov 2024 14:04:24 +0800 Subject: [PATCH 5/6] Refactor language menu and dom utils (#32450) 1. Make `queryElem*` functions could correctly handle TS types 2. Remove some legacy jQuery $ calls (introduce fomanticQuery for Fomantic UI only) 3. Fix some TS typing problems --- templates/base/footer_content.tmpl | 8 +++---- web_src/css/home.css | 2 +- web_src/js/features/common-page.ts | 27 ++++++++++++----------- web_src/js/features/imagediff.ts | 32 +++++++++++++++------------- web_src/js/features/repo-common.ts | 2 +- web_src/js/features/repo-editor.ts | 24 ++++++++++----------- web_src/js/features/repo-settings.ts | 2 +- web_src/js/modules/fomantic/base.ts | 4 ++++ web_src/js/modules/tippy.ts | 8 +++---- web_src/js/utils/dom.ts | 23 +++++++++++--------- 10 files changed, 70 insertions(+), 62 deletions(-) diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index 4b9d9f5bbec..60eb2fe1f82 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -17,12 +17,12 @@ {{end}}
+
{{end}} diff --git a/templates/repo/issue/sidebar/allow_maintainer_edit.tmpl b/templates/repo/issue/sidebar/allow_maintainer_edit.tmpl index 43736deeed8..ad4ce96a475 100644 --- a/templates/repo/issue/sidebar/allow_maintainer_edit.tmpl +++ b/templates/repo/issue/sidebar/allow_maintainer_edit.tmpl @@ -1,15 +1,13 @@ {{if and .Issue.IsPull .IsIssuePoster (not .Issue.IsClosed) .Issue.PullRequest.HeadRepo}} {{if and (not (eq .Issue.PullRequest.HeadRepo.FullName .Issue.PullRequest.BaseRepo.FullName)) .CanWriteToHeadRepo}}
-
-
- - -
+
+ +
{{end}} {{end}} diff --git a/templates/repo/issue/sidebar/issue_dependencies.tmpl b/templates/repo/issue/sidebar/issue_dependencies.tmpl index f372ff81b2a..837bcd56705 100644 --- a/templates/repo/issue/sidebar/issue_dependencies.tmpl +++ b/templates/repo/issue/sidebar/issue_dependencies.tmpl @@ -18,11 +18,11 @@ {{ctx.Locale.Tr "repo.issues.dependency.blocks_short"}} -
+
{{range .BlockingDependencies}}
- + #{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}
@@ -50,11 +50,11 @@ {{ctx.Locale.Tr "repo.issues.dependency.blocked_by_short"}} -
+
{{range .BlockedByDependencies}}
- + #{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}
@@ -76,7 +76,7 @@
{{svg "octicon-lock" 16}} - + #{{.Issue.Index}} {{.Issue.Title | ctx.RenderUtils.RenderEmoji}}
diff --git a/web_src/css/repo.css b/web_src/css/repo.css index 85f33f858e2..61aa99d531f 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -62,23 +62,6 @@ } } -.repository .issue-content-right .ui.list .dependency { - padding: 0; - white-space: nowrap; -} - -.repository .issue-content-right .ui.list .title { - overflow: hidden; - text-overflow: ellipsis; -} - -.repository .issue-content-right #deadlineForm input { - width: 12.8rem; - border-radius: var(--border-radius) 0 0 var(--border-radius); - border-right: 0; - white-space: nowrap; -} - .repository .issue-content-right .filter.menu { max-height: 500px; overflow-x: auto;