Commit Graph

18978 Commits (main)

Author SHA1 Message Date
wxiaoguang 6cc1067884
Fix incorrect ref commit ID usage (#33331)
After the RefName refactoring, the `ctx.Repo.CommitID` is only set when
there is a `RepoRefByType` middleware.

Many handlers do not use that middleware and they only use "default
branch"
2025-01-20 07:43:49 +00:00
wxiaoguang 39de2955fd
Improve sync fork behavior (#33319)
Fix #33271

Suppose there is a `branch-a` in fork repo:

1. if `branch-a` exists in base repo: try to sync `base:branch-a` to `fork:branch-a`
2. if `branch-a` doesn't exist in base repo: try to sync `base:main` to `fork:branch-a`
2025-01-20 15:17:47 +08:00
wxiaoguang 6073e2f1bb
Refactor response writer & access logger (#33323)
And add comments & tests
2025-01-20 06:25:17 +00:00
GiteaBot 13dbd260b7 [skip ci] Updated licenses and gitignores 2025-01-20 00:31:52 +00:00
Michael Vetter 076d122f34
Fix typo in documentation of GetBranchNames() (#33330) 2025-01-19 18:41:15 -05:00
CrimsonEdgeHope 1928918c35
Fix Account linking page (#33325)
Fix password form missing whilst linking account even with
`ENABLE_PASSWORD_SIGNIN_FORM = true`.

Remove redundant empty box in account linking sign up page when
`LinkAccountMode` is true.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-19 20:37:22 +08:00
hiifong b7614e2d2f
Fix parentCommit invalid memory address or nil pointer dereference. (#33204)
When the parent Commit does not exist on gitea, an error will be
reported when opening the Commit details page: invalid memory address or
nil pointer dereference.

![image](https://github.com/user-attachments/assets/4c2a9802-935f-41e9-b5b9-a4f0d745f709)

![image](https://github.com/user-attachments/assets/7b0bc15e-7f5f-4d58-8d24-fee667a799fa)
2025-01-19 02:51:43 +00:00
Vladimir Sysoev dc2308a959
Make tracked time representation display as hours (#33315)
Estimated time represented in hours it might be convenient to
have tracked time represented in the same way to be compared and
managed.

---------

Co-authored-by: Sysoev, Vladimir <i@vsysoev.ru>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-19 09:30:44 +08:00
GiteaBot f250ee6360 [skip ci] Updated translations via Crowdin 2025-01-19 00:33:43 +00:00
GiteaBot fffc8550ab [skip ci] Updated translations via Crowdin 2025-01-18 00:30:24 +00:00
Chai-Shi 55e0756c68
Fix push message behavior (#33215)
Fixes #32769 by the logic from pr #33192

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-17 19:37:17 +00:00
6543 1342d48433
Add golang back to nix dev environment and pin v1.23 (#33275) 2025-01-17 12:25:33 -05:00
wxiaoguang 3b839f8dc0
Trivial fixes (#33304)
1. the error check was added for go-git, it was caused by the empty `.keep` file in the test fixtures.
2. use `PostFormValue` instead of `PostForm.Get` (`Get` needs to parse the form ahead)
3. fix incorrect container text (it should show "Images" in the header but not "OS/Arch")
4. align maven xml
5. fix closed PR color&icon
2025-01-17 08:55:02 +00:00
GiteaBot 7582eb0419 [skip ci] Updated translations via Crowdin 2025-01-17 00:31:11 +00:00
wxiaoguang cfc6e21f06
Fix incorrect ref usages (#33301)
Fix #33297

By the way, improve some locales
2025-01-16 13:52:21 +00:00
silverwind ab347fd0f7
Update JS and PY dependencies (#33249)
- Update all JS and PY dependencies
- Tested affected dependencies
- Disabled `async-preventdefault` lint rule because it brought up new
false-positives.
2025-01-16 09:56:41 +00:00
Kemal Zebari 2483a93fbc
Only allow admins to rename default/protected branches (#33276)
Currently, anyone with write permissions to a repo are able to rename
default or protected branches.

This change follows
[GitHub's](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch)
design by only allowing repo/site admins to change these branches.
However, it also follows are current design for protected branches and
only allows admins to modify branch names == branch protection rule
names. Glob-based rules cannot be renamed by anyone (as was already the
case, but we now catch `ErrBranchIsProtected` which we previously did
not catch, throwing a 500).
2025-01-15 20:51:49 +00:00
silverwind 4b21a6c792
Enable Typescript `noImplicitThis` (#33250)
- Enable https://www.typescriptlang.org/tsconfig/#noImplicitThis
- Wrap Vue Template-Syntax SFCs in
[`defineComponent`](https://vuejs.org/api/general#definecomponent) which
makes type inference and linter work better
- Move `createApp` calls outside the SFCs into separate files
- Use [`PropType`](https://vuejs.org/api/utility-types#proptype-t) where
appropriate
- Some top-level component properties changed order as dictated by the
linter
- Fix all tsc and lint issues that popped up during these refactors
2025-01-16 04:26:17 +08:00
wxiaoguang b15d01b0ce
Prepare for support performance trace (#33286)
For #32973
2025-01-15 20:05:18 +00:00
wxiaoguang 6659a381ea
Fix closed dependency title (#33285)
Fix #33283
2025-01-15 23:38:03 +08:00
Zettat123 d0962ce3da
Move some Actions related functions from `routers` to `services` (#33280)
Move the main logic of `generateTaskContext` and `findTaskNeeds` to the
`services` layer.

This is a part of #32751, since we need the git context and `needs` to
parse the concurrency expressions.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-15 21:34:30 +08:00
wxiaoguang f6dbf0e7b3
Fix incorrect TagName/BranchName usages (#33279)
Add add a new test
2025-01-15 17:34:55 +08:00
wxiaoguang fcd096231a
Simplify context ref name (#33267) 2025-01-15 11:15:47 +08:00
GiteaBot cbf933eb4e [skip ci] Updated translations via Crowdin 2025-01-15 00:31:44 +00:00
wxiaoguang 4d399e717d
Fix some broken route handlers (#33268)
Some mistakes introduced by recent refactoring PRs (some sidebar
dropdowns doesn't work)
2025-01-14 19:03:02 +00:00
wxiaoguang 1299fdb084
Add a confirm dialog for "sync fork" (#33270)
Try to quickly fix #33264
2025-01-14 18:30:43 +00:00
wxiaoguang 5eff19a77a
Fix sidebar milestone link (#33269)
Fix  #33266
2025-01-14 13:01:53 -05:00
Lunny Xiao 6410c34b7f
Refactor ref type (#33242)
Major changes:

1. do not sync ".keep" file during tests
2. fix incorrect route handler and empty repo handling (backported as #33253 with tests)
3. do not use `RepoRef`: most of the calls are abuses.
4. Use `git.RefType` instead of a new type definition `RepoRefType` on `context`.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-14 15:35:34 +08:00
yp05327 3a749fc816
Fix 500 error when error occurred in migration page (#33256)
The template should be `repo/migrate/{service type}`
But input element `service` is not in the form.

Related: #33081

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-14 06:29:44 +00:00
yp05327 4672ddcdd7
Fix missing license when sync mirror (#33255)
Fix #33222
2025-01-14 05:44:12 +00:00
wxiaoguang a98a836e76
Support public code/issue access for private repositories (#33127)
Close #8649, close #639 (will add "anonymous access" in following PRs)
2025-01-14 01:53:34 +00:00
Kemal Zebari ecd463c2f1
Validate that the tag doesn't exist when creating a tag via the web (#33241)
Found while investigating #33210.

This line no longer makes sense because the form field "TagName" is
required, so this would mean that this code path would never be covered.
Because it isn't covered, we end up going down the "update release"
logic where we eventually set `Release.IsTag` to false (meaning it will
now be treated as a release instead of a tag).

This snapshot rewrites the condition to ensure that we aren't trying to
create a tag that already exists.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-14 09:27:35 +08:00
GiteaBot 58ac17c005 [skip ci] Updated translations via Crowdin 2025-01-14 00:31:05 +00:00
silverwind 98d7e04767
Switch back to `vue-tsc` (#33248)
It supports Typescript 5.7 now, so we can switch back to the official
version.
2025-01-13 21:57:52 +01:00
Michael B. a90af22003
Let API create and edit system webhooks, attempt 2 (#33180)
This PR fixes inconsistencies between system and default webhooks in the
Gitea API. (See also #26418)
- A system webhook is a webhook that captures events for all
repositories.
- A default webhook is copied to a new repository when it is created. 

Before this PR `POST /api/v1/admin/hooks/` creates default webhooks (if
not configured otherwise) and `GET /api/v1/admin/hooks/` returns system
webhooks.

The PR introduces an optional query parameter to `GET
/api/v1/admin/hooks/` to enable selecting if either default, system or
both kind of webhooks should be retrieved. By default the flag is set to
return system webhooks keep current behaviour.

## Examples

### System Webhooks

#### Create

```
POST /api/v1/admin/hooks/

{
  "type": "gitea",
  "active": false,
  "branch_filter": "*",
  "events": [ "create", "..." ],
  "config": {
    "url": "http://...",
    "content_type": "json",
    "secret": "secret",
    "is_system_webhook": true // <-- controls hook type
  }
}
```

#### List
```
GET/api/v1/admin/hooks?type=system //type argument is optional here since it's the default
```

#### Others
The other relevant endpoints work as expected by referencing the hook by
id
```
GET /api/v1/admin/hooks/:id
PATCH /api/v1/admin/hooks/:id
DELETE /api/v1/admin/hooks/:id
```


### Default Webhooks

#### Create
```
POST /api/v1/admin/hooks/

{
  "type": "gitea",
  "active": false,
  "branch_filter": "*",
  "events": [ "create", "..." ],
  "config": {
    "url": "http://...",
    "content_type": "json",
    "secret": "secret",
    "is_system_webhook": false // optional, as false is the default value
  }
}
```

#### List
```
GET/api/v1/admin/hooks?type=default
```

#### Others
The other relevant endpoints work as expected by referencing the hook by
id
```
GET /api/v1/admin/hooks/:id
PATCH /api/v1/admin/hooks/:id
DELETE /api/v1/admin/hooks/:id
```
2025-01-13 17:17:39 +00:00
wxiaoguang 348b7074c8
Fix incorrect ref "blob" (#33240)
1. "blob" is not a "ref", it shouldn't (and not unable to) be handled by
`RepoRefByType`
2. the `/blob/{sha}` handle should use the path param "sha" directly
2025-01-13 16:27:11 +08:00
wxiaoguang 2ea929a952
Refactor RefName (#33234)
And fix some FIXMEs
2025-01-13 14:01:53 +08:00
wxiaoguang 81352542fd
Refactor context RefName and RepoAssignment (#33226)
The `ctx.Repo.RefName` was used to be a "short name", it causes a lot of
ambiguity.

This PR does some refactoring and use `RefFullName` to replace the
legacy `RefName`, and simplify RepoAssignment
2025-01-13 01:07:05 +00:00
GiteaBot 604365efd7 [skip ci] Updated translations via Crowdin 2025-01-13 00:34:26 +00:00
wxiaoguang c0751ef116
Fix upload file form (#33230)
Fix #33228
2025-01-13 03:39:15 +08:00
Lunny Xiao be4e961240
Fix mirror bug (#33224)
Fix #33200

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-12 18:46:37 +08:00
wxiaoguang 9024b79933
Remove unused CSS styles and move some styles to proper files (#33217) 2025-01-12 05:16:22 +00:00
wxiaoguang a068462ac0
Refactor context repository (#33202) 2025-01-12 03:39:46 +00:00
GiteaBot a7e750414c [skip ci] Updated translations via Crowdin 2025-01-12 00:35:53 +00:00
Lunny Xiao fd7d393c67
Fix unpin hint on the pinned pull requests (#33207) 2025-01-12 00:05:33 +00:00
TheFox0x7 8c6d7076b7
fix(cache): cache test triggered by non memory cache (#33220)
Change SlowCacheThreshold to 30 milliseconds so it doesn't trigger on
non memory cache

Closes: https://github.com/go-gitea/gitea/issues/33190
Closes: https://github.com/go-gitea/gitea/issues/32657
2025-01-12 04:33:43 +08:00
yp05327 5c150ce9b0
Update README.md (#33149)
~~Waiting for the upload of screenshots~~
I have a good idea about the screenshots. I will do it later.

---------

Co-authored-by: Gary Wang <git@blumia.net>
2025-01-10 16:03:07 +08:00
Harry Vince d7ec23febf
Fix editor markdown not incrementing in a numbered list (#33187)
Amended the logic for newPrefix in the MarkdownEditor to resolve
incorrect number ordering.

Fixes #33184

Attached screenshot of fixed input similar to issue 
<img width="175" alt="Screenshot 2025-01-09 at 23 59 24"
src="https://github.com/user-attachments/assets/dfa23cf1-f3db-4b5e-99d2-a71bbcb289a8"
/>

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-10 07:28:38 +00:00
Lunny Xiao d3083d2198
Some small refactors (#33144) 2025-01-10 06:00:06 +00:00
Chai-Shi e5f3c16587
Fix sync fork for consistency (#33147)
Fixes #33145

An integration test could be added.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-10 05:29:55 +00:00