Commit graph

4608 commits

Author SHA1 Message Date
oliverpool 6f00821f3d [REFACTOR] webhook slack endpoints 2024-03-27 15:38:38 +01:00
oliverpool 7e0965b02c [REFACTOR] webhook forgejo/gitea endpoints 2024-03-27 15:38:38 +01:00
oliverpool 8dfbbfef07 [REFACTOR] webhook matrix endpoints 2024-03-27 15:38:38 +01:00
Earl Warren e41e18f87e Merge pull request '[REFACTOR] webhook.Handler interface' (#2758) from oliverpool/forgejo:webhook_2_interface into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2758
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-27 13:45:04 +00:00
Earl Warren ac672fc3ff Merge pull request '[ACTIONS] port scheduled actions from Gitea' (#2826) from earl-warren/forgejo:wip-gitea-schedule into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2826
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-03-27 06:23:56 +00:00
wxiaoguang b73117127c
Escape paths for find file correctly (#30026)
Fix #30020

(cherry picked from commit 1cdc6c3a4ea28396788b2697f9cf257df161ff9a)
2024-03-26 19:04:27 +01:00
Lunny Xiao 196c8772a8
Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995)
(cherry picked from commit f8ab9dafb7a173a35e9308f8f784735b0f822439)

Conflicts:
	routers/web/repo/fork.go
	trivial context conflict, the file does not exist in Forgejo
2024-03-26 19:04:27 +01:00
wxiaoguang d4ea1c2559
Fix some pending problems (#29985)
These changes are quite independent and trivial, so I don't want to open
too many PRs.

* https://github.com/go-gitea/gitea/pull/29882#discussion_r1529607091
    * the `f.Close` should be called properly
* the error message could be more meaningful
(https://github.com/go-gitea/gitea/pull/29882#pullrequestreview-1942557935)
*
https://github.com/go-gitea/gitea/pull/29859#pullrequestreview-1942324716
    * the new translation strings don't take arguments
* https://github.com/go-gitea/gitea/pull/28710#discussion_r1443778807
    * stale for long time
*  #28140
    * a form was forgotten to be changed to work with backend code

(cherry picked from commit 226231ea27d4f2b0f09fa4efb39501507613b284)

Conflicts:
	templates/repo/issue/view_content/pull.tmpl
	discarded because unexplained
	templates/status/404.tmpl
	implemented differently in Forgejo
2024-03-26 19:04:26 +01:00
Zettat123 8848b0ea2b
Fix bugs in rerunning jobs (#29955)
Fix #28761
Fix #27884
Fix #28093

## Changes

### Rerun all jobs
When rerun all jobs, status of the jobs with `needs` will be set to
`blocked` instead of `waiting`. Therefore, these jobs will not run until
the required jobs are completed.

### Rerun a single job
When a single job is rerun, its dependents should also be rerun, just
like GitHub does
(https://github.com/go-gitea/gitea/issues/28761#issuecomment-2008620820).
In this case, only the specified job will be set to `waiting`, its
dependents will be set to `blocked` to wait the job.

### Show warning if every job has `needs`
If every job in a workflow has `needs`, all jobs will be blocked and no
job can be run. So I add a warning message.

<img
src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b"
width="480px" />

(cherry picked from commit 2f060c5834d81f0317c795fc281f9a07e03e5962)
2024-03-26 19:04:26 +01:00
wxiaoguang e5920b4a62
Refactor StringsToInt64s (#29967)
And close #27176

(cherry picked from commit cdb4d1a8db096d60dba04728924dab85def45b19)
2024-03-26 19:04:26 +01:00
Lunny Xiao d92c2048b3
Performance improvements for pull request list page (#29900)
This PR will avoid load pullrequest.Issue twice in pull request list
page. It will reduce x times database queries for those WIP pull
requests.

Partially fix #29585

---------

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit 62f8174aa2fae1481c7e17a6afcb731a5b178cd0)

Conflicts:
	models/activities/notification_list.go
	moved to models/activities/notification.go
2024-03-26 19:04:26 +01:00
Jason Song 18e95af24f
Restore deleted branches when syncing (#29898)
Regression of #29493. If a branch has been deleted, repushing it won't
restore it.

Lunny may have noticed that, but I didn't delve into the comment then
overlooked it:
https://github.com/go-gitea/gitea/pull/29493#discussion_r1509046867

The additional comments added are to explain the issue I found during
testing, which are unrelated to the fixes.

(cherry picked from commit f371f84fa3456c2a71470632b6458d81e4892a54)
2024-03-26 19:04:25 +01:00
Zettat123 0da787f237
Fix milestoneID filter bug in issue list (#29897)
Fix #29717

(cherry picked from commit 656d8e2267dbdbb595704d507a780533038bb7ed)
2024-03-26 19:04:25 +01:00
coldWater 664052fb0b
Fix missing error check of bufio.Scanner (#29882)
maybe more

(cherry picked from commit 0e183d81fc5283f9d2047472de580e4f04a046c1)
2024-03-26 19:04:25 +01:00
wxiaoguang fbf0b3d661
Only do counting when count_only=true for repo dashboard (#29884)
Ref: #29878
(cherry picked from commit b251e608c01392c947f84be387f956541bfea25c)
2024-03-26 19:04:25 +01:00
buckybytes 0d3ddec26c
Editor error message misleading due to re-used key. (#29859)
The error message:

`editor.file_changed_while_editing = The file contents have changed
since you started editing. <a target="_blank" rel="noopener noreferrer"
href="%s">Click here</a> to see them or <strong>Commit Changes
again</strong> to overwrite them.`

Is re-used in inappropriate contexts. The link in the key goes to a 404
when the key is used in a situation where the file contents have not
changed.

Added two new keys to differentiate commit id mismatch and push out of
date conditions.

(cherry picked from commit 16e360099d0a515d429538ec88cff1f3ede23fb4)
2024-03-26 19:04:25 +01:00
Nanguan Lin a2f4ab60e8
Fix missing code in the user profile (#29865)
fix #29820
deleted by
https://github.com/go-gitea/gitea/pull/29248/files#diff-2b0b591787f16325539485e648a09ab6d3177f47dc129cfe84a35ffe141dfd19L39-L62,
which causing malfunction of follow/unfollow and missing description in
the user profile page.

(cherry picked from commit 5ca65d33906ebbca1e502536ffef18942b541c1d)

Conflicts:
	routers/web/shared/user/header.go
	trivial context conflict because of user blocking code
2024-03-26 19:04:25 +01:00
Earl Warren a117dfd2b1
[ACTIONS] port scheduled actions from Gitea
Refs: https://codeberg.org/forgejo/forgejo/issues/2798
2024-03-26 16:51:56 +01:00
Gusted 0f79122053
[BUG] Detect protected branch on branch rename
- If a branch cannot be renamed due to a protected branch rule, show
this error in the UI instead of throwing an internal server error.
- Add integration test (also simplify the existing one).
- Resolves #2751
2024-03-26 15:58:52 +01:00
Zettat123 cf78141bdd
Fix an actions schedule bug (#28942)
In #28691, schedule plans will be deleted when a repo's actions unit is
disabled. But when the unit is enabled, the schedule plans won't be
created again.

This PR fixes the bug. The schedule plans will be created again when the
actions unit is re-enabled

(cherry picked from commit adc3598a75)
2024-03-25 16:27:32 +01:00
Lunny Xiao 3b3747ffe8
Fix schedule tasks bugs (#28691)
Fix #28157

This PR fix the possible bugs about actions schedule.

- Move `UpdateRepositoryUnit` and `SetRepoDefaultBranch` from models to
service layer
- Remove schedules plan from database and cancel waiting & running
schedules tasks in this repository when actions unit has been disabled
or global disabled.
- Remove schedules plan from database and cancel waiting & running
schedules tasks in this repository when default branch changed.

(cherry picked from commit 97292da960)

Conflicts:
	modules/actions/github.go
	routers/web/repo/setting/default_branch.go
	routers/web/repo/setting/setting.go
	services/repository/branch.go
	services/repository/setting.go
	tests/integration/actions_trigger_test.go
2024-03-25 16:25:02 +01:00
oliverpool 702152bfde [REFACTOR] webhook.Handler interface 2024-03-24 10:35:06 +01:00
Earl Warren 5a18b74632 Merge pull request '[TESTS] fail when log.Error is called' (#2657) from oliverpool/forgejo:fail_test_on_log_error into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2657
2024-03-24 07:28:31 +00:00
oliverpool 2d209f1130 drop log.Error in ReadRepoNotifications 2024-03-24 07:12:31 +01:00
oliverpool fb6bcf1029 packages/maven: log.Warn on bad request 2024-03-24 07:12:31 +01:00
oliverpool 7b576d0a5d activitypub: warn instead of error 2024-03-24 07:12:31 +01:00
oliverpool e7abda6a0d actions artifacts: warn instead of error on invalid request 2024-03-24 07:12:31 +01:00
Earl Warren 0bfd4ca532 Merge pull request 'Allow users to hide all "Add more units..." hints' (#2533) from algernon/forgejo:less-is-more into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2533
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-24 05:42:37 +00:00
Earl Warren b7c535dba8 Merge pull request '[TESTS] webhook forms creation and edition' (#2755) from oliverpool/forgejo:webhook_1_tests into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2755
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-24 05:35:07 +00:00
Earl Warren 33ede09135 Merge pull request '[PORT] Unify search boxes (gitea#29530)' (#2688) from snematoda/port-29530 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2688
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-24 05:33:13 +00:00
oliverpool 33a3ee1955 [TESTS] webhook forms creation and edition 2024-03-23 23:02:06 +01:00
wxiaoguang 44221a3cd7
Customizable "Open with" applications for repository clone (#29320)
Users could customize the "clone" menu with their own application URLs on the admin panel.

Replace #22378
Close #21121
Close #22149
2024-03-23 11:58:54 +01:00
Gergely Nagy 36147f580c
Allow users to hide all "Add more units..." hints
Repositories displaying an "Add more..." tab on the header is a neat way
to let people discover they can enable more units. However, displaying
it all the time for repository owners, even when they deliberately do
not want to enable more units gets noisy very fast.

As such, this patch introduces a new setting which lets people disable
this hint under the appearance settings.

Fixes #2378.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-03-21 08:15:51 +01:00
Gergely Nagy 8433f3aa09
Fix repo badges when the label or text contains dashes
shields.io uses dashes to separate parts of the badge it needs to
return. If our label or text parts contain dashes, we need to encode
those for shields.io to recognise what we want it to do, and to have the
correct text on the badge, too.

Fortunately, this is as simple as replacing all dashes with double
dashes in both the label and the text parts. We do not need to do the
same for the color, because that part is not user controlled.

This fixes the badges for cases when a workflow name includes dashes, or
when a release's tag name does.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-03-20 22:41:20 +01:00
Shiny Nematoda 4a061ca26c simplify template 2024-03-20 12:31:36 +00:00
Denys Konovalov 847f03b6a6 Unify search boxes (#29530)
Unify all but a few search boxes to use uniform style, uniform
translations and shared templates where possible.
Remove a few duplicated search templates, e. g. code search.

<details><summary>Example after screenshots:</summary>

![grafik](https://github.com/go-gitea/gitea/assets/47871822/e20e7d6b-c6be-4a47-b132-672766f41421)

![grafik](https://github.com/go-gitea/gitea/assets/47871822/d5b11b9c-c12f-4a29-8fb0-24e5aa511d18)

![grafik](https://github.com/go-gitea/gitea/assets/47871822/d86bb444-36c7-426d-9cf1-c634963dffb1)

![grafik](https://github.com/go-gitea/gitea/assets/47871822/a76c0319-0518-484a-a840-563d02b61198)

</details>

Also includes #29700

Co-authored-by: 6543 <6543@obermui.de>

---------

Co-authored-by: 6543 <m.huber@kithara.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
Conflicts:
	routers/web/repo/search.go
	templates/repo/home.tmpl
	templates/repo/search.tmpl
	templates/shared/repo_search.tmpl
2024-03-20 12:31:05 +00:00
Earl Warren 84f33ead4e Merge pull request '[BUG] Reflect Cargo index state in settings' (#2698) from gusted/forgejo-cargo-index into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2698
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-20 11:38:26 +00:00
Gusted 461f925554
[BUG] Reflect Cargo index state in settings
- Currently in the Cargo section of the packages setting menu two
buttons are always shown, "Initalize index" and "Rebuild index", however
only of these should be shown depending on the state of the index, if
there's no index the "Initalize index" button should be shown and if
there's an index the "Rebuild index" button should be shown. This patch
does exactly that.
- Resolves #2628
2024-03-20 09:17:49 +01:00
norohind d74f74a025
Fix PR creation via api between branches of same repo with head field namespaced (#26986)
Fix #20175

Current implementation of API does not allow creating pull requests
between branches of the same
repo when you specify *namespace* (owner of the repo) in `head` field in
http request body.

---

Although GitHub implementation of API allows performing such action and
since Gitea targeting
compatibility with GitHub API I see it as an appropriate change.

I'm proposing a fix to the described problem and test case which covers
this logic.

My use-case just in case:
https://github.com/go-gitea/gitea/issues/20175#issuecomment-1711283022

(cherry picked from commit ed02d1fab85c9b8206c0af84dcfc3792e61609cf)
2024-03-20 08:46:30 +01:00
yp05327 2da0628f18
Fix incorrect menu/link on webhook edit page (#29709)
Fix #29699

---------

Co-authored-by: silverwind <me@silverwind.io>
(cherry picked from commit 2da13675c0cfdc531044553636c3b74f2fda3eb4)
2024-03-20 08:46:29 +01:00
KN4CK3R 024bfb7f34
Use relative links for commits, mentions, and issues in markdown (#29427)
Fixes #29404

Use relative links for
- commits
- mentions
- issues

---------

Co-authored-by: silverwind <me@silverwind.io>
(cherry picked from commit 85c59d6c21e10ef9d3ccf11713548f50e47e920f)
2024-03-20 08:46:28 +01:00
6543 d9103449b3
Refactor to use optional.Option for issue index search option (#29739)
Signed-off-by: 6543 <6543@obermui.de>
(cherry picked from commit 7fd0a5b276aadcf88dcc012fcd364fe160a58810)
2024-03-20 08:46:28 +01:00
Lunny Xiao fc8799f269
Use Get but not Post to get actions artifacts (#29734)
(cherry picked from commit 171d3d9a3c891d107001094b9118d93b0b00c02c)

Conflicts:
	routers/web/web.go
2024-03-20 08:46:28 +01:00
Lunny Xiao d996c5d517
Some performance optimization on dashboard and issues page (#29010)
This PR do some loading speed optimization for feeds user interface
pages.
- Load action users batchly but not one by one.
- Load action repositories batchly but not one by one.
- Load action's Repo Owners batchly but not one by one.
- Load action's possible issues batchly but not one by one.
- Load action's possible comments batchly but not one by one.

(cherry picked from commit aed3b53abdd02a3ffbf9e8eb90272ff567333073)
2024-03-20 08:46:28 +01:00
pengqiseven e825d007b1
remove repetitive words (#29695)
Signed-off-by: pengqiseven <912170095@qq.com>
(cherry picked from commit 7f856d5d742dcb6febdb8a3f22cd9a8fecc69a4d)
2024-03-20 08:46:28 +01:00
Zettat123 2559c80bec
Add a warning for disallowed email domains (#29658)
Resolve #29660

Follow #29522 and #29609

Add a warning for disallowed email domains when admins manually add/edit
users.

Thanks @yp05327 for the
[comment](https://github.com/go-gitea/gitea/pull/29605#issuecomment-1980105119)

![image](https://github.com/go-gitea/gitea/assets/15528715/6737b221-a3a2-4180-9ef8-b846c10f96e0)

(cherry picked from commit 4129e0e79bbf30e4297efd33feb2602c40322d10)
2024-03-20 08:46:28 +01:00
Lunny Xiao 69ebc2f7d8
Use repo object format name instead of detecting from git repository (#29702)
It's unnecessary to detect the repository object format from git
repository. Just use the repository's object format name.

(cherry picked from commit 3c6fc25a77c37d50686caa495d27a31dcef7f75f)

Conflicts:
	services/pull/pull.go
2024-03-20 08:46:28 +01:00
Gusted 17ef8145a8 Merge pull request '[PORT] Refactor code_indexer to use an SearchOptions struct for PerformSearch (gitea#29724)' (#2686) from snematoda/port-29724 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2686
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-03-19 17:42:50 +00:00
oliverpool ce6db31efe Merge pull request '[Port] Sync branches to DB immediately when handle git hook calling gitea#29493' (#2684) from oliverpool/forgejo:sync_branch into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2684
Reviewed-by: Otto <otto@codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-03-19 08:37:30 +00:00
Ada 41676a8634 Fix #2512 /api/forgejo/v1/version auth check (#2582)
Add the same auth check and middlewares as the /v1/ API.
It require to export some variable from /v1 API, i am not sure if is the correct way to do

Co-authored-by: oliverpool <git@olivier.pfad.fr>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2582
Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Ada <ada@gnous.eu>
Co-committed-by: Ada <ada@gnous.eu>
2024-03-19 07:16:19 +00:00
Jason Song 375222a145 Sync branches first (gitea#29714)
Follow gitea#29493.

Sync branches to DB first, then trigger push events.
2024-03-18 17:39:34 +01:00
oliverpool 0a53eb838d use gitRepo.GetCommit directly
and give it a commitID instead of a branchName (a bit more correct and faster)
2024-03-18 17:38:58 +01:00
Jason Song 286d09203f Sync branches to DB immediately when handle git hook calling (gitea#29493)
Unlike other async processing in the queue, we should sync branches to
the DB immediately when handling git hook calling. If it fails, users
can see the error message in the output of the git command.

It can avoid potential inconsistency issues, and help #29494.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2024-03-18 17:38:01 +01:00
Gergely Nagy 921d1283ed
routers: Minor code cleanup in UsernameSubRoute
The `reloadParam` function already calls `context.UserAssignmentWeb`
with the same parameters, there's no need to do it again.

Change cherry picked from gitea#29751.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-03-18 13:28:20 +01:00
6543 d5319feb85 Refactor code_indexer to use an SearchOptions struct for PerformSearch (#29724)
similar to how it's already done for the issue_indexer

---
*Sponsored by Kithara Software GmbH*

Conflicts:
	routers/web/repo/search.go
2024-03-18 12:25:05 +00:00
Shiny Nematoda 773048afa1 fix #2501 2024-03-14 12:34:41 +00:00
oliverpool 98f1fe7944 Makefile: check git diff exit-code (#2651)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2651
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-03-14 10:38:58 +00:00
6543 38c3cc4eb7
Patch in exact search for meilisearch (#29671)
meilisearch does not have an search option to contorl fuzzynes per query
right now:
 - https://github.com/meilisearch/meilisearch/issues/1192
 - https://github.com/orgs/meilisearch/discussions/377
 - https://github.com/meilisearch/meilisearch/discussions/1096

so we have to create a workaround by post-filter the search result in
gitea until this is addressed.

For future works I added an option in backend only atm, to enable
fuzzynes for issue indexer too.
And also refactored the code so the fuzzy option is equal in logic to
code indexer

---
*Sponsored by Kithara Software GmbH*
Conflicts:
	routers/web/repo/search.go
	trivial context confict s/isMatch/isFuzzy/
2024-03-11 23:37:00 +07:00
Lunny Xiao 3d9afe8813
Move get/set default branch from git package to gitrepo package to hide repopath (#29126)
(cherry picked from commit 25b842df261452a29570ba89ffc3a4842d73f68c)

Conflicts:
	routers/web/repo/wiki.go
	services/repository/branch.go
	services/repository/migrate.go
	services/wiki/wiki.go
	also apply to Forgejo specific usage of the refactored functions
2024-03-11 23:36:59 +07:00
sillyguodong 6cb9e8d869
Make runs-on support variable expression (#29468)
As title.
Close issue: https://gitea.com/gitea/act_runner/issues/445
Follow: https://gitea.com/gitea/act/pulls/91

Move `getSecretsOfTask` and `getVariablesOfTask` under `models` because
of circular dependency issues.

(cherry picked from commit a1f5dd767729e30d07ab42fda80c19f30a72679f)
2024-03-11 23:36:59 +07:00
Lunny Xiao 76db6d9e74
Fix 500 when deleting account with incorrect password or unsupported login type (#29579)
Fix #26210

---------

Co-authored-by: Jason Song <i@wolfogre.com>
(cherry picked from commit ce8a98f8789a7e4e9ee97ab0abac6064d78fb1f6)
2024-03-11 23:36:59 +07:00
Lunny Xiao 95e682f104
Cache repository default branch commit status to reduce query on commit status table (#29444)
After repository commit status has been introduced on dashaboard, the
most top SQL comes from `GetLatestCommitStatusForPairs`.

This PR adds a cache for the repository's default branch's latest
combined commit status. When a new commit status updated, the cache will
be marked as invalid.

<img width="998" alt="image"
src="https://github.com/go-gitea/gitea/assets/81045/76759de7-3a83-4d54-8571-278f5422aed3">

(cherry picked from commit e308d25f1b2fe24b4735432b05e5e221879a2705)
2024-03-11 23:36:58 +07:00
Jason Song 963df82907
Detect broken git hooks (#29494)
Detect broken git hooks by checking if the commit id of branches in DB
is the same with the git repo.

It can help #29338 #28277 and maybe more issues.

Users could complain about actions, webhooks, and activities not
working, but they were not aware that it is caused by broken git hooks
unless they could see a warning.

<img width="1348" alt="image"
src="https://github.com/go-gitea/gitea/assets/9418365/2b92a46d-7f1d-4115-bef4-9f970bd695da">

It should be merged after #29493. Otherwise, users could see a ephemeral
warning after committing and opening the repo home page immediately.

And it also waits for #29495, since the doc link (the anchor part) will
be updated.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit a4bcfb8ef1d5b2b522f78c9560d53ddbdbb02218)
2024-03-11 23:36:58 +07:00
Zettat123 e7afba21ce
Skip email domain check when admins edit user emails (#29609)
Follow #29522

Administrators should be able to set a user's email address even if the
email address is not in `EMAIL_DOMAIN_ALLOWLIST`

(cherry picked from commit 136dd99e86eea9c8bfe61b972a12b395655171e8)
2024-03-11 23:36:58 +07:00
Zettat123 b6057a34db
Skip email domain check when admin users adds user manually (#29522)
Fix #27457

Administrators should be able to manually create any user even if the
user's email address is not in `EMAIL_DOMAIN_ALLOWLIST`.

(cherry picked from commit 4fd9c56ed09b31e2f6164a5f534a31c6624d0478)
2024-03-11 23:36:58 +07:00
wxiaoguang 9482b023a8
Make "/user/login" page redirect if the current user has signed in (#29583)
Fix #29582 and maybe more.
Maybe fix #29116

(cherry picked from commit df1268ca08aaacae54c775a8eec34006dfe365e0)
2024-03-11 23:36:58 +07:00
Lunny Xiao bb09ad2b63
Allow options to disable user ssh keys configuration from the interface on app.ini (#29447)
Follow #29275
Extract from #20549
Fix #24716

---------

Co-authored-by: delvh <dev.lh@web.de>
(cherry picked from commit 8e12ba34bab7e728ac93ccfaecbe91e053ef1c89)

Conflicts:
	custom/conf/app.example.ini
	trivial context conflict
2024-03-11 23:36:57 +07:00
Gusted 4dbf2d7c11 Merge pull request 'Better number for UserCards pagination' (#2584) from 0ko/forgejo:its39 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2584
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
2024-03-11 15:53:59 +00:00
0ko 498a3f988d Better number for UserCards pagination 2024-03-07 13:30:12 +05:00
KN4CK3R 8f55cf199d
Port "Fix wrong test usage of AppSubURL"
- Port of https://github.com/go-gitea/gitea/pull/29459
- The tests use an invalid `setting.AppSubURL`. The wrong behaviour
disturbs other PRs like https://github.com/go-gitea/gitea/pull/29222
and https://github.com/go-gitea/gitea/pull/29427.
2024-03-06 21:47:44 +01:00
wxiaoguang de6768ed54
Add an trailing slash to dashboard links (#29555)
Fix #29533, and add some tests for "base/paginate.tmpl"

(cherry picked from commit 8553b4600e3035b6f6ad6907c37cebd013fa4d64)

Conflicts:
	services/contexttest/context_tests.go
	trivial conflict because
	"Improve user experience for outdated comments" was skipped
2024-03-06 12:10:47 +08:00
Nanguan Lin c69a0bb506
Fix 500 when pushing release to an empty repo (#29554)
As title.
The former code directly used `ctx.Repo.GitRepo`, causing 500.

22b4f0c09f/routers/api/v1/repo/release.go (L241)
(cherry picked from commit 6e2aafd5130cb9436f02209ae90bf79a58cc13ae)
2024-03-06 12:10:47 +08:00
Tim-Niclas Oelschläger 83e04328df
Filter Repositories by type (#29231)
Filter Repositories by type (resolves #1170, #1318)

before:

![image](https://github.com/go-gitea/gitea/assets/72873130/74e6be62-9010-4ab4-8f9b-bd8afbebb8fb)

after:

![image](https://github.com/go-gitea/gitea/assets/72873130/e4d85ed6-7864-4150-8d72-5194dac1293f)

(cherry picked from commit e3524c63d6d42865ea8288af89b372544d35474b)
2024-03-06 12:10:46 +08:00
wxiaoguang ff7a032c74
Fix incorrect cookie path for AppSubURL (#29534)
Regression of #24107

(cherry picked from commit 44398e405ffe297997c6b9c8dbb97f966926b65a)
2024-03-06 12:10:46 +08:00
6543 318634ef74
Add option to set language in admin user view (#28449)
![image](https://github.com/go-gitea/gitea/assets/24977596/be7e3f92-af3f-4628-b4ed-abf6439687f3)
`/admin/users/<UserID>/edit`

![image](https://github.com/go-gitea/gitea/assets/24977596/906af0dd-cceb-4ed9-9cd9-32c71ae1bf71)
`/admin/users/<UserID>`

---
*Sponsored by Kithara Software GmbH*

(cherry picked from commit e3e6569c5fd8c69aa65384e6d1636cc14b23a32b)
2024-03-06 12:10:46 +08:00
Yarden Shoham 1e29bccddb
Fix elipsis button not working if the last commit loading is deferred (#29544)
Before this change, if we had more than 200 entries being deferred in
loading, the entire table would get replaced thus losing any event
listeners attached to the elements within the table, such as the elipsis
button and commit list with tippy.

With this change we remove the previous javascript code that replaced
the table and use htmx to replace the table.

htmx attributes added:
- `hx-indicator="tr.notready td.message span"`: attach the loading
spinner to the files whose last commit is still being loaded
- `hx-trigger="load"` trigger the request-replace behavior as soon as
possible
- `hx-swap="morph"`: use the idiomorph morphing algorithm, this is the
thing that makes it so the elipsis button event listener is kept during
the replacement, fixing the bug because we don't actually replace the
table, only modifying it
- `hx-post="{{.LastCommitLoaderURL}}"`: make a post request to this url
to get the table with all of the commit information

As part of this change I removed the handling of partial replacement in
the case we have less than 200 "not ready" files. The first reason is
that I couldn't make htmx replace only a subset of returned elements,
the second reason is that we have a cache implemented in the backend
already so the only cost added is that we query the cache a few times
(which is sure to be populated due to the initial request), and the last
reason is that since the last refactor of this functionality that
removed jQuery we don't properly send the "not ready" entries as the
backend expects `FormData` with `f[]` and we send a JSON with `f` so we
always query for all rows anyway.

# Before

![before](https://github.com/go-gitea/gitea/assets/20454870/482ebfec-66c5-40cc-9c1e-e3b3bfe1bbc1)

# After

![after](https://github.com/go-gitea/gitea/assets/20454870/454c517e-3a4e-4006-a49f-99cc56e0fd60)

---------

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
(cherry picked from commit 937e8b55149388840bbf6c4d7216495bc3dd2fe9)
2024-03-06 12:10:46 +08:00
wxiaoguang 12441d7c5c
Fix incorrect relative/absolute URL usages (#29531)
Add two "HTMLURL" methods for PackageDescriptor.
And rename "FullWebLink" to "VersionWebLink"

(cherry picked from commit bf6502a8f7a2e9a2b64b43b7733316d863c9a768)
2024-03-06 12:10:46 +08:00
KN4CK3R 47a913d40d
Add support for API blob upload of release attachments (#29507)
Fixes #29502

Our endpoint is not Github compatible.

https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset

---------

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit 70c126e6184872a6ac63cae2f327fc745b25d1d7)
2024-03-06 12:10:46 +08:00
6543 e2371743d5
remove util.OptionalBool and related functions (#29513)
and migrate affected code

_last refactoring bits to replace **util.OptionalBool** with
**optional.Option[bool]**_

(cherry picked from commit a3f05d0d98408bb47333b19f505b21afcefa9e7c)

Conflicts:
	services/repository/branch.go
	trivial context conflict
2024-03-06 12:10:46 +08:00
wxiaoguang 221a28436a
Make PR form use toast to show error message (#29545)
![image](https://github.com/go-gitea/gitea/assets/2114189/b7a14ed6-db89-4f21-a590-66cd33307233)

(cherry picked from commit 27deea7330f83ddb37c918afbb4159053d8847cb)
2024-03-06 12:10:46 +08:00
wxiaoguang db19d4eb39
Fix incorrect redirection when creating a PR fails (#29537)
This is only a quick fix to make it easier to backport.

After this PR gets merged, I will propose a new PR to fix the FIXME.

<details>

![image](https://github.com/go-gitea/gitea/assets/2114189/98d1d5c4-2e79-4a75-80e9-76fd898986e0)

</details>

(cherry picked from commit e650f64d812f5ebeb4a11d2ec20f2376c6d963bc)
2024-03-06 12:10:45 +08:00
ChristopherHX 66632c4958
Actions Artifacts v4 backend (#28965)
Fixes #28853

Needs both https://gitea.com/gitea/act_runner/pulls/473 and
https://gitea.com/gitea/act_runner/pulls/471 on the runner side and
patched `actions/upload-artifact@v4` / `actions/download-artifact@v4`,
like `christopherhx/gitea-upload-artifact@v4` and
`christopherhx/gitea-download-artifact@v4`, to not return errors due to
GHES not beeing supported yet.

(cherry picked from commit a53d268aca87a281aadc2246541f8749eddcebed)
2024-03-06 12:10:45 +08:00
Lunny Xiao ee6ff937c0
Allow options to disable user gpg keys configuration from the interface on app.ini (#29486)
Follow #29447
Fix #29454
Extract from #20549

(cherry picked from commit 9de5e39e25009bacc5ca201ed97e9cbb623e56e9)

Conflicts:
	custom/conf/app.example.ini
	docs/content/administration/config-cheat-sheet.en-us.md
	docs/content/administration/config-cheat-sheet.zh-cn.md
	trivial context conflict
2024-03-06 12:10:45 +08:00
wxiaoguang 2892aaab02
Rename Str2html to SanitizeHTML and clarify its behavior (#29516)
Str2html was abused a lot. So use a proper name for it: SanitizeHTML

And add some tests to show its behavior.

(cherry picked from commit fb42972c057364a1dc99dfb528554e7a94415be7)

Conflicts:
	docs/content/administration/mail-templates.en-us.md
	docs/content/administration/mail-templates.zh-cn.md
	prefer their version always
2024-03-06 12:10:45 +08:00
wxiaoguang 68099f2f00
Refactor some Str2html code (#29397)
This PR touches the most interesting part of the "template refactoring".

1. Unclear variable type. Especially for "web/feed/convert.go":
sometimes it uses text, sometimes it uses HTML.
2. Assign text content to "RenderedContent" field, for example: `
project.RenderedContent = project.Description` in web/org/projects.go
3. Assign rendered content to text field, for example: `r.Note =
rendered content` in web/repo/release.go
4. (possible) Incorrectly calling `{{Str2html
.PackageDescriptor.Metadata.ReleaseNotes}}` in
package/content/nuget.tmpl, I guess the name Str2html misleads
developers to use it to "render string to html", but it only sanitizes.
if ReleaseNotes really contains HTML, then this is not a problem.

(cherry picked from commit e71eb8930a5d0f60874b038c223498b41ad65592)

Conflicts:
	modules/templates/util_string.go
	trivial context conflict
2024-03-06 12:10:44 +08:00
6543 d3d70198b0
migrate some more "OptionalBool" to "Option[bool]" (#29479)
just some refactoring bits towards replacing **util.OptionalBool** with
**optional.Option[bool]**

---------

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
(cherry picked from commit f6656181e4a07d6c415927220efa2077d509f7c6)

Conflicts:
	models/repo/repo_list_test.go
	trivial shared fixture count conflicts
2024-03-06 12:10:44 +08:00
wxiaoguang 9c5afa0b8f
Fix incorrect user location link on profile page (#29474)
Fix #29472. Regression of #29236, a "if" check was missing.

(cherry picked from commit 10cfa0879a538a470598281d7093de3555c018be)
2024-03-06 12:10:44 +08:00
Lunny Xiao 46fca90cfc
Move generate from module to service (#29465)
(cherry picked from commit b5188cd55c535a588492fb4e153d646ec4f3232a)
2024-03-06 12:10:44 +08:00
6543 7b23949f29
Let ctx.FormOptionalBool() return optional.Option[bool] (#29461)
just some refactoring bits towards replacing **util.OptionalBool** with
**optional.Option[bool]**

(cherry picked from commit 274c0aea2e88db9bc41690c90e13e8aedf6193d4)
2024-03-06 12:10:43 +08:00
Lunny Xiao c498c07adf
Fix missed return (#29450)
(cherry picked from commit e9f4c2db8291c54044345aebd9381ac820ed9687)
2024-03-06 12:10:43 +08:00
wxiaoguang 459ee98136
Only use supported sort order for "explore/users" page (#29430)
Thanks to inferenceus : some sort orders on the "explore/users" page
could list users by their lastlogintime/updatetime.

It leaks user's activity unintentionally. This PR makes that page only
use "supported" sort orders.

Removing the "sort orders" could also be a good solution, while IMO at
the moment keeping the "create time" and "name" orders is also fine, in
case some users would like to find a target user in the search result,
the "sort order" might help.

![image](https://github.com/go-gitea/gitea/assets/2114189/ce5c39c1-1e86-484a-80c3-33cac6419af8)

(cherry picked from commit eedb8f41297c343d6073a7bab46e4df6ee297a90)
2024-03-06 12:10:43 +08:00
sillyguodong 997350a68d
Not trigger all jobs any more, when re-running the first job (#29439)
Previously, it will be treated as "re-run all jobs" when `jobIndex ==
0`. So when you click re-run button on the first job, it triggers all
the jobs actually.

(cherry picked from commit bad4ad70181c747599e206c0e7a87b57c997385d)
2024-03-06 12:10:43 +08:00
Lunny Xiao 894d9b2836
Move context from modules to services (#29440)
Since `modules/context` has to depend on `models` and many other
packages, it should be moved from `modules/context` to
`services/context` according to design principles. There is no logic
code change on this PR, only move packages.

- Move `code.gitea.io/gitea/modules/context` to
`code.gitea.io/gitea/services/context`
- Move `code.gitea.io/gitea/modules/contexttest` to
`code.gitea.io/gitea/services/contexttest` because of depending on
context
- Move `code.gitea.io/gitea/modules/upload` to
`code.gitea.io/gitea/services/context/upload` because of depending on
context

(cherry picked from commit 29f149bd9f517225a3c9f1ca3fb0a7b5325af696)

Conflicts:
	routers/api/packages/alpine/alpine.go
	routers/api/v1/repo/issue_reaction.go
	routers/install/install.go
	routers/web/admin/config.go
	routers/web/passkey.go
	routers/web/repo/search.go
	routers/web/repo/setting/default_branch.go
	routers/web/user/home.go
	routers/web/user/profile.go
	tests/integration/editor_test.go
	tests/integration/integration_test.go
	tests/integration/mirror_push_test.go
	trivial context conflicts
	also modified all other occurrences in Forgejo specific files
2024-03-06 12:10:43 +08:00
yp05327 480c61432a
Fix logic error from #28138 (#29417)
There's a miss in #28138:

![image](https://github.com/go-gitea/gitea/assets/18380374/b1e0c5fc-0e6e-44ab-9f6e-34bc8ffbe1cc)

https://github.com/go-gitea/gitea/pull/28138/files#diff-2556e62ad7204a230c91927a3f2115e25a2b688240d0ee1de6d34f0277f37dfeR162

@lunny
Not sure about the impact of this, but it will only effect 1.22, and
maybe we should fix it ASAP.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
(cherry picked from commit f8c1efe944c539396402fb014bbfdb67ba199ef2)
2024-03-06 12:10:43 +08:00
Earl Warren 21b1381e36 Merge pull request 'Move migration functions to services layer - port of gitea#29497' (#2546) from algernon/forgejo:gitea/port/29497 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2546
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-04 10:01:26 +00:00
Lunny Xiao c41b2c73ef
Display tag name as title for a tag with no release 2024-03-04 07:41:49 +01:00
Lunny Xiao ff8cb299d1
Move migration functions to services layer (#29497) 2024-03-04 07:10:53 +01:00
Earl Warren 3f68525ae4 Merge pull request '[BUG] Fix header name in swagger response' (#2526) from gusted/forgejo-header into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2526
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-02 21:16:11 +00:00
Gusted c63b52c126
[FEAT] Show follow symlink button
- When a user goes opens a symlink file in Forgejo, the file would be
rendered with the path of the symlink as content.
- Add a button that is shown when the user opens a *valid* symlink file,
which means that the symlink must have an valid path to an existent
file and after 999 follows isn't a symlink anymore.
- Return the relative path from the `FollowLink` functions, because Git
really doesn't want to tell where an file is located based on the blob ID.
- Adds integration tests.
2024-03-02 17:58:09 +01:00
Gusted abe3351187 Merge pull request '[BUG] Allow to select commit email for file updload/delete' (#2383) from 0ko/forgejo:fix-commit-del into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2383
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-03-02 12:00:45 +00:00