delvh
778ad795fd
Refactor deletion ( #28610 )
...
Introduce the new generic deletion methods
- `func DeleteByID[T any](ctx context.Context, id int64) (int64, error)`
- `func DeleteByIDs[T any](ctx context.Context, ids ...int64) error`
- `func Delete[T any](ctx context.Context, opts FindOptions) (int64,
error)`
So, we no longer need any specific deletion method and can just use
the generic ones instead.
Replacement of #28450
Closes #28450
---------
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
11 months ago
Jean-Baptiste Gomond
d0f24ff4ca
Added instance-level variables ( #28115 )
...
This PR adds instance-level variables, and so closes #27726
![gitea_instance_variables_1](https://github.com/go-gitea/gitea/assets/8344487/ad409cd4-ce36-4c84-a764-34451b0fb63a )
![gitea_instance_variables_2](https://github.com/go-gitea/gitea/assets/8344487/426f0965-dec6-4560-948c-067cdeddd720 )
![gitea_instance_variables_3](https://github.com/go-gitea/gitea/assets/8344487/cf1d7776-4938-4825-922e-cbbbf28a5f33 )
11 months ago
Lunny Xiao
4eb2a29910
Improve ObjectFormat interface ( #28496 )
...
The 4 functions are duplicated, especially as interface methods. I think
we just need to keep `MustID` the only one and remove other 3.
```
MustID(b []byte) ObjectID
MustIDFromString(s string) ObjectID
NewID(b []byte) (ObjectID, error)
NewIDFromString(s string) (ObjectID, error)
```
Introduced the new interfrace method `ComputeHash` which will replace
the interface `HasherInterface`. Now we don't need to keep two
interfaces.
Reintroduced `git.NewIDFromString` and `git.MustIDFromString`. The new
function will detect the hash length to decide which objectformat of it.
If it's 40, then it's SHA1. If it's 64, then it's SHA256. This will be
right if the commitID is a full one. So the parameter should be always a
full commit id.
@AdamMajer Please review.
11 months ago
Lunny Xiao
408a484224
Adjust object format interface ( #28469 )
...
- Remove `ObjectFormatID`
- Remove function `ObjectFormatFromID`.
- Use `Sha1ObjectFormat` directly but not a pointer because it's an
empty struct.
- Store `ObjectFormatName` in `repository` struct
11 months ago
Adam Majer
cbf923e87b
Abstract hash function usage ( #28138 )
...
Refactor Hash interfaces and centralize hash function. This will allow
easier introduction of different hash function later on.
This forms the "no-op" part of the SHA256 enablement patch.
11 months ago
Lunny Xiao
df1e7d0067
Use db.Find instead of writing methods for every object ( #28084 )
...
For those simple objects, it's unnecessary to write the find and count
methods again and again.
12 months ago
JakobDev
76a85a4ce9
Final round of `db.DefaultContext` refactor ( #27587 )
...
Last part of #27065
1 year ago
JakobDev
cc5df26680
Even more `db.DefaultContext` refactor ( #27352 )
...
Part of #27065
---------
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
1 year ago
delvh
e709bc199f
Differentiate between `push` and `pull` `mirror sync in progress` ( #27390 )
...
Previously, if you had both a push and a pull mirror, the message did
not clarify if you've accidentally synchronized the wrong one.
Additionally fixed two typos that were encountered while debugging.
## Screenshots
![grafik](https://github.com/go-gitea/gitea/assets/51889757/164d5d20-728d-4365-9cb5-c37e95857cdf )
![grafik](https://github.com/go-gitea/gitea/assets/51889757/90bfffd2-abd4-4847-b8e2-db4231700a6d )
1 year ago
yp05327
393193a3e0
Fix repo count in org action settings ( #27245 )
...
Only in org action settings, repo count is missing
Before:
![image](https://github.com/go-gitea/gitea/assets/18380374/4a74c090-c55f-4f06-810a-c390337efa9d )
![image](https://github.com/go-gitea/gitea/assets/18380374/e234f7e7-178c-4186-bbc0-0f291192b011 )
![image](https://github.com/go-gitea/gitea/assets/18380374/c1db70cd-973b-40d5-ba17-1f354aed9149 )
In other setting page:
![image](https://github.com/go-gitea/gitea/assets/18380374/43bfec6b-a1a4-48a9-8280-ab6f967b7ec4 )
After:
![image](https://github.com/go-gitea/gitea/assets/18380374/9a697bd8-ce9f-40e2-8749-b46726d68d84 )
![image](https://github.com/go-gitea/gitea/assets/18380374/3b6d1e59-64dd-4655-953b-064718e6aa7a )
![image](https://github.com/go-gitea/gitea/assets/18380374/5604c063-556c-4252-8778-4e5a5e23b7e1 )
1 year ago
JakobDev
cf0df023be
More `db.DefaultContext` refactor ( #27265 )
...
Part of #27065
This PR touches functions used in templates. As templates are not static
typed, errors are harder to find, but I hope I catch it all. I think
some tests from other persons do not hurt.
1 year ago
Lunny Xiao
673cf6af76
make writing main test easier ( #27270 )
...
This PR removed `unittest.MainTest` the second parameter
`TestOptions.GiteaRoot`. Now it detects the root directory by current
working directory.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 year ago
JakobDev
7047df36d4
Another round of `db.DefaultContext` refactor ( #27103 )
...
Part of #27065
---------
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
1 year ago
JakobDev
28f9b313ba
Updates to the API for archived repos ( #27149 )
1 year ago
KN4CK3R
c766140dad
Add `RemoteAddress` to mirrors ( #26952 )
...
This PR adds a new field `RemoteAddress` to both mirror types which
contains the sanitized remote address for easier (database) access to
that information. Will be used in the audit PR if merged.
1 year ago
JakobDev
f91dbbba98
Next round of `db.DefaultContext` refactor ( #27089 )
...
Part of #27065
1 year ago
JakobDev
c548dde205
More refactoring of `db.DefaultContext` ( #27083 )
...
Next step of #27065
1 year ago
JakobDev
76659b1114
Reduce usage of `db.DefaultContext` ( #27073 )
...
Part of #27065
This reduces the usage of `db.DefaultContext`. I think I've got enough
files for the first PR. When this is merged, I will continue working on
this.
Considering how many files this PR affect, I hope it won't take to long
to merge, so I don't end up in the merge conflict hell.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 year ago
Nanguan Lin
cda97a7253
Update status and code index after changing the default branch ( #27018 )
...
Fix #26723
Add `ChangeDefaultBranch` to the `notifier` interface and implement it
in `indexerNotifier`. So when changing the default branch,
`indexerNotifier` sends a message to the `indexer queue` to update the
index.
---------
Co-authored-by: techknowlogick <matti@mdranta.net>
1 year ago
Lunny Xiao
e3ed67859a
Move some functions to service layer ( #26969 )
1 year ago
Lunny Xiao
4f32abaf94
move repository deletion to service layer ( #26948 )
...
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 year ago
Lunny Xiao
f20e317d6d
Improve hint when uploading a too large avatar ( #26935 )
...
Fix #26390
---------
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: silverwind <me@silverwind.io>
1 year ago
wxiaoguang
e8aae43f56
Move web/api context related testing function into a separate package ( #26859 )
...
Just like `models/unittest`, the testing helper functions should be in a
separate package: `contexttest`
And complete the TODO:
> // TODO: move this function to other packages, because it depends on
"models" package
1 year ago
Lunny Xiao
476b9d1589
Use docs.gitea.com instead of docs.gitea.io ( #26739 )
1 year ago
Chongyi Zheng
43652746f2
Move `modules/mirror` to `services` ( #26737 )
...
To solve the cyclic imports in a better way
Closes #20261
1 year ago
wxiaoguang
e8b990999f
Make "link-action" backend code respond correct JSON content ( #26680 )
...
Otherwise the `link-action` JS code couldn't parse the response.
Co-authored-by: Giteabot <teabot@gitea.io>
1 year ago
Earl Warren
50fc22eecf
Add ThreadID parameter for Telegram webhooks ( #25996 )
...
Telegram has recently implemented threads (channels) for group chats.
Co-authored-by: neveraskedtoexist <matikot415@gmail.com>
1 year ago
puni9869
ab388deb0e
Allow editing push mirrors after creation ( #26151 )
...
Allow users to edit the sync interval for existing push mirrors.
Currently, there is no way to modify the interval once the mirror is
created.
<details>
<summary>Screenshots</summary>
## Before
<img width="936" alt="Screenshot 2023-07-26 at 9 31 21 AM"
src="https://github.com/go-gitea/gitea/assets/80308335/35b8a40c-4320-474c-a866-1dea0f1fa0de ">
## After
<img width="945" alt="Screenshot 2023-07-26 at 9 44 40 AM"
src="https://github.com/go-gitea/gitea/assets/80308335/ee12e12f-0f68-4feb-90eb-33366f5997d3 ">
### On hover
<img width="247" alt="image"
src="https://github.com/go-gitea/gitea/assets/80308335/2f32de45-bd50-4150-9623-3be2ef3ea7f8 ">
<img width="237" alt="image"
src="https://github.com/go-gitea/gitea/assets/80308335/49f4ab4d-ccff-4489-80ce-a9788a73c3bb ">
<img width="245" alt="image"
src="https://github.com/go-gitea/gitea/assets/80308335/165fc888-9d48-438a-b730-d4beb12122af ">
### Edit modal
<img width="905" alt="image"
src="https://github.com/go-gitea/gitea/assets/80308335/2a7ca24b-4f36-4e0e-9799-39f2ecc46413 ">
### Only valid times are allowed
<img width="728" alt="Screenshot 2023-07-26 at 9 50 01 AM"
src="https://github.com/go-gitea/gitea/assets/80308335/ced6d330-c235-4e29-8f17-28daddcf1444 ">
<img width="853" alt="image"
src="https://github.com/go-gitea/gitea/assets/80308335/8636f62a-70d1-4684-a3e8-b205adc03580 ">
</details>
Fixes #21295
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 year ago
wxiaoguang
dcd3a63128
Move web JSON functions to web context and simplify code ( #26132 )
...
The JSONRedirect/JSONOK/JSONError functions were put into "Base" context
incorrectly, it would cause abuse.
Actually, they are for "web context" only, so, move them to the correct
place.
And by the way, use them to simplify old code: +75 -196
1 year ago
Lunny Xiao
b167f35113
Add context parameter to some database functions ( #26055 )
...
To avoid deadlock problem, almost database related functions should be
have ctx as the first parameter.
This PR do a refactor for some of these functions.
1 year ago
HesterG
2f0e79e639
Use frontend fetch for branch dropdown component ( #25719 )
...
- Send request to get branch/tag list, use loading icon when waiting for
response.
- Only fetch when the first time branch/tag list shows.
- For backend, removed assignment to `ctx.Data["Branches"]` and
`ctx.Data["Tags"]` from `context/repo.go` and passed these data wherever
needed.
- Changed some `v-if` to `v-show` and used native `svg` as mentioned in
https://github.com/go-gitea/gitea/pull/25719#issuecomment-1631712757 to
improve perfomance when there are a lot of branches.
- Places Used the dropdown component:
Repo Home Page
<img width="1429" alt="Screen Shot 2023-07-06 at 12 17 51"
src="https://github.com/go-gitea/gitea/assets/17645053/6accc7b6-8d37-4e88-ae1a-bd2b3b927ea0 ">
Commits Page
<img width="1431" alt="Screen Shot 2023-07-06 at 12 18 34"
src="https://github.com/go-gitea/gitea/assets/17645053/2d0bf306-d1e2-45a8-a784-bc424879f537 ">
Specific commit -> operations -> cherry-pick
<img width="758" alt="Screen Shot 2023-07-06 at 12 23 28"
src="https://github.com/go-gitea/gitea/assets/17645053/1e557948-3881-4e45-a625-8ef36d45ae2d ">
Release Page
<img width="1433" alt="Screen Shot 2023-07-06 at 12 25 05"
src="https://github.com/go-gitea/gitea/assets/17645053/3ec82af1-15a4-4162-a50b-04a9502161bb ">
- Demo
https://github.com/go-gitea/gitea/assets/17645053/d45d266b-3eb0-465a-82f9-57f78dc5f9f3
- Note:
UI of dropdown menu could be improved in another PR as it should apply
to more dropdown menus.
Fix #14180
---------
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 year ago
silverwind
88f835192d
Replace `interface{}` with `any` ( #25686 )
...
Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.
Basically the same [as golang did](2580d0e08d
).
1 year ago
Lunny Xiao
aab7cb6750
Move some files under repo/setting ( #25585 )
...
There are too many files under `routers/web/repo` and the file
`routers/web/repo/setting.go` is too big.
This PR move all setting related routers' body functions under
`routers/web/repo/setting` and also split `routers/web/repo/setting.go`
1 year ago
sillyguodong
35a653d7ed
Support configuration variables on Gitea Actions ( #24724 )
...
Co-Author: @silverwind @wxiaoguang
Replace: #24404
See:
- [defining configuration variables for multiple
workflows](https://docs.github.com/en/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows )
- [vars
context](https://docs.github.com/en/actions/learn-github-actions/contexts#vars-context )
Related to:
- [x] protocol: https://gitea.com/gitea/actions-proto-def/pulls/7
- [x] act_runner: https://gitea.com/gitea/act_runner/pulls/157
- [x] act: https://gitea.com/gitea/act/pulls/43
#### Screenshoot
Create Variable:
![image](https://user-images.githubusercontent.com/33891828/236758288-032b7f64-44e7-48ea-b07d-de8b8b0e3729.png )
![image](https://user-images.githubusercontent.com/33891828/236758174-5203f64c-1d0e-4737-a5b0-62061dee86f8.png )
Workflow:
```yaml
test_vars:
runs-on: ubuntu-latest
steps:
- name: Print Custom Variables
run: echo "${{ vars.test_key }}"
- name: Try to print a non-exist var
run: echo "${{ vars.NON_EXIST_VAR }}"
```
Actions Log:
![image](https://user-images.githubusercontent.com/33891828/236759075-af0c5950-368d-4758-a8ac-47a96e43b6e2.png )
---
This PR just implement the org / user (depends on the owner of the
current repository) and repo level variables, The Environment level
variables have not been implemented.
Because
[Environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#about-environments )
is a module separate from `Actions`. Maybe it would be better to create
a new PR to do it.
---------
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
1 year ago
HesterG
28a89e360f
Add user level action runners ( #24995 )
...
Used similar logic to organization.
<img width="1437" alt="Screen Shot 2023-05-30 at 10 18 06"
src="https://github.com/go-gitea/gitea/assets/17645053/49f3800a-44ae-4188-b1e6-91d49e3d7868 ">
<img width="1331" alt="Screen Shot 2023-05-30 at 10 31 18"
src="https://github.com/go-gitea/gitea/assets/17645053/221b2068-e9b9-4e34-bb4a-d390594b2f35 ">
1 year ago
Hester Gong
63a401ac40
Move secrets and runners settings to actions settings ( #24200 )
...
This PR moves the secrets and runners settings to actions settings on
all settings(repo,org,user,admin) levels.
After this PR, if
[ENABLED](5e7543fcf4/custom/conf/app.example.ini (L2604)
)
inside `app.ini` under `[actions]` is set to `false`, the "Actions" tab
(including runners management and secrets management) will not be shown.
After, the settings under actions settings for each level:
1. Admin Level
"Runners Management"
<img width="1437" alt="Screen Shot 2023-04-26 at 14 34 20"
src="https://user-images.githubusercontent.com/17645053/234489731-15822d21-38e1-4560-8bbe-69f122376abc.png ">
2. User Level
"Secrets Management"
<img width="1427" alt="Screen Shot 2023-04-26 at 14 34 30"
src="https://user-images.githubusercontent.com/17645053/234489795-68c9c0cb-24f8-4f09-95c6-458ab914c313.png ">
3. Repo and Organization Levels
"Runners Management" and "Secrets Management"
Org:
<img width="1437" alt="Screen Shot 2023-04-26 at 14 35 07"
src="https://user-images.githubusercontent.com/17645053/234489996-f3af5ebb-d354-46ca-9087-a0b586845281.png ">
<img width="1433" alt="Screen Shot 2023-04-26 at 14 35 14"
src="https://user-images.githubusercontent.com/17645053/234490004-3abf8fed-81fd-4ce2-837a-935dade1793d.png ">
Repo:
<img width="1419" alt="Screen Shot 2023-04-26 at 14 34 50"
src="https://user-images.githubusercontent.com/17645053/234489904-80c11038-4b58-462c-9d0b-8b7cf70bc2b3.png ">
<img width="1430" alt="Screen Shot 2023-04-26 at 14 34 57"
src="https://user-images.githubusercontent.com/17645053/234489918-4e8d1fe2-9bcd-4d8a-96c1-238a8088d92e.png ">
It also finished these tasks :
- [x] rename routers function "runners" to "actions", and refactor
related file names
- [x] check and modify part of the runners related functions to match
their name
- [x] Fix backend check caused by fmt check
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years ago