{{template "repo/header" .}}
- diff --git a/templates/shared/actions/runner_badge.tmpl b/templates/shared/actions/runner_badge.tmpl index 816e87e177..1ba9be09fb 100644 --- a/templates/shared/actions/runner_badge.tmpl +++ b/templates/shared/actions/runner_badge.tmpl @@ -1,25 +1,27 @@ - {{.Badge.Label.Text}}: {{.Badge.Message.Text}} - - - - - + + + - - + + - - - - + + + + + + + + {{.Badge.Label.Text}} + + {{.Badge.Message.Text}} - {{.Badge.Label.Text}}{{.Badge.Message.Text}} diff --git a/tests/integration/actions_log_test.go b/tests/integration/actions_log_test.go index a157a923f6..cd20604b84 100644 --- a/tests/integration/actions_log_test.go +++ b/tests/integration/actions_log_test.go @@ -31,7 +31,7 @@ func TestDownloadTaskLogs(t *testing.T) { testCases := []struct { treePath string fileContent string - outcome *mockTaskOutcome + outcome []*mockTaskOutcome zstdEnabled bool }{ { @@ -46,21 +46,44 @@ jobs: runs-on: ubuntu-latest steps: - run: echo job1 with zstd enabled + job2: + runs-on: ubuntu-latest + steps: + - run: echo job2 with zstd enabled `, - outcome: &mockTaskOutcome{ - result: runnerv1.Result_RESULT_SUCCESS, - logRows: []*runnerv1.LogRow{ - { - Time: timestamppb.New(now.Add(1 * time.Second)), - Content: " \U0001F433 docker create image", + outcome: []*mockTaskOutcome{ + { + result: runnerv1.Result_RESULT_SUCCESS, + logRows: []*runnerv1.LogRow{ + { + Time: timestamppb.New(now.Add(1 * time.Second)), + Content: " \U0001F433 docker create image", + }, + { + Time: timestamppb.New(now.Add(2 * time.Second)), + Content: "job1 zstd enabled", + }, + { + Time: timestamppb.New(now.Add(3 * time.Second)), + Content: "\U0001F3C1 Job succeeded", + }, }, - { - Time: timestamppb.New(now.Add(2 * time.Second)), - Content: "job1 zstd enabled", - }, - { - Time: timestamppb.New(now.Add(3 * time.Second)), - Content: "\U0001F3C1 Job succeeded", + }, + { + result: runnerv1.Result_RESULT_SUCCESS, + logRows: []*runnerv1.LogRow{ + { + Time: timestamppb.New(now.Add(1 * time.Second)), + Content: " \U0001F433 docker create image", + }, + { + Time: timestamppb.New(now.Add(2 * time.Second)), + Content: "job2 zstd enabled", + }, + { + Time: timestamppb.New(now.Add(3 * time.Second)), + Content: "\U0001F3C1 Job succeeded", + }, }, }, }, @@ -78,21 +101,44 @@ jobs: runs-on: ubuntu-latest steps: - run: echo job1 with zstd disabled + job2: + runs-on: ubuntu-latest + steps: + - run: echo job2 with zstd disabled `, - outcome: &mockTaskOutcome{ - result: runnerv1.Result_RESULT_SUCCESS, - logRows: []*runnerv1.LogRow{ - { - Time: timestamppb.New(now.Add(4 * time.Second)), - Content: " \U0001F433 docker create image", + outcome: []*mockTaskOutcome{ + { + result: runnerv1.Result_RESULT_SUCCESS, + logRows: []*runnerv1.LogRow{ + { + Time: timestamppb.New(now.Add(4 * time.Second)), + Content: " \U0001F433 docker create image", + }, + { + Time: timestamppb.New(now.Add(5 * time.Second)), + Content: "job1 zstd disabled", + }, + { + Time: timestamppb.New(now.Add(6 * time.Second)), + Content: "\U0001F3C1 Job succeeded", + }, }, - { - Time: timestamppb.New(now.Add(5 * time.Second)), - Content: "job1 zstd disabled", - }, - { - Time: timestamppb.New(now.Add(6 * time.Second)), - Content: "\U0001F3C1 Job succeeded", + }, + { + result: runnerv1.Result_RESULT_SUCCESS, + logRows: []*runnerv1.LogRow{ + { + Time: timestamppb.New(now.Add(4 * time.Second)), + Content: " \U0001F433 docker create image", + }, + { + Time: timestamppb.New(now.Add(5 * time.Second)), + Content: "job2 zstd disabled", + }, + { + Time: timestamppb.New(now.Add(6 * time.Second)), + Content: "\U0001F3C1 Job succeeded", + }, }, }, }, @@ -124,54 +170,55 @@ jobs: opts := getWorkflowCreateFileOptions(user2, repo.DefaultBranch, fmt.Sprintf("create %s", tc.treePath), tc.fileContent) createWorkflowFile(t, token, user2.Name, repo.Name, tc.treePath, opts) - // fetch and execute task - task := runner.fetchTask(t) - runner.execTask(t, task, tc.outcome) + // fetch and execute tasks + for jobIndex, outcome := range tc.outcome { + task := runner.fetchTask(t) + runner.execTask(t, task, outcome) - // check whether the log file exists - logFileName := fmt.Sprintf("%s/%02x/%d.log", repo.FullName(), task.Id%256, task.Id) - if setting.Actions.LogCompression.IsZstd() { - logFileName += ".zst" + // check whether the log file exists + logFileName := fmt.Sprintf("%s/%02x/%d.log", repo.FullName(), task.Id%256, task.Id) + if setting.Actions.LogCompression.IsZstd() { + logFileName += ".zst" + } + _, err := storage.Actions.Stat(logFileName) + assert.NoError(t, err) + + // download task logs and check content + runIndex := task.Context.GetFields()["run_number"].GetStringValue() + req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/actions/runs/%s/jobs/%d/logs", user2.Name, repo.Name, runIndex, jobIndex)). + AddTokenAuth(token) + resp := MakeRequest(t, req, http.StatusOK) + logTextLines := strings.Split(strings.TrimSpace(resp.Body.String()), "\n") + assert.Len(t, logTextLines, len(outcome.logRows)) + for idx, lr := range outcome.logRows { + assert.Equal( + t, + fmt.Sprintf("%s %s", lr.Time.AsTime().Format("2006-01-02T15:04:05.0000000Z07:00"), lr.Content), + logTextLines[idx], + ) + } + + runID, _ := strconv.ParseInt(task.Context.GetFields()["run_id"].GetStringValue(), 10, 64) + + jobs, err := actions_model.GetRunJobsByRunID(t.Context(), runID) + assert.NoError(t, err) + assert.Len(t, jobs, len(tc.outcome)) + jobID := jobs[jobIndex].ID + + // download task logs from API and check content + req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/actions/jobs/%d/logs", user2.Name, repo.Name, jobID)). + AddTokenAuth(token) + resp = MakeRequest(t, req, http.StatusOK) + logTextLines = strings.Split(strings.TrimSpace(resp.Body.String()), "\n") + assert.Len(t, logTextLines, len(outcome.logRows)) + for idx, lr := range outcome.logRows { + assert.Equal( + t, + fmt.Sprintf("%s %s", lr.Time.AsTime().Format("2006-01-02T15:04:05.0000000Z07:00"), lr.Content), + logTextLines[idx], + ) + } } - _, err := storage.Actions.Stat(logFileName) - assert.NoError(t, err) - - // download task logs and check content - runIndex := task.Context.GetFields()["run_number"].GetStringValue() - req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/actions/runs/%s/jobs/0/logs", user2.Name, repo.Name, runIndex)). - AddTokenAuth(token) - resp := MakeRequest(t, req, http.StatusOK) - logTextLines := strings.Split(strings.TrimSpace(resp.Body.String()), "\n") - assert.Len(t, logTextLines, len(tc.outcome.logRows)) - for idx, lr := range tc.outcome.logRows { - assert.Equal( - t, - fmt.Sprintf("%s %s", lr.Time.AsTime().Format("2006-01-02T15:04:05.0000000Z07:00"), lr.Content), - logTextLines[idx], - ) - } - - runID, _ := strconv.ParseInt(task.Context.GetFields()["run_id"].GetStringValue(), 10, 64) - - jobs, err := actions_model.GetRunJobsByRunID(t.Context(), runID) - assert.NoError(t, err) - assert.Len(t, jobs, 1) - jobID := jobs[0].ID - - // download task logs from API and check content - req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/actions/jobs/%d/logs", user2.Name, repo.Name, jobID)). - AddTokenAuth(token) - resp = MakeRequest(t, req, http.StatusOK) - logTextLines = strings.Split(strings.TrimSpace(resp.Body.String()), "\n") - assert.Len(t, logTextLines, len(tc.outcome.logRows)) - for idx, lr := range tc.outcome.logRows { - assert.Equal( - t, - fmt.Sprintf("%s %s", lr.Time.AsTime().Format("2006-01-02T15:04:05.0000000Z07:00"), lr.Content), - logTextLines[idx], - ) - } - resetFunc() }) } diff --git a/tests/integration/git_smart_http_test.go b/tests/integration/git_smart_http_test.go index 55d647672a..1cbda5a673 100644 --- a/tests/integration/git_smart_http_test.go +++ b/tests/integration/git_smart_http_test.go @@ -9,6 +9,8 @@ import ( "net/url" "testing" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" @@ -16,7 +18,10 @@ import ( ) func TestGitSmartHTTP(t *testing.T) { - onGiteaRun(t, testGitSmartHTTP) + onGiteaRun(t, func(t *testing.T, u *url.URL) { + testGitSmartHTTP(t, u) + testRenamedRepoRedirect(t) + }) } func testGitSmartHTTP(t *testing.T, u *url.URL) { @@ -73,3 +78,21 @@ func testGitSmartHTTP(t *testing.T, u *url.URL) { }) } } + +func testRenamedRepoRedirect(t *testing.T) { + defer test.MockVariableValue(&setting.Service.RequireSignInView, true)() + + // git client requires to get a 301 redirect response before 401 unauthorized response + req := NewRequest(t, "GET", "/user2/oldrepo1/info/refs") + resp := MakeRequest(t, req, http.StatusMovedPermanently) + redirect := resp.Header().Get("Location") + assert.Equal(t, "/user2/repo1/info/refs", redirect) + + req = NewRequest(t, "GET", redirect) + resp = MakeRequest(t, req, http.StatusUnauthorized) + assert.Equal(t, "Unauthorized\n", resp.Body.String()) + + req = NewRequest(t, "GET", redirect).AddBasicAuth("user2") + resp = MakeRequest(t, req, http.StatusOK) + assert.Contains(t, resp.Body.String(), "65f1bf27bc3bf70f64657658635e66094edbcb4d\trefs/tags/v1.1") +} diff --git a/tests/integration/repo_generate_test.go b/tests/integration/repo_generate_test.go index ff2aa220d3..f5645d62bc 100644 --- a/tests/integration/repo_generate_test.go +++ b/tests/integration/repo_generate_test.go @@ -31,16 +31,16 @@ func testRepoGenerate(t *testing.T, session *TestSession, templateID, templateOw // Step2: click the "Use this template" button htmlDoc := NewHTMLParser(t, resp.Body) - link, exists := htmlDoc.doc.Find("a.ui.button[href^=\"/repo/create\"]").Attr("href") + link, exists := htmlDoc.doc.Find(`a.ui.button[href^="/repo/create"]`).Attr("href") assert.True(t, exists, "The template has changed") req = NewRequest(t, "GET", link) resp = session.MakeRequest(t, req, http.StatusOK) - // Step3: fill the form of the create + // Step3: fill the form on the "create" page htmlDoc = NewHTMLParser(t, resp.Body) - link, exists = htmlDoc.doc.Find("form.ui.form[action^=\"/repo/create\"]").Attr("action") + link, exists = htmlDoc.doc.Find(`form.ui.form[action^="/repo/create"]`).Attr("action") assert.True(t, exists, "The template has changed") - _, exists = htmlDoc.doc.Find(fmt.Sprintf(".owner.dropdown .item[data-value=\"%d\"]", generateOwner.ID)).Attr("data-value") + _, exists = htmlDoc.doc.Find(fmt.Sprintf(`#repo_owner_dropdown .item[data-value="%d"]`, generateOwner.ID)).Attr("data-value") assert.True(t, exists, "Generate owner '%s' is not present in select box", generateOwnerName) req = NewRequestWithValues(t, "POST", link, map[string]string{ "_csrf": htmlDoc.GetCSRF(), diff --git a/web_src/css/base.css b/web_src/css/base.css index 47b4f44a66..98eb32bc13 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -989,14 +989,7 @@ table th[data-sortt-desc] .svg { box-shadow: 0 0 0 1px var(--color-secondary) inset; } -.emoji { - font-size: 1.25em; - line-height: var(--line-height-default); - font-style: normal !important; - font-weight: var(--font-weight-normal) !important; - vertical-align: -0.075em; -} - +/* for "image" emojis like ":git:" ":gitea:" and ":github:" (see CUSTOM_EMOJIS config option) */ .emoji img { border-width: 0 !important; margin: 0 !important; @@ -1155,6 +1148,11 @@ table th[data-sortt-desc] .svg { min-width: 0; } +.flex-text-block > .ui.button, +.flex-text-inline > .ui.button { + margin: 0; /* fomantic buttons have default margin, when we use them in a flex container with gap, we do not need these margins */ +} + /* to override Fomantic's default display: block for ".menu .item", and use a slightly larger gap for menu item content the "!important" is necessary to override Fomantic UI menu item styles, meanwhile we should keep the "hidden" items still hidden */ .ui.dropdown .menu.flex-items-menu > .item:not(.hidden, .filtered, .tw-hidden) { diff --git a/web_src/css/features/projects.css b/web_src/css/features/projects.css index 8763d3684e..72ef523913 100644 --- a/web_src/css/features/projects.css +++ b/web_src/css/features/projects.css @@ -8,18 +8,6 @@ margin: 0 0.5em; } -.project-toolbar-right .filter.menu { - flex-direction: row; - flex-wrap: wrap; -} - -@media (max-width: 767.98px) { - .project-toolbar-right .dropdown .menu { - left: auto !important; - right: auto !important; - } -} - .project-column { background-color: var(--color-project-column-bg) !important; border: 1px solid var(--color-secondary) !important; diff --git a/web_src/css/markup/content.css b/web_src/css/markup/content.css index 865ac0536a..6d985a76a7 100644 --- a/web_src/css/markup/content.css +++ b/web_src/css/markup/content.css @@ -336,11 +336,6 @@ padding-right: 28px; } -.markup .emoji { - max-width: none; - vertical-align: text-top; -} - .markup span.frame { display: block; overflow: hidden; diff --git a/web_src/js/features/repo-new.ts b/web_src/js/features/repo-new.ts index 5128942465..0e4d78872d 100644 --- a/web_src/js/features/repo-new.ts +++ b/web_src/js/features/repo-new.ts @@ -1,4 +1,4 @@ -import {hideElem, showElem, toggleElem} from '../utils/dom.ts'; +import {hideElem, querySingleVisibleElem, showElem, toggleElem} from '../utils/dom.ts'; import {htmlEscape} from 'escape-goat'; import {fomanticQuery} from '../modules/fomantic/base.ts'; import {sanitizeRepoName} from './repo-common.ts'; @@ -6,7 +6,9 @@ import {sanitizeRepoName} from './repo-common.ts'; const {appSubUrl} = window.config; function initRepoNewTemplateSearch(form: HTMLFormElement) { - const inputRepoOwnerUid = form.querySelector('#uid'); + const elSubmitButton = querySingleVisibleElem(form, '.ui.primary.button'); + const elCreateRepoErrorMessage = form.querySelector('#create-repo-error-message'); + const elRepoOwnerDropdown = form.querySelector('#repo_owner_dropdown'); const elRepoTemplateDropdown = form.querySelector('#repo_template_search'); const inputRepoTemplate = form.querySelector('#repo_template'); const elTemplateUnits = form.querySelector('#template_units'); @@ -19,11 +21,23 @@ function initRepoNewTemplateSearch(form: HTMLFormElement) { inputRepoTemplate.addEventListener('change', checkTemplate); checkTemplate(); - const $dropdown = fomanticQuery(elRepoTemplateDropdown); + const $repoOwnerDropdown = fomanticQuery(elRepoOwnerDropdown); + const $repoTemplateDropdown = fomanticQuery(elRepoTemplateDropdown); const onChangeOwner = function () { - $dropdown.dropdown('setting', { + const ownerId = $repoOwnerDropdown.dropdown('get value'); + const $ownerItem = $repoOwnerDropdown.dropdown('get item', ownerId); + hideElem(elCreateRepoErrorMessage); + elSubmitButton.disabled = false; + if ($ownerItem?.length) { + const elOwnerItem = $ownerItem[0]; + elCreateRepoErrorMessage.textContent = elOwnerItem.getAttribute('data-create-repo-disallowed-prompt') ?? ''; + const hasError = Boolean(elCreateRepoErrorMessage.textContent); + toggleElem(elCreateRepoErrorMessage, hasError); + elSubmitButton.disabled = hasError; + } + $repoTemplateDropdown.dropdown('setting', { apiSettings: { - url: `${appSubUrl}/repo/search?q={query}&template=true&priority_owner_id=${inputRepoOwnerUid.value}`, + url: `${appSubUrl}/repo/search?q={query}&template=true&priority_owner_id=${ownerId}`, onResponse(response: any) { const results = []; results.push({name: '', value: ''}); // empty item means not using template @@ -33,14 +47,14 @@ function initRepoNewTemplateSearch(form: HTMLFormElement) { value: String(tmplRepo.repository.id), }); } - $dropdown.fomanticExt.onResponseKeepSelectedItem($dropdown, inputRepoTemplate.value); + $repoTemplateDropdown.fomanticExt.onResponseKeepSelectedItem($repoTemplateDropdown, inputRepoTemplate.value); return {results}; }, cache: false, }, }); }; - inputRepoOwnerUid.addEventListener('change', onChangeOwner); + $repoOwnerDropdown.dropdown('setting', 'onChange', onChangeOwner); onChangeOwner(); }