Commit Graph

488 Commits

Author SHA1 Message Date
86d6598a54 fix: use LONGBLOB 2022-12-12 13:08:49 +08:00
d378a78c79 Merge branch 'main' into feature/bots 2022-12-09 16:20:28 +08:00
3c59d31bc6 Add API management for issue/pull and comment attachments (#21783)
Close #14601
Fix #3690

Revive of #14601.
Updated to current code, cleanup and added more read/write checks.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andre Bruch <ab@andrebruch.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-09 14:35:56 +08:00
266a122ba2 Merge branch 'main' into feature/bots 2022-12-08 18:11:18 +08:00
0585ac3ac6 Update go dev dependencies (#22064)
`golangci-lint`
[deprecated](https://github.com/golangci/golangci-lint/issues/1841) a
bunch of linters, removed them.
2022-12-08 16:21:37 +08:00
223782ca4c refactor: rename to actions 2022-12-06 15:16:25 +08:00
b0d6c7b86e chore: use SPDX-License-Identifier 2022-12-02 22:25:31 +08:00
76869e4b76 Merge branch 'main' into feature/bots 2022-12-02 22:17:49 +08:00
f59a74852b Update gitea-vet to check FSFE REUSE (#22004)
Related to:
- #21840
- https://gitea.com/gitea/gitea-vet/pulls/21

What it looks like when it's working:
https://drone.gitea.io/go-gitea/gitea/64040/1/5

All available SPDX license identifiers: [SPDX License
List](https://spdx.org/licenses/).

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-02 22:14:57 +08:00
8f2efdaf60 chore: add dbfs to migration 2022-11-29 17:19:26 +08:00
c1fce2cf7d feat: remove bots resources after deleting repo 2022-11-29 16:25:58 +08:00
04d72d3500 refactor: rename tables to bot_* 2022-11-29 12:34:23 +08:00
797c21de1f Merge branch 'main' into feature/bots 2022-11-29 11:09:20 +08:00
9607750b5e Replace fmt.Sprintf with hex.EncodeToString (#21960)
`hex.EncodeToString` has better performance than `fmt.Sprintf("%x",
[]byte)`, we should use it as much as possible.

I'm not an extreme fan of performance, so I think there are some
exceptions:

- `fmt.Sprintf("%x", func(...)[N]byte())`
- We can't slice the function return value directly, and it's not worth
adding lines.
    ```diff
    func A()[20]byte { ... }
    - a := fmt.Sprintf("%x", A())
    - a := hex.EncodeToString(A()[:]) // invalid
    + tmp := A()
    + a := hex.EncodeToString(tmp[:])
    ```
- `fmt.Sprintf("%X", []byte)`
- `strings.ToUpper(hex.EncodeToString(bytes))` has even worse
performance.
2022-11-28 11:19:18 +00:00
66b558017f Merge branch 'main' into feature/bots 2022-11-28 17:23:53 +08:00
e81ccc406b Implement FSFE REUSE for golang files (#21840)
Change all license headers to comply with REUSE specification.

Fix #16132

Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-11-27 18:20:29 +00:00
ef4b3673dd chore: golang lint 2022-11-26 22:12:52 +08:00
378e1f8d01 chore: fix problems caused by rebase 2022-11-25 17:58:34 +08:00
fdd3c0434e feat: add IsForkPullRequest 2022-11-25 17:48:48 +08:00
6ad8bddabf feat: GetRunningTaskByToken 2022-11-25 17:48:48 +08:00
0f5aab0c1a chore: remove Result from task and step 2022-11-25 17:48:47 +08:00
7059cd7265 feat: update runner status 2022-11-25 17:48:47 +08:00
7b2f1f5a91 chore: fix token format 2022-11-25 17:48:47 +08:00
e19f2c8c44 chore: add ids to task 2022-11-25 17:48:47 +08:00
5e7adf2004 chore: add extra fields to Run and RunJob 2022-11-25 17:48:47 +08:00
cab3fc072a fix: use updated to check abandoned jobs 2022-11-25 17:48:47 +08:00
cf40dca0c4 feat: record job needs 2022-11-25 17:48:46 +08:00
964f67e189 chore: remove unique index of runner name 2022-11-25 17:48:46 +08:00
b5520f098f Some improvements 2022-11-25 17:48:46 +08:00
e7d5c99b42 Fix lint 2022-11-25 17:48:46 +08:00
e43e3f9518 improve UI 2022-11-25 17:48:46 +08:00
feab4b1601 feat: update task status 2022-11-25 17:48:45 +08:00
a8f74d4ec8 fix: make run index group by repo id only 2022-11-25 17:48:45 +08:00
8dbe30dff9 feat: tranfer log to storage 2022-11-25 17:48:45 +08:00
dd5b2c5dfd feat: optimize log indexes 2022-11-25 17:48:45 +08:00
f75a4abc5d build UI 2022-11-25 17:48:45 +08:00
482832da76 delete unused structs 2022-11-25 17:48:45 +08:00
5f0cb6b9e5 fix merge 2022-11-25 17:48:44 +08:00
a1bd3a8932 Fix build 2022-11-25 17:48:43 +08:00
2c4f6fd42f add most tables 2022-11-25 17:48:43 +08:00
5a479bb034 Add builds UI 2022-11-25 17:48:43 +08:00
7732392a96 Add bots 2022-11-25 17:48:33 +08:00
702f4b521e Add index for access_token (#21908)
The `token_last_eight` field has been used in `GetAccessTokenBySHA `:
2022-11-23 20:49:41 -06:00
4c00d8f916 Move migration test fixtures to the correct directories (#21901)
Unfortunately #21549 changed the name of Testcases without changing
their associated fixture directories.

Fix #21854

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-23 18:24:55 +08:00
32db62515f Add package registry cleanup rules (#21658)
Fixes #20514
Fixes #20766
Fixes #20631

This PR adds Cleanup Rules for the package registry. This allows to
delete unneeded packages automatically. Cleanup rules can be set up from
the user or org settings.
Please have a look at the documentation because I'm not a native english
speaker.

Rule Form

![grafik](https://user-images.githubusercontent.com/1666336/199330792-c13918a6-e196-4e71-9f53-18554515edca.png)

Rule List

![grafik](https://user-images.githubusercontent.com/1666336/199331261-5f6878e8-a80c-4985-800d-ebb3524b1a8d.png)

Rule Preview

![grafik](https://user-images.githubusercontent.com/1666336/199330917-c95e4017-cf64-4142-a3e4-af18c4f127c3.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-20 16:08:38 +02:00
92525ddffd Init git module before database migration (#21764)
Close #21761

Some database migrations depend on the git module.
2022-11-10 14:22:39 +00:00
91c7a3e66f Fix tests on migrations (#21705) 2022-11-08 12:07:46 +08:00
b6e81357bd Add Webhook authorization header (#20926)
_This is a different approach to #20267, I took the liberty of adapting
some parts, see below_

## Context

In some cases, a weebhook endpoint requires some kind of authentication.
The usual way is by sending a static `Authorization` header, with a
given token. For instance:

- Matrix expects a `Bearer <token>` (already implemented, by storing the
header cleartext in the metadata - which is buggy on retry #19872)
- TeamCity #18667
- Gitea instances #20267
- SourceHut https://man.sr.ht/graphql.md#authentication-strategies (this
is my actual personal need :)

## Proposed solution

Add a dedicated encrypt column to the webhook table (instead of storing
it as meta as proposed in #20267), so that it gets available for all
present and future hook types (especially the custom ones #19307).

This would also solve the buggy matrix retry #19872.

As a first step, I would recommend focusing on the backend logic and
improve the frontend at a later stage. For now the UI is a simple
`Authorization` field (which could be later customized with `Bearer` and
`Basic` switches):


![2022-08-23-142911](https://user-images.githubusercontent.com/3864879/186162483-5b721504-eef5-4932-812e-eb96a68494cc.png)

The header name is hard-coded, since I couldn't fine any usecase
justifying otherwise.

## Questions

- What do you think of this approach? @justusbunsi @Gusted @silverwind 
- ~~How are the migrations generated? Do I have to manually create a new
file, or is there a command for that?~~
- ~~I started adding it to the API: should I complete it or should I
drop it? (I don't know how much the API is actually used)~~

## Done as well:

- add a migration for the existing matrix webhooks and remove the
`Authorization` logic there


_Closes #19872_

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2022-11-03 20:23:20 +02:00
f8f859b8fa Alter package_version.metadata_json to LONGTEXT (#21667) 2022-11-03 15:28:46 +08:00
e72acd5e5b Split migrations folder (#21549)
There are too many files in `models/migrations` folder so that I split
them into sub folders.
2022-11-02 16:54:36 +08:00