Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 01:44:24 +01:00
Commit graph

17187 commits

Author SHA1 Message Date
Gusted 1891dac547
[GITEA] Adjust name of operation
- The name could be conflucted with the `GET
/user/applications/oauth2/{id}` operation, as it only differed in a
single letter being uppercase. Change it to be
userGetOAuth2Application**s**, as that's also more accurate for this function.
- Resolves #2163
2024-01-20 22:33:36 +01:00
Gusted 05bc80633d Merge pull request '[GITEA] Limit amount of javascript errors being shown' (#2175) from gusted/forgejo-wall-of-errors into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2175
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-01-19 21:23:06 +00:00
Gusted c023e6d23f Merge pull request '[GITEA] Fix API inconsistencies' (#2182) from gusted/forgejo-api-fixes into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2182
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-01-19 13:23:56 +00:00
Earl Warren ab270b3cd7 Merge pull request 'Cleanup characters forbidden on Windows from test fixture filenames' (#2178) from wetneb/forgejo:2156-windows-cloning into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2178
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-01-19 12:50:32 +00:00
Gusted 6c8c4512b5
[GITEA] Fix API inconsistencies
- Document the correct content types for Git archives. Add code that
actually sets the correct application type for `.zip` and `.tar.gz`.
- When an action (POST/PUT/DELETE method) was successful, an 204 status
code should be returned instead of status code 200.
- Add and adjust integration testing.
- Resolves #2180
- Resolves #2181
2024-01-19 01:19:01 +01:00
Antonin Delpeuch cb9b8a31b2 fixup! [GITEA] Avoid conflicts of issue and PR numbers in GitLab migration (#1790) (squash) 2024-01-18 23:25:49 +01:00
Antonin Delpeuch e74e262030 fixup! [GITEA] Enable mocked HTTP responses for GitLab migration test (squash) 2024-01-18 23:25:45 +01:00
Gusted 424a745c4a
[GITEA] Limit amount of javascript errors being shown
- Currently an unlimited amount of errors could be shown to the user,
this can cause that if something goes wrong the user will be shown a big
wall of errors, even when Forgejo in most cases can still be used.
- Therefor limit to three errors being shown, as it's unlikely that
three seperate javascript errors needs to be shown, they are likely to
be related and the console still shows all of the errors.
2024-01-18 19:42:34 +01:00
Earl Warren 17f52b1c90 Merge pull request '[GITEA] Revert "Fix schedule tasks bugs (#28691)"' (#2172) from earl-warren/forgejo:wip-scheduled-actions into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2172
Reviewed-by: Loïc Dachary <dachary@noreply.codeberg.org>
2024-01-18 17:34:47 +00:00
Earl Warren e562b6f7a0
[ACTIONS] on.schedule: the event is always "schedule"
handleSchedules() is called every time an event is received and will
check the content of the main branch to (re)create scheduled events.
There is no reason why intput.Event will be relevant when the schedule
workflow runs.

(cherry picked from commit 9a712bb276)
(cherry picked from commit 41af36da81)
(cherry picked from commit bb83604fa2)
(cherry picked from commit 65e4503a7a)
2024-01-18 16:41:21 +00:00
Earl Warren 72954836a4
Revert "Fix schedule tasks bugs (#28691)" (part 2)
This function is now being used elsewhere and cannot be reverted. Only
the part that was modified in addition to being moved is deleted.
2024-01-18 16:41:21 +00:00
Earl Warren 3249d2806c
Revert "Fix schedule tasks bugs (#28691)"
This reverts commit 97292da960.
2024-01-18 16:09:06 +00:00
Earl Warren dce3a7c0f6
Revert "[ACTIONS] on.schedule: the event is always "schedule""
This reverts commit 9a08db699c.
2024-01-18 16:09:06 +00:00
Earl Warren 074f67ab6f Merge pull request 'Improved Linguist compatibility' (#2088) from algernon/forgejo:b/language-stats-should-not-skip-docs into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2088
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-01-18 14:44:36 +00:00
Earl Warren 66a2d07ed2 Merge pull request '[GITEA] POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments (squash) do not implicitly create a review' (#2169) from earl-warren/forgejo:wip-api-review into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2169
Reviewed-by: Loïc Dachary <dachary@noreply.codeberg.org>
2024-01-18 14:24:04 +00:00
Earl Warren 6a555996dc
[GITEA] POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments (squash) do not implicitly create a review
If a comment already exists in a review, the comment is added. If it
is the first comment added to a review, it will implicitly create a
new review instead of adding to the existing one.

The pull_service.CreateCodeComment function is responsibe for this
behavior and it will defer to createCodeComment once the review is
determined, either because it was found or because it was created.

Rename createCodeComment into CreateCodeCommentKnownReviewID to expose
it and change the API endpoint to use it instead. Since the review is
provided by the user and verified to exist already, there is no need
for the logic implemented by CreateCodeComment.

The tests are modified to remove the initial comment from the fixture
because it was creating the false positive. I was verified to fail
without this fix.
2024-01-18 11:09:05 +00:00
Earl Warren b145764e86 Merge pull request '[GITEA] DELETE /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}' (#2157) from earl-warren/forgejo:wip-api-review into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2157
Reviewed-by: Loïc Dachary <dachary@noreply.codeberg.org>
2024-01-18 10:25:18 +00:00
Earl Warren 5b90ab77f6
[GITEA] DELETE /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}
* reuse deleteIssueComment by adding the commentType parameter
* ensure tests start with a PR with no random reviews from fixtures

Refs: https://codeberg.org/forgejo/forgejo/issues/2109
2024-01-18 09:30:47 +00:00
Earl Warren d47fb3737a Merge pull request '[GITEA] Fix relative links rendering' (#2166) from gusted/forgejo-relative-links into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2166
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2024-01-17 18:55:50 +00:00
Gusted 0e9d52e291
[GITEA] Fix relative links rendering
- Relative links were not properly being rendered, because the links
were being made absolute against the repository URL instead of
repository URL + /src/branch, which leads to incorrect links.
- Restore the 'old' behaviour. When there's branch information, that
should be used as base for links.
- Adjusts the test cases.
- Regression of 637451a45e
- Resolves https://codeberg.org/Codeberg/Community/issues/1411
2024-01-17 17:45:55 +01:00
Gergely Nagy 6d4e02fe5f
Improved Linguist compatibility
Recognise the `linguist-documentation` and `linguist-detectable`
attributes in `.gitattributes` files, and use them in
`GetLanguageStats()` to make a decision whether to include a particular
file in the stats or not.

This allows one more control over which files in their repositories
contribute toward the language statistics, so that for a project that is
mostly documentation, the language stats can reflect that.

Fixes #1672.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-01-15 22:02:53 +01:00
Earl Warren fed50cf72e
[GITEA] Optionally allow anyone to edit Wikis (squash) AddTokenAuth 2024-01-15 16:56:41 +00:00
Earl Warren 1296f4d115
[GITEA] GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}
Refs: https://codeberg.org/forgejo/forgejo/issues/2109
(cherry picked from commit 69fcf26dee)
2024-01-15 16:51:46 +00:00
Earl Warren 09db07aeae
[GITEA] API commentAssignment() to verify the id belongs
Instead of repeating the tests that verify the ID of a comment
is related to the repository of the API endpoint, add the middleware
function commentAssignment() to assign ctx.Comment if the ID of the
comment is verified to be related to the repository.

There already are integration tests for cases of potential unrelated
comment IDs that cover some of the modified endpoints which covers the
commentAssignment() function logic.

* TestAPICommentReactions - GetIssueCommentReactions
* TestAPICommentReactions - PostIssueCommentReaction
* TestAPICommentReactions - DeleteIssueCommentReaction
* TestAPIEditComment - EditIssueComment
* TestAPIDeleteComment - DeleteIssueComment
* TestAPIGetCommentAttachment - GetIssueCommentAttachment

The other modified endpoints do not have tests to verify cases of
potential unrelated comment IDs. They no longer need to because they
no longer implement the logic to enforce this. They however all have
integration tests that verify the commentAssignment() they now rely on
does not introduce a regression.

* TestAPIGetComment - GetIssueComment
* TestAPIListCommentAttachments - ListIssueCommentAttachments
* TestAPICreateCommentAttachment - CreateIssueCommentAttachment
* TestAPIEditCommentAttachment - EditIssueCommentAttachment
* TestAPIDeleteCommentAttachment - DeleteIssueCommentAttachment

(cherry picked from commit d414376d74)
2024-01-15 16:51:46 +00:00
Gusted 8602dfa6a2
[GITEA] Fix test TestWebhookProxy with http proxy env
- Unset the http proxies environments for the `TestWebhookProxy`.
- Resolves #2132

(cherry picked from commit 244b9786fc)
2024-01-15 16:51:46 +00:00
Gergely Nagy 2527e09125
[GITEA] Include a branch link in the recently pushed banner
The message telling us that we recently pushed on a branch should
include a link to said branch, not just a "New pull request" button.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit d9662d03a4)
2024-01-15 16:51:45 +00:00
Gergely Nagy 06b808fa2c
[GITEA] Fix the topic search paging
When searching for repository topics, either via the API, or via
Explore, paging did not work correctly, because it only applied when the
`page` parameter was non-zero. Paging should have applied when the page
size is greater than zero, which is what this patch does.

As a result, both the API, and the Explore endpoint will return paged
results (30 by default). As such, when managing topics on the frontend,
the offered completions will also be limited to a pageful of results,
based on what the user has already typed.

This drastically reduces the amount of traffic, and also the number of
the topics to choose from, and thus, the rendering time too.

The topics will be returned by popularity, with most used topics first.
A single page will contain `[api].DEFAULT_PAGING_NUM` (30 by default)
items that match the query. That's plenty to choose from.

Fixes #132.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 64d4ff41db)
2024-01-15 16:51:45 +00:00
Gusted 96dd3e87cf
[GITEA] Log SQL queries when the database return error
- When the database returns an error about the SQL query, the error is
logged but not the SQL query and arguments, which is just as valuable as
the vague deeply hidden documented error that the database returns.
It's possible to log the SQL query by logging **all** SQL queries. For
bigger instances such as Codeberg, this is not a viable option.
- Adds a new hook, enabled by default, to log SQL queries with their
arguments and the error returned by the database when the database
returns an error.
- This likely needs some fine tuning in the future to decide when to
enable this, as the error is already logged and if people have the
`[database].LOG_SQL` option enabled, the SQL would be logged twice. But
given that it's an rare occurence for SQL queries to error, it's fine to
leave that as-is.
- Ref: https://codeberg.org/forgejo/forgejo/issues/1998

(cherry picked from commit 866229bc32)
2024-01-15 16:51:45 +00:00
Gergely Nagy 439fadf563
[GITEA] services: Gracefully handle missing branches
services: in loadOneBranch, return if CountDivergingCommits fail

If we can't count the number of diverging commits for one reason or
another (such as the branch being in the database, but missing from
disk), rather than logging an error and continuing into a crash (because
`divergence` will be nil), return an error instead.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 8266105f24)

services: Gracefully handle missing branches

When loading branches, if loading one fails, log an error, and ignore
the branch, rather than returning and causing an internal server error.

Ideally, we would only ignore the error if it was caused by a missing
branch, and do it silently, like the respective API endpoint does.
However, veryfing that at this place is not very practical, so for the
time being, ignore any and all branch loading errors.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit e552a8fd62)

tests: Add a testcase for missing branches

This tests the scenario reported in Codeberg/Community#1408: a branch
that is recorded in the database, but missing on disk was causing
internal server errors. With recent changes, that is no longer the case,
the error is logged and then ignored.

This test case tests this behaviour, that the repo's branches page on
the web UI functions even if the git branch is missing.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit e20eb7b385)

tests: More testing in TestDatabaseMissingABranch

In the `TestDatabaseMissingABranch` testcase, make sure that the
branches are in sync between the db and git before deleting a branch via
git, then compare the branch count from the web UI, making sure that it
returns an out-of-sync value first, and the correct one after another
sync.

This is currently tested by scraping the UI, and relies on the fact that
the branch counter is out of date before syncing. If that issue gets
resolved, we'll have to adjust the test to verify the sync another way.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 8c2ccfcece)
2024-01-15 16:51:45 +00:00
Gusted 30d168bcc8
[GITEA] Fix panic in canSoftDeleteContentHistory
- It's possible that `canSoftDeleteContentHistory` is called without
`ctx.Doer` being set, such as an anonymous user requesting the
`/content-history/detail` endpoint.
- Add a simple condition to always set to `canSoftDelete` to false if an
anonymous user is requesting this, this avoids a panic in the code that
assumes `ctx.Doer` is set.
- Added integration testing.

(cherry picked from commit 0b5db0dcc6)
2024-01-15 16:51:45 +00:00
Earl Warren 196edea0f9
[GITEA] POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments
Refs: https://codeberg.org/forgejo/forgejo/issues/2109
(cherry picked from commit 8b4ba3dce7)
2024-01-15 16:51:45 +00:00
Gusted ef5e1b01b8
[GITEA] Improve 404 screen on mobile
- Remove `container` to remove unnecessary margins being added to the
whole page.
- Specify max width for the 404 image to avoid overflow of the image.

(cherry picked from commit b1ced72ce5)
2024-01-15 16:51:45 +00:00
Gergely Nagy e7f5c1ba14
[FEAT] API support for repository flags
Expose the repository flags feature over the API, so the flags can be
managed by a site administrator without using the web API.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit bac9f0225d)
2024-01-15 16:51:45 +00:00
Gergely Nagy f09f6e029b
[FEAT] Repository flags
This implements "repository flags", a way for instance administrators to
assign custom flags to repositories. The idea is that custom templates
can look at these flags, and display banners based on them, Forgejo does
not provide anything built on top of it, just the foundation. The
feature is optional, and disabled by default. To enable it, set
`[repository].ENABLE_FLAGS = true`.

On the UI side, instance administrators will see a new "Manage flags"
tab on repositories, and a list of enabled tags (if any) on the
repository home page. The "Manage flags" page allows them to remove
existing flags, or add any new ones that are listed in
`[repository].SETTABLE_FLAGS`.

The model does not enforce that only the `SETTABLE_FLAGS` are present.
If the setting is changed, old flags may remain present in the database,
and anything that uses them, will still work. The repository flag
management page will allow an instance administrator to remove them, but
not set them, once removed.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit ba735ce222)
2024-01-15 16:51:45 +00:00
Gergely Nagy 70cb266760
[GITEA] Disable the RSS feed in file view for non-branches
Files can have an RSS feed, but those only make sense when taken in the
context of a branch. There is no history to make a feed of on a tag or a
commit: they're static. Forgejo does not provide a feed for them for
this reason.

However, the file view on the web UI was offering a link to these
non-existent feeds. With this patch, it does that no longer, and only
provides a link when viewing the file in the context of a branch.

Fixes #2102.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 4b48d21ea7)
2024-01-15 16:51:45 +00:00
Earl Warren 0077b2661e
[GITEA] add option for banning dots in usernames (squash) set in test
(cherry picked from commit b005b586c3)
2024-01-15 16:51:45 +00:00
Gergely Nagy 3975a9f3aa
[GITEA] Find README.md for user profiles case insensitively
When trying to find a `README.md` in a `.profile` repo, do so case
insensitively. This change does not make it possible to render readmes
in formats other than Markdown, it just removes the hard-coded
"README.md".

Also adds a few tests to make sure the change works.

Fixes #1494.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit edd219d8e9)
(cherry picked from commit 2c0105ef17)
2024-01-15 16:51:45 +00:00
Gusted 6b7c7d18dc
[GITEA] Check for Commit in opengraph
- It's possible that `PageIsDiff` is set but not `Commit` resulting in a
NPE in the template. This can happen when the requested commit doesn't exist.
- Regression of c802c46a9b &
5743d7cb5b
- Added 'hacky' integration test.

(cherry picked from commit 8db2d5e4a7)
(cherry picked from commit 8c737a802b)
2024-01-15 16:51:45 +00:00
Gergely Nagy 4359741431
[GITEA] Add support for shields.io-based badges
Adds a new `/{username}/{repo}/badges` family of routes, which redirect
to various shields.io badges. The goal is to not reimplement badge
generation, and delegate it to shields.io (or a similar service), which
are already used by many. This way, we get all the goodies that come
with it: different styles, colors, logos, you name it.

So these routes are just thin wrappers around shields.io that make it
easier to display the information we want. The URL is configurable via
`app.ini`, and is templatable, allowing to use alternative badge
generator services with slightly different URL patterns.

Additionally, for compatibility with GitHub, there's an
`/{username}/{repo}/actions/workflows/{workflow_file}/badge.svg` route
that works much the same way as on GitHub. Change the hostname in the
URL, and done.

Fixes gitea#5633, gitea#23688, and also fixes #126.

Work sponsored by Codeberg e.V.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit fcd0f61212)
(cherry picked from commit 20d14f7844)
2024-01-15 16:51:45 +00:00
Gergely Nagy c3a8e98870
[GITEA] repo: Don't redirect the repo to external units
When displaying the repo home view, do not redirect to unit types that
can't be defaults (which, at the moment, are the external wiki and issue
tracker unit types).

If we'd redirect to those, that would mean that a repository with the
Code unit disabled, and an external issue tracker would immediately
redirect to the external issue tracker, making it harder to reach other,
non-external units of the repo.

Fixes #1965.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 44078e5460)
(cherry picked from commit 1868dec2e4)
2024-01-15 16:51:45 +00:00
Earl Warren 63d086f666
[GITEA] notifies admins on new user registration (squash) DeleteByID
trivial conflict because of
   778ad795fd Refactor deletion (#28610)

(cherry picked from commit 05682614e5)
(cherry picked from commit 64bd374803)
2024-01-15 16:48:45 +00:00
Earl Warren 63b9b624bd
[GITEA] Fix session generation for database (squash) timeutil.Mock
because of e743570f65 * Refactor timeutil package (#28623)

(cherry picked from commit acc6b51be2)
(cherry picked from commit 02b74317f2)
2024-01-15 16:48:44 +00:00
Gusted 986be6171a
[GITEA] Remove redundant syncBranchToDB
- The transaction in combination with Git push was causing deadlocks if
you had the `push_update` queue set to `immediate`. This was the root
cause of slow integration tests in CI.
- Remove the sync branch code as this is already being done in the Git
post-receive hook.
- Add tests to proof the branch models are in sync even with this code
removed.

(cherry picked from commit 90110e1f44)
(cherry picked from commit a064065cb9)
(cherry picked from commit 7713e558eb)

Conflicts:
	services/repository/branch.go
	https://codeberg.org/forgejo/forgejo/pulls/2068
(cherry picked from commit 3bb73e0813)
(cherry picked from commit c557540926)
2024-01-15 16:48:44 +00:00
Gergely Nagy 3d3366dbbe
[GITEA] Configurable clone methods
Adds `[repository].DOWNLOAD_OR_CLONE_METHODS` (defaulting to
"download-zip,download-targz,download-bundle,vscode-clone"), which lets
an instance administrator override the additional clone methods
displayed on the repository home view.

This is purely display-only, the clone methods not listed here are still
available, unless disabled elsewhere. They're just not displayed.

Fixes #710.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 2aadcf4946)
(cherry picked from commit 42ac34fbf9)
(cherry picked from commit bd231b0245)
2024-01-15 16:48:44 +00:00
Gusted 70623e8da1
[GITEA] Fix NPE in ToPullReviewList
- Add condition to ensure doer isn't nil when using it.
- Added unit test.
- Resolves #2055

(cherry picked from commit 8f1a74fb29)
(cherry picked from commit 60ac881776)
(cherry picked from commit 5fdc461ac5)
2024-01-15 16:48:44 +00:00
Antonin Delpeuch 94e954ce22
[GITEA] pulls: "Edit File" button in "Files Changed" tab
Closes #1894.
Gitea issue: https://github.com/go-gitea/gitea/issues/23848

(cherry picked from commit 79c75164ca)
(cherry picked from commit 58c76aad8f)
(cherry picked from commit 5bdb3c6c53)
2024-01-15 16:48:44 +00:00
Gusted 19013ba5ea
[GITEA] Avoid WHERE IN for comment migration query
- Rewrite `UpdateCommentsMigrationsByType` to not use `WHERE IN` as
that's a performance diaster for MariaDB, it now use batching to query
the the relevant comment IDs via JOINs (which is not possible in a
UPDATE query for SQLite) and then update them in a seperate query.
- Add unit test.
- Resolves https://codeberg.org/forgejo/forgejo/issues/1856

(cherry picked from commit 8098ca9d2e)

Conflicts:
	models/issues/comment.go
	https://codeberg.org/forgejo/forgejo/pulls/2075
(cherry picked from commit ca65deba1c)
(cherry picked from commit 0e1e09e77d)
2024-01-15 16:48:44 +00:00
Gusted 66eae1041c
[GITEA] Fix /issues/search endpoint
- The endpoint was moved from being an API endpoint to an web endpoint
with JSON result. However the API context isn't the same as the web
context, for example the `ctx.Error` only takes in the first two
arguments into consideration and doesn't do logging, which is not the
same behavior as the API context where there's three arguments and does
do logging and only reveal the function + error if the user is admin.
- Remove any details in the error message and do the logging seperatly,
this is somewhat consistent with how other API endpoints behave.
- Ref: https://codeberg.org/forgejo/forgejo/issues/1998

(cherry picked from commit fe71e32ace)
(cherry picked from commit c89e0735fa)
(cherry picked from commit 4c04dcfc59)
2024-01-15 16:48:44 +00:00
Gergely Nagy a5d2829a10
[GITEA] Optionally allow anyone to edit Wikis
This is largely based on gitea#6312 by @ashimokawa, with updates and
fixes by myself, and incorporates the review feedback given in that pull
request, and more.

What this patch does is add a new "default_permissions" column to the
`repo_units` table (defaulting to read permission), adjusts the
permission checking code to take this into consideration, and then
exposes a setting that lets a repo administrator enable any user on a
Forgejo instance to edit the repo's wiki (effectively giving the wiki
unit of the repo "write" permissions by default).

By default, wikis will remain restricted to collaborators, but with the
new setting exposed, they can be turned into globally editable wikis.

Fixes Codeberg/Community#28.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 4b74439922)
(cherry picked from commit 337cf62c10)
(cherry picked from commit b6786fdb32)
2024-01-15 16:48:44 +00:00
Gusted 65dbc4303b
[GITEA] Fix session generation for database
- If the session doesn't exist, it shouldn't be expected that the
variable is non-nil. Define the session variable instead and insert that.
- Add unit tests to test the behavior of the database sessions code .
- Regression caused by dd30d9d5c0.
- Resolves https://codeberg.org/forgejo/forgejo/issues/2042

(cherry picked from commit 90307ad200)
(cherry picked from commit 874ef1978d)
(cherry picked from commit 27d5f035fc)
2024-01-15 16:47:17 +00:00