Commit Graph

1808 Commits

Author SHA1 Message Date
ChristopherHX
08b9776970 Refactor Actions Token Access (#35688)
* use a single function to do Action Tokens Permission checks
* allows easier customization
* add basic tests
* lfs file locks should work now

---------

Signed-off-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-22 11:12:31 +00:00
Kemal Zebari
a9f2ea720b Honor delete branch on merge repo setting when using merge API (#35488)
Fix #35463.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-22 05:06:56 +00:00
wxiaoguang
5f0697243c Don't block site admin's operation if SECRET_KEY is lost (#35721)
Related: #24573
2025-10-22 12:35:56 +08:00
a1012112796
a4e23b81d3 fix attachment file size limit in server backend (#35519)
fix #35512

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-21 15:07:11 +00:00
wxiaoguang
a2eea2fb2e Fix various trivial problems (#35714) 2025-10-21 13:19:29 +08:00
wxiaoguang
b2ee5be52e Refactor legacy code (#35708)
And by the way, remove the legacy TODO, split large functions into small
ones, and add more tests
2025-10-20 11:43:08 -07:00
Zettat123
897e48dde3 Add quick approve button on PR page (#35678)
This PR adds a quick approve button on PR page to allow reviewers to
approve all pending checks. Only users with write permission to the 
Actions unit can approve.

---------

Signed-off-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-20 18:46:37 +08:00
Bryan Mutai
c30d74d0f9 feat(diff): Enable commenting on expanded lines in PR diffs (#35662)
Fixes #32257 
/claim #32257

Implemented commenting on unchanged lines in Pull Request diffs, lines
are accessed by expanding the diff preview. Comments also appear in the
"Files Changed" tab on the unchanged lines where they were placed.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-19 18:19:12 +08:00
wxiaoguang
2d36a0c9ff Fix various bugs (#35684)
1. Fix incorrect column in `applySubscribedCondition`, add a test
2. Fix debian version parsing, add more tests fix #35695
3. Fix log level for HTTP errors, fix #35651
4. Fix abused "panic" handler in API `Migrate`
5. Fix the redirection from PR to issue, add a test
6. Fix Actions variable & secret name validation, add more tests
    * envNameCIRegexMatch is unnecessary, removed
    * validating in "delete" function doesn't make sense, removed
7. Fix incorrect link in release email

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2025-10-19 00:37:50 +08:00
Lunny Xiao
a7eceb57a9 Use gitrepo.Repository instead of wikipath (#35398)
Now the wikipath will not be referenced directly.
2025-10-17 20:00:44 -07:00
Lunny Xiao
731d803d19 Creating push comments before invoke pull request checking (#35647)
This PR moved the creation of pushing comments before pull request
mergeable checking. So that when the pull request status changed, the
comments should have been created.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-14 19:19:27 +00:00
ChristopherHX
2401812b76 Cleanup ActionRun creation (#35624)
Closes #35622

---------

Signed-off-by: ChristopherHX <christopher.homberger@web.de>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-12 12:23:37 +00:00
Lunny Xiao
662a44d924 Fix merge panic (#35606)
To prevent potential bugs, the logic in #35543 makes `gitcmd.Command`
panic when attempting to override stdout or stderr. Instead of using
`PrepareCmd`, this PR now uses the WithXXX methods directly to avoid the
panic.

Fix #35603
2025-10-12 04:24:00 +02:00
ChristopherHX
25c4eb1659 Refactor ActionRunJob parsing into a reusable function (#35623)
Use a helper method around the jobparser for parsing a single job
structure from an ActionRunJob

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-11 12:58:36 -07:00
Zettat123
40f71bcd4c Support Actions concurrency syntax (#32751)
Fix #24769
Fix #32662
Fix #33260

Depends on https://gitea.com/gitea/act/pulls/124

-
https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency

## ⚠️ BREAKING ⚠️

This PR removes the auto-cancellation feature added by #25716. Users
need to manually add `concurrency` to workflows to control concurrent
workflows or jobs.

---------

Signed-off-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-10 18:58:55 +00:00
Lunny Xiao
69f5ee970c Move some functions to gitrepo package (#35543)
Refactor Git command functions to use WithXXX methods instead of
exposing RunOpts.
This change simplifies reuse across gitrepo and improves consistency,
encapsulation, and maintainability of command options.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-07 17:06:51 +08:00
Rob Gonnella
c9e7fde8b3 feat: adds option to force update new branch in contents routes (#35592)
Allows users to specify a "force" option in API /contents routes when
modifying files in a new branch. When "force" is true, and the branch
already exists, a force push will occur provided the branch does not
have a branch protection rule that disables force pushing.

This is useful as a way to manage a branch remotely through only the
API. For example in an automated release tool you can pull commits,
analyze, and update a release PR branch all remotely without needing to
clone or perform any local git operations.

Resolve #35538

---------

Co-authored-by: Rob Gonnella <rob.gonnella@papayapay.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-06 21:23:14 -07:00
Lunny Xiao
ad2ff67343 Move archive function to repo_model and gitrepo (#35514) 2025-10-06 15:01:26 -07:00
Zettat123
cdc0733047 Use inputs context when parsing workflows (#35590)
Depends on [gitea/act#143](https://gitea.com/gitea/act/pulls/143)

The [`inputs`
context](https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#inputs-context)
is used when parsing workflows so that `run-name` like `run-name: Deploy
to ${{ inputs.deploy_target }}` can be parsed correctly.
2025-10-06 06:09:27 +02:00
Lunny Xiao
e1c2fef593 Fix creating pull request failure when the target branch name is the same as some tag (#35552)
Use full reference name in the git command to avoid ambiguity.

Fix #35470
2025-10-03 22:54:37 +00:00
Lunny Xiao
17c8aa6587 Add rebase push display wrong comments bug (#35560)
Fix #35518

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-03 15:16:17 -07:00
wxiaoguang
71360a94cb Address some CodeQL security concerns (#35572)
Although there is no real security problem
2025-10-04 01:21:26 +08:00
Kausthubh J Rao
c4532101a4 fix(webhook): prevent tag events from bypassing branch filters targets #35449 (#35567)
Tag creation/deletion was triggering push webhooks even when branch
filters were configured, causing unintended pipeline executions.

This change modifies the branch filter logic to check the full ref
name directly instead of first determining if it's a "branch" event.

Fixes: Tag events now properly respect branch filters
- Add getPayloadRef() function to extract full ref names
- Update PrepareWebhook() to use direct ref matching
- Prevents refs/tags/* from matching refs/heads/* filters

Closes #35449

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2025-10-03 08:51:57 +02:00
Aleksandr Denisovich
efc48c36ff Added button to copy file name in PR files (#35509)
The merge request file viewer has a button for copying the file path,
but it is not always convenient. Often, you only want to copy the file
name, which is currently not possible. This change request adds this
capability.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: a.kiselev <a.kiselev@reglab.ru>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-02 18:08:11 +00:00
junoberryferry
151ef80e28 use experimental go json v2 library (#35392)
details: https://pkg.go.dev/encoding/json/v2

---------

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-09-28 08:03:36 +00:00
Lunny Xiao
8106d95577 Use global lock instead of status pool for cron lock (#35507) 2025-09-27 10:11:52 -07:00
Lunny Xiao
1f32170060 Move some functions to gitrepo package (#35503) 2025-09-26 10:14:20 -07:00
Lunny Xiao
7bf2972379 Move GetDiverging functions to gitrepo (#35524)
Extracted from #35469

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-09-26 15:15:42 +00:00
Sumit
f09bea7af1 [Fix] Trigger 'unlabeled' event when label is Deleted from PR (#34316)
This pull request updates the handling of issue label events in
workflows to distinguish between label additions and deletions,
introduces corresponding test cases, and extends the `IssuePayload`
structure to support this functionality.

### Enhancements to issue label event handling:
* Updated `matchIssuesEvent` in `modules/actions/workflows.go` to
differentiate between "labeled" and "unlabeled" events based on whether
labels were added or removed.
* Added a new field, `RemovedLabels`, to the `IssuePayload` struct in
`modules/structs/hook.go` to track labels that were removed during an
issue event.

### Testing improvements:
* Added `TestMatchIssuesEvent` in `modules/actions/workflows_test.go` to
cover scenarios such as label addition, label deletion, and label
clearing, ensuring the correct event type is triggered.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2025-09-24 09:45:38 -07:00
Lunny Xiao
198f37e33c Move updateref and removeref to gitrepo and remove unnecessary open repository (#35511)
Extracted from #35077
`UpdateRef` and `RemoveRef` will call git commands even for gogit
version.
2025-09-19 08:04:18 -07:00
ChristopherHX
9a0ec53ee3 Stream repo zip/tar.gz/bundle achives by default (#35487)
Initial implementation of linked proposal.

* Closes #29942
* Fix #34003
* Fix #30443

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-09-19 11:51:21 +08:00
Lunny Xiao
9332ff291b Move git command to git/gitcmd (#35483)
The name cmd is already used in many places and may cause conflicts, so
I chose `gitcmd` instead to minimize potential naming conflicts.
2025-09-15 23:33:12 -07:00
Gnanakeethan Balasubramaniam
fe5afcb022 Exposing TimeEstimate field in the API (#35475)
Time Estimate field is not included in the issue modification webhooks
or issue API endpoints.

This PR fixes the field for the API.

---------

Signed-off-by: Gnanakeethan Balasubramaniam <gnanakeethan@users.noreply.github.com>
Signed-off-by: Gnanakeethan Balasubramaniam <gnanakeethan@cloudparallax.com>
2025-09-16 04:32:03 +00:00
wxiaoguang
4fe1066a17 Replace gobwas/glob package (#35478)
https://github.com/gobwas/glob is unmaintained and has bugs.
2025-09-13 18:01:00 +00:00
luzpaz
688abac5ca Fix various typos in codebase (#35480) 2025-09-13 10:34:43 -04:00
ChristopherHX
84812e42df Fix SSH signing key path will be displayed in the pull request UI (#35381)
Closes #35361

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-09-12 03:00:18 +00:00
Lunny Xiao
89d7929711 Fix package link setting can only list limited repositories (#35394)
Fix #24801

<img width="1123" height="503" alt="image"
src="https://github.com/user-attachments/assets/823f4214-e08a-4506-9018-057c50e7fc52"
/>

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
2025-09-11 01:50:17 +02:00
Lunny Xiao
e35e724e42 Use db.WithTx/WithTx2 instead of TxContext when possible (#35428) 2025-09-10 03:15:01 +00:00
Lunny Xiao
b9efbe9fe6 Fix push commits comments when changing the pull request target branch (#35386)
When changing the pull request target branch, the pushed commits
comments will not be changed resulted the number are inconsistent
between commits tab number and the pushed commits comments number.

This PR will remove all the previous pushed commits comments and
calculate new comments when changing the target branch.

Before:

<img width="928" height="585" alt="image"
src="https://github.com/user-attachments/assets/35e4d31f-31a1-4d14-83b0-1786721ab0d9"
/>

After:
<img width="816" height="623" alt="image"
src="https://github.com/user-attachments/assets/24b6dafe-9238-4e7e-833d-68472457afab"
/>
2025-09-09 19:40:54 +00:00
ulnanlu
09d1f359d5 fix(webhook/discord): fixed username cannot be empty error (#35412)
username field is not required by discord and used to override the
default username. sending it as blank causes a 400 error. it should be
omitted instead when it's not set.

Ref:
https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params

Closes #35411
2025-09-05 11:19:31 -07:00
NorthRealm
07347634aa Refactor and update mail templates (#35150)
- Moved mail templates to new directories.
- Added new devtest ymls.
- Embedded styles as much as possible.
- Added new translation keys for actions email.

---------

Signed-off-by: NorthRealm <155140859+NorthRealm@users.noreply.github.com>
Co-authored-by: delvh <dev.lh@web.de>
2025-09-04 20:20:42 -07:00
Lunny Xiao
e96ef97989 Upgrade dependencies (#35384)
- ~Upgrade golang to 1.25~ blocked by the issue
https://github.com/go-swagger/go-swagger/issues/3220
- Upgrade minor versions of most dependencies
- Upgrade github.com/google/go-github version to v74
- Fix meilisearch because of sdk interface change
- Use github.com/Necoro/html2text which is a fork instead of html2text
because of https://github.com/jaytaylor/html2text/issues/67 which
resulted in complie failure.
- Fix some deprecated methods of gitlab go client.
2025-09-02 23:13:38 -04:00
Lunny Xiao
1717af72c4 Move some functions from package git to gitrepo (#33910)
Follow #33874
2025-09-01 19:13:18 +00:00
Lunny Xiao
d2e994db2c Move git config/remote to gitrepo package and add global lock to resolve possible conflict when updating repository git config file (#35151)
Partially fix #32018 

`git config` and `git remote` write operations create a temporary file
named `config.lock`. Since these operations are not atomic, they must
not be run in parallel. If two requests attempt to modify the same
repository concurrently—such as during a compare operation—one may fail
due to the presence of an existing `config.lock` file.

In cases where `config.lock` is left behind due to an unexpected program
exit, a global lock mechanism could allow us to safely remove the stale
lock file when a related error is detected. While this behavior is not
yet implemented in this PR, it is planned for a future enhancement.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-09-01 18:47:04 +00:00
Lunny Xiao
4e1b8db1fc Move HasWiki to repository service package (#33912)
Move HasWiki out of the models package to avoid referencing the absolute
wiki path directly.
2025-09-01 11:12:58 -07:00
Lunny Xiao
fb056bf4ed Use gitrepo.SetDefaultBranch when set default branch of wiki repository (#33911) 2025-08-28 06:06:39 +00:00
Lunny Xiao
7636d581d9 Deleting branch could delete broken branch which has database record but git branch is missing (#35360)
For some reasons, branches between database and git are not synced. If a
branch exists in database but not in the git, it should be able to be
deleted.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-08-27 22:32:22 -07:00
wxiaoguang
0cbaa0b662 Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
wxiaoguang
60246730b5 Remove wrong "git.DefaultContext" (#35364) 2025-08-27 16:31:21 +00:00
wxiaoguang
e837c998b7 Fix context usages (#35348) 2025-08-27 11:00:01 +00:00