Commit Graph
100 Commits
Author SHA1 Message Date
wxiaoguang 160ccb5ee2 Fix test fixtures for user2/lfs.git (#32477) 2024-11-12 05:41:22 +00:00
wxiaoguang 580e21dd2e Refactor LFS SSH and internal routers (#32473)
Gitea instance keeps reporting a lot of errors like "LFS SSH transfer connection denied, pure SSH protocol is disabled". When starting debugging the problem, there are more problems found. Try to address most of them:

* avoid unnecessary server side error logs (change `fail()` to not log them)
* figure out the broken tests/user2/lfs.git (added comments)
* avoid `migratePushMirrors` failure when a repository doesn't exist (ignore them)
* avoid "Authorization" (internal&lfs) header conflicts, remove the tricky "swapAuth" and use "X-Gitea-Internal-Auth"
* make internal token comparing constant time (it wasn't a serous problem because in a real world it's nearly impossible to timing-attack the token, but good to fix and backport)
* avoid duplicate routers (introduce AddOwnerRepoGitLFSRoutes)
* avoid "internal (private)" routes using session/web context (they should use private context)
* fix incorrect "path" usages (use "filepath")
* fix incorrect mocked route point handling (need to check func nil correctly)
* split some tests from "git general tests" to "git misc tests" (to keep "git_general_test.go" simple)

Still no correct result for Git LFS SSH tests. So the code is kept there
(`tests/integration/git_lfs_ssh_test.go`) and a FIXME explains the details.
2024-11-12 02:38:22 +00:00
wxiaoguang a928739456 Refactor sidebar assignee&milestone&project selectors (#32465)
Follow #32460

Now the code could be much clearer than before and easier to maintain. A
lot of legacy code is removed.

Manually tested.

This PR is large enough, that fine tunes could be deferred to the future if
there is no bug found or design problem.

Screenshots:

<details>

![image](https://github.com/user-attachments/assets/35f4ab7b-1bc0-4bad-a73c-a4569328303c)

</details>
2024-11-11 04:07:54 +08:00
wxiaoguang 58c634b854 Refactor sidebar label selector (#32460)
Introduce `issueSidebarLabelsData` to handle all sidebar labels related data.
2024-11-10 08:26:42 +00:00
wxiaoguang d80f99ef04 Fix issue sidebar (#32455)
Fix #32453

Major changes:

* revert the `<div class="divider"></div>` in
`templates/repo/issue/branch_selector_field.tmpl` (it was removed by
mistake in ##32444)
* remove incorrect `<div class="inline field">` in
`templates/repo/issue/sidebar/allow_maintainer_edit.tmpl`
* use `gt-ellipsis` to replace the "title" class in the dependency list,
then `.repository .issue-content-right .ui.list .title` could be removed
* remove the "relaxed" from dependency list, then there is no padding,
then `.repository .issue-content-right .ui.list .dependency` could be
removed (`white-space` doesn't have effect either because there is
`gt-ellipsis`)
* remove dead code `.repository .issue-content-right #deadlineForm input
`

The fixed UI should be the same as before.
2024-11-09 01:55:32 +08:00
wxiaoguang 0f397ae09b 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
2024-11-08 14:04:24 +08:00
wxiaoguang 623a2d41cc Refactor issue page info (#32445)
Fix a longstanding TODO since 2021 (#14826) / 2018 (#2531)
2024-11-08 02:21:13 +00:00
wxiaoguang 028e612094 Split issue sidebar into small templates (#32444)
Only move code
2024-11-08 01:44:20 +00:00
wxiaoguang 145e266987 Support quote selected comments to reply (#32431)
Many existing tests were quite hacky, these could be improved later.

<details>

![image](https://github.com/user-attachments/assets/93aebb4f-9de5-4cb8-910b-50c64cbcd25a)

</details>
2024-11-07 03:57:07 +00:00
wxiaoguangandsilverwind b573512312 Correctly query the primary button in a form (#32438)
The "primary button" is used at many places, but sometimes they might
conflict (due to button switch, hidden panel, dropdown menu, etc).

Sometimes we could add a special CSS class for the buttons, but
sometimes not (see the comment of QuickSubmit)

This PR introduces `querySingleVisibleElem` to help to get the correct
primary button (the only visible one), and prevent from querying the
wrong buttons.

Fix #32437

---------

Co-authored-by: silverwind <me@silverwind.io>
2024-11-07 04:21:53 +08:00
wxiaoguang 41b4ef825d Use 8 as default value for git lfs concurrency (#32421) 2024-11-05 13:10:57 +00:00
wxiaoguang 61c35590c7 Refactor RepoRefByType (#32413)
1. clarify the "filepath" could(should) contain "{ref}"
2. remove unclear RepoRefLegacy and RepoRefAny, use RepoRefUnknown to guess
3. by the way, avoid using AppURL
2024-11-05 06:35:54 +00:00
wxiaoguang 4a469c8e1b Refactor template ctx and render utils (#32422)
Clean up the templates
2024-11-05 14:04:26 +08:00
wxiaoguang b068dbd40e Refactor DateUtils and merge TimeSince (#32409)
Follow #32383 and #32402
2024-11-04 11:30:00 +00:00
wxiaoguang 61be51e56b Refactor markup package (#32399)
To make the markup package easier to maintain:
1. Split some go files into small files
2. Use a shared util.NopCloser, remove duplicate code
3. Remove unused functions
2024-11-04 10:59:50 +00:00
wxiaoguang af28ce59b8 Add some handy markdown editor features (#32400)
There were some missing features from EasyMDE:

1. H1 - H3 style
2. Auto add task list
3. Insert a table

And added some tests
2024-11-04 10:14:36 +00:00
wxiaoguangandGiteabot f2a6df03d9 Refactor repo legacy (#32404)
Only move code, no unnecessary logic change. (There are many problems in
old code, but changing them is not in this PR's scope)

Co-authored-by: Giteabot <teabot@gitea.io>
2024-11-03 11:00:12 +00:00
wxiaoguang 259811617b Replace DateTime with proper functions (#32402)
Follow #32383

This PR cleans up the "Deadline" usages in templates, make them call
`ParseLegacy` first to get a `Time` struct then display by `DateUtils`.

Now it should be pretty clear how "deadline string" works, it makes it
possible to do further refactoring and correcting.
2024-11-02 21:04:53 +00:00
wxiaoguang e524f63d58 Fix git error handling (#32401) 2024-11-02 11:20:22 +00:00
wxiaoguang fec6b3d500 Replace DateTime with DateUtils (#32383) 2024-11-02 04:08:28 +00:00
wxiaoguang ec2d1593c2 Refactor tests to prevent from unnecessary preparations (#32398) 2024-11-01 23:18:29 +08:00
wxiaoguang 5e6523aa57 Update go dependencies (#32389) 2024-10-31 12:05:54 +00:00
wxiaoguang a4a121c684 Fix suggestions for issues (#32380) 2024-10-30 20:06:36 +00:00
wxiaoguang aee9801d46 Fix toAbsoluteLocaleDate and add more tests (#32387) 2024-10-31 02:36:02 +08:00
wxiaoguang ce4d909bd6 Fix absolute-date (#32375) 2024-10-30 17:50:19 +08:00
wxiaoguang a920fcfd91 Fix db engine (#32351)
Fix #32349
2024-10-27 18:48:07 -04:00
wxiaoguang d70af38447 Refactor the DB migration system slightly (#32344)
Introduce "idNumber" for each migration, and clarify the difference
between the migration ID number and database version.
2024-10-27 19:54:35 +08:00
wxiaoguang 0196b3583a Warn users when they try to use a non-root-url to sign in/up (#32272) 2024-10-17 10:28:51 +08:00
wxiaoguang 5242e520c4 Make owner/repo/pulls handlers use "PR reader" permission (#32254)
Fix #32253 (partially)
2024-10-15 06:47:07 +00:00
wxiaoguang afa8dd45af Make git push options accept short name (#32245)
Just like what most CLI parsers do: `--opt` means `opt=true`

Then users could use `-o force-push` as `-o force-push=true`
2024-10-12 05:42:10 +00:00
wxiaoguang 6029d78ab5 Improve the maintainblity of the reserved username list (#32229) 2024-10-10 09:04:42 +00:00
wxiaoguang dd83cfcacc Refactor CSRF token (#32216) 2024-10-10 03:48:21 +00:00
wxiaoguang 3b10fd9b34 Only use Host header from reverse proxy (#32060)
X-Forwarded-Host has many problems: non-standard, not well-defined
(X-Forwarded-Port or not), conflicts with Host header, it already caused
problems like #31907. So do not use X-Forwarded-Host, just use Host
header directly.

Official document also only uses `Host` header and never mentioned
others.
2024-09-20 14:57:55 +00:00
wxiaoguang 1fede04b83 Refactor CSRF protector (#32057)
Remove unused CSRF options, decouple "new csrf protector" and "prepare"
logic, do not redirect to home page if CSRF validation falis (it
shouldn't happen in daily usage, if it happens, redirecting to home
doesn't help either but just makes the problem more complex for "fetch")
2024-09-18 15:17:25 +08:00
wxiaoguang e3678356e1 Fix createElementFromAttrs bug (#31751)
The "false" value was not handled correctly, it would cause bugs in the
future (fortunately, this behavior is not used in code yet).
2024-08-01 19:06:03 +00:00
wxiaoguang 169031b7cf Fix "Filter by commit" Dropdown (#31695)
Regression of #31281
Fix #31673
2024-07-25 01:48:51 +00:00
wxiaoguang 72b6bc8caf Refactor webhook (#31587)
A more complete fix for #31588

1. Make "generic" code more readable
2. Clarify HTML or Markdown for the payload content
2024-07-10 11:37:16 +00:00
wxiaoguangandsilverwind c1fe6fbcc3 Make toast support preventDuplicates (#31501)
make preventDuplicates default to true, users get a clear UI feedback
and know that "a new message appears".

Fixes: https://github.com/go-gitea/gitea/issues/26651

---------

Co-authored-by: silverwind <me@silverwind.io>
2024-06-27 13:58:38 +00:00
wxiaoguang 00fc29aee1 Refactor issue label selection (#31497)
Follow #26460
2024-06-26 23:41:59 +00:00
wxiaoguang a88f718c10 Refactor dropzone (#31482)
Refactor the legacy code and remove some jQuery calls.
2024-06-27 01:01:20 +08:00
wxiaoguang f4921b9daa Simplify 404/500 page (#31409) 2024-06-23 17:45:21 +00:00
wxiaoguang bda875b6e6 Switch to "Write" tab when edit comment again (#31445)
Fix #19031
2024-06-22 09:25:04 +00:00
wxiaoguang 1d76e9aabf Add simple JS init performance trace (#31459)
Related to #23461, and help some cases like #31412

For developers, they could use browser's Performance tool to collect
performance data, while this PR is also quite handy to optimize the
`index.js`.

For end users, this PR is simple enough and could figure out the slow
function quickly.


![image](https://github.com/go-gitea/gitea/assets/2114189/a557b08e-6594-474b-81a3-03d5ac2bd68e)
2024-06-22 17:20:20 +08:00
wxiaoguang 1a811c0bd1 Refactor image diff (#31444)
And remove some jQuery functions
2024-06-22 04:52:09 +00:00
wxiaoguang 621e1ff9c9 Improve markdown textarea for indentation and lists (#31406)
Almost works like GitHub

* use Tab/Shift-Tab to indent/unindent the selected lines
* use Enter to insert a new line with the same indentation and prefix
2024-06-21 08:14:40 +00:00
wxiaoguang 06782872c4 Split common-global.js into separate files (#31438)
To improve maintainability
2024-06-21 15:40:33 +08:00
wxiaoguang ed5ded3ff8 Fix the link for .git-blame-ignore-revs bypass (#31432)
A quick fix for #31429
2024-06-20 23:28:34 +00:00
wxiaoguang 43c7a2e7b1 Refactor names (#31405)
This PR only does "renaming":

* `Route` should be `Router` (and chi router is also called "router")
* `Params` should be `PathParam` (to distingush it from URL query param, and to match `FormString`)
* Use lower case for private functions to avoid exposing or abusing
2024-06-19 06:32:45 +08:00
wxiaoguang 21783a5752 Fix rendered wiki page link (#31398)
Fix #31395
2024-06-18 03:09:20 +00:00
wxiaoguangandsilverwind 37a4b233a0 Refactor repo unit "disabled" check (#31389)
1. There are already global "unit consts", no need to use context data, which is fragile
2. Remove the "String()" method from "unit", it would only cause rendering problems in templates

---------

Co-authored-by: silverwind <me@silverwind.io>
2024-06-18 00:51:13 +00:00
wxiaoguang d32648b204 Refactor route path normalization (#31381)
Refactor route path normalization and decouple it from the chi router.
Fix the TODO, fix the legacy strange path behavior.
2024-06-17 23:28:47 +00:00
wxiaoguang 5a7376c060 Refactor markup code (#31399)
1. use clearer names
2. remove deadcode
3. avoid name shadowing
4. eliminate some lint warnings
2024-06-17 22:56:45 +00:00
wxiaoguang 0f09c22663 Improve rubygems package registry (#31357)
To make it work with Bundler:
https://guides.rubygems.org/rubygems-org-compact-index-api/

It only adds 2 new API endpoints and improves some tests, existing logic
is not changed.
2024-06-17 08:42:46 +00:00
wxiaoguang 25f3ec5b65 Fix natural sort (#31384)
Fix #31374
2024-06-17 06:45:12 +00:00
wxiaoguang f5dfd7d73c Add a simple test for AdoptRepository (#31391)
Follow #31333
2024-06-17 01:18:35 +00:00
wxiaoguang f446e3b4ab Fix JS error when creating new issue (#31383)
Fix #31336
2024-06-16 02:07:21 +00:00
wxiaoguangandtdsds.com 84cbb6c4d2 Fix duplicate sub-path for avatars (#31365)
Fix #31361, and add tests

And this PR introduces an undocumented & debug-purpose-only config
option: `USE_SUB_URL_PATH`. It does nothing for end users, it only helps
the development of sub-path related problems.

And also fix #31366

Co-authored-by: @ExplodingDragon
2024-06-15 11:43:57 +08:00
wxiaoguangandsilverwind 47ca61d8ba Improve detecting empty files (#31332)
Co-authored-by: silverwind <me@silverwind.io>
2024-06-13 01:06:46 +00:00
wxiaoguang 4bf848a06b Make template Iif exactly match if (#31322) 2024-06-11 14:52:12 +00:00
wxiaoguang 5342a61124 Delete legacy cookie before setting new cookie (#31306)
Try to fix #31202
2024-06-11 11:31:23 +08:00
wxiaoguang 6106a61eff Remove sub-path from container registry realm (#31293)
Container registry requires that the "/v2" must be in the root, so the
sub-path in AppURL should be removed
2024-06-09 16:29:29 +08:00
wxiaoguang 0188d82e49 Fix some URLs whose sub-path is missing (#31289)
Fix #31285
2024-06-07 15:15:17 +00:00
wxiaoguang e728fd741b Fix Activity Page Contributors dropdown (#31264)
Fix #31261
2024-06-06 10:28:33 +08:00
wxiaoguang bd80225ec3 Make blockquote attention recognize more syntaxes (#31240)
Fix #31214
2024-06-04 15:35:29 +00:00
wxiaoguang fcc061ae44 Fix admin oauth2 custom URL settings (#31246)
Fix #31244
2024-06-04 23:06:21 +08:00
wxiaoguangandLunny Xiao 9000811118 Make pasted "img" tag has the same behavior as markdown image (#31235)
Fix #31230

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2024-06-04 12:19:41 +00:00
wxiaoguang a4275951ba Split sanitizer functions and fine-tune some tests (#31192) 2024-05-31 13:26:01 +00:00
wxiaoguang d612a24e3e Ignore FindRecentlyPushedNewBranches err (#31164)
Fix #31163
2024-05-30 02:24:22 +00:00
wxiaoguang 34daee6baf Fix markup preview (#31158)
Fix #31157

After:

![image](https://github.com/go-gitea/gitea/assets/2114189/4d918cce-cd0d-4601-9c81-4b32df1b0b38)
2024-05-29 16:28:55 +00:00
wxiaoguang 8fc2ec1872 Update pip related commands for docker (#31106)
Thanks to graelo and silverwind for figuring out the problem.

Fix #31101
2024-05-27 13:53:33 +00:00
wxiaoguang 20c40259f1 Fix missing memcache import (#31105)
Fix #31102
2024-05-27 13:43:32 +00:00
wxiaoguang fb1ad920b7 Refactor sha1 and time-limited code (#31023)
Remove "EncodeSha1", it shouldn't be used as a general purpose hasher
(just like we have removed "EncodeMD5" in #28622)

Rewrite the "time-limited code" related code and write better tests, the
old code doesn't seem quite right.
2024-05-20 15:12:50 +00:00
wxiaoguang de9bcd1d23 Avoid 500 panic error when uploading invalid maven package file (#31014)
PackageDescriptor.Metadata might be nil (and maybe not only for maven).
This is only a quick fix.

The new `if` block is written intentionally to avoid unnecessary
indenting to the existing code.
2024-05-20 06:44:16 +00:00
wxiaoguangandGiteabot f48cc501c4 Fix incorrect "blob excerpt" link when comparing files (#31013)
When comparing files between the base repo and forked repo, the "blob
excerpt" link should point to the forked repo, because the commit
doesn't exist in base repo.

Co-authored-by: Giteabot <teabot@gitea.io>
2024-05-20 05:57:57 +00:00
wxiaoguang b6574099ed Fix project column title overflow (#31011)
By the way:
* Re-format the "color.go" to Golang code style
* Remove unused `overflow-y: scroll;` from `.project-column` because
there is `overflow: visible`
2024-05-20 05:21:01 +00:00
wxiaoguang 47accfebbd Fix data-race during testing (#30999)
Fix #30992
2024-05-20 04:35:38 +00:00
wxiaoguang edbf74c418 Fix "force private" logic (#31012)
When creating a repo, the "FORCE_PRIVATE" config option should be
respected, `readonly` doesn't work for checkbox, so it should use
`disabled` attribute.
2024-05-20 00:56:45 +00:00
wxiaoguangandKN4CK3R 339bc8bc8f Improve reverse proxy documents and clarify the AppURL guessing behavior (#31003)
Fix #31002

1. Mention Make sure `Host` and `X-Fowarded-Proto` headers are correctly passed to Gitea
2. Clarify the basic requirements and move the "general configuration" to the top
3. Add a comment for the "container registry"
4. Use 1.21 behavior if the reverse proxy is not correctly configured

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-05-19 14:56:08 +00:00
wxiaoguang 821d2fc2a3 Simplify mirror repository API logic (#30963)
Fix #30921
2024-05-17 16:07:41 +00:00
wxiaoguang 740b6e1389 Fix JS error when editing a merged PR's title (#30990) 2024-05-16 13:04:25 +00:00
wxiaoguang effb405cae Always load or generate oauth2 jwt secret (#30942)
Fix #30923
2024-05-14 14:21:38 +00:00
wxiaoguang f4f4e18b14 Filter out duplicate action(activity) items for a repository (#30957)
Fix #20986
2024-05-14 13:47:03 +00:00
wxiaoguangandsilverwind 080486e47d Fix some UI regressions for commit list (#30920)
Close #30919

---------

Co-authored-by: silverwind <me@silverwind.io>
2024-05-10 12:58:05 +00:00
7424f27cf3 Check if reverse proxy is correctly configured (#30890)
Follow #27011
Follow #30885

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
2024-05-10 20:07:01 +08:00
wxiaoguang ed0fc2729e Add missing menu active item background back (#30897)
Fix #30578
2024-05-08 23:01:25 +00:00
wxiaoguang 3fdb2d4ad8 Fix incorrect issue form (#30881)
Fix #30864
2024-05-08 15:39:13 +00:00
wxiaoguangandKN4CK3R 67c1a07285 Refactor AppURL usage (#30885)
Fix #30883
Fix #29591

---------

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-05-07 08:26:13 +00:00
wxiaoguang 9c08637eae Make "sync branch" also sync object format and add tests (#30878) 2024-05-06 17:02:30 +00:00
wxiaoguang 7c613f100e Make sure git version&feature are always prepared (#30877)
Otherwise there would be more similar issues like #29287
2024-05-06 18:34:16 +02:00
wxiaoguang eda10cc2bb Fix some UI problems (dropdown/container) (#30849)
Follow #30345
Follow #30547

`ellipsis` / `white-space` shouldn't be put on the general dropdown components.
2024-05-06 07:17:22 +00:00
wxiaoguang ce8b11ae13 Fix some UI problems (install/checkbox) (#30854)
Fix the space between the box and label for checkboxes, and fix incorrect usages in "repo-issue.js"
2024-05-06 06:32:05 +00:00
wxiaoguang 982b20d259 Do not show monaco JS errors (#30862)
Fix #30861
2024-05-05 16:34:13 +00:00
wxiaoguang 5c236bd4c0 Fix issue/PR title edit (#30858)
1. "enter" doesn't work (I think it is the last enter support for #14843)
2. if a branch name contains something like `&`, then the branch selector doesn't update
2024-05-05 13:09:41 +00:00
wxiaoguang c7bb3aa034 Fix markdown URL parsing for commit ID (#30812) 2024-05-04 09:48:16 +08:00
wxiaoguang 0f3e717a1a Improve grep search (#30843)
Reduce the context line number to 1, make "git grep" search respect the
include/exclude patter, and fix #30785
2024-05-03 09:13:48 +00:00
wxiaoguang 53b55223d1 Ignore useless error message "broken pipe" (#30801)
Fix #30792
2024-05-03 02:39:36 +00:00
wxiaoguang 677032d36a Fix incorrect message id for releaes email (#30825)
Make generateMessageIDForRelease outputs the same format as
generateMessageIDForIssue (old `createReference`)
2024-05-02 15:24:21 +00:00
wxiaoguangandsilverwind eb8bb82e58 Fix activity heat map padding & locale (#30823)
Fix #30808

---------

Co-authored-by: silverwind <me@silverwind.io>
2024-05-02 13:22:55 +00:00
wxiaoguang 6ff2acc52c Fix issue card layout (#30800)
Fix #30788
2024-05-02 11:19:44 +00:00
wxiaoguang ebe6f4cad7 Fix branch selector UI (#30803)
Fix  #30802
2024-05-02 10:45:23 +00:00