aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
Commit message (Collapse)AuthorAgeFilesLines
* Add cli flags LDAP group configuration (#33933)TheFox0x77 days2-0/+77
| | | | | Add 7 new flags to ldap subcommands corresponding to UI options Closes CLI part of https://github.com/go-gitea/gitea/issues/20716
* Add global lock for migrations to make upgrade more safe with multiple ↵Lunny Xiao2025-03-073-6/+7
| | | | replications (#33706)
* Try to fix ACME (3rd) (#33807)wxiaoguang2025-03-071-1/+8
| | | Fix #33802, fix #32191
* Remove context from git struct (#33793)TheFox0x72025-03-041-1/+1
| | | | Argument is moved from struct init in command run, which lets us remove context from struct.
* Try to fix ACME path when renew (#33668)wxiaoguang2025-02-231-6/+10
| | | Try to fix #32191
* Use test context in tests and new loop system in benchmarks (#33648)TheFox0x72025-02-202-4/+2
| | | | | | | | Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Artifacts download api for artifact actions v4 (#33510)ChristopherHX2025-02-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * download endpoint has to use 302 redirect * fake blob download used if direct download not possible * downloading v3 artifacts not possible New repo apis based on GitHub Rest V3 - GET /runs/{run}/artifacts (Cannot use run index of url due to not being unique) - GET /artifacts - GET + DELETE /artifacts/{artifact_id} - GET /artifacts/{artifact_id}/zip - (GET /artifacts/{artifact_id}/zip/raw this is a workaround for a http 302 assertion in actions/toolkit) - api docs removed this is protected by a signed url like the internal artifacts api and no longer usable with any token or swagger - returns http 401 if the signature is invalid - or change the artifact id - or expired after 1 hour Closes #33353 Closes #32124 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add a option "--user-type bot" to admin user create, improve role display ↵mscherer2025-02-072-23/+70
| | | | | | | | | | | (#27885) Partially solve #13044 Fix #33295 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* User facing messages for AGit errors (#33012)TheFox0x72025-01-271-1/+4
| | | | | | | | | | | Adds user facing messages to errors when submitting agit pull request Tries to highlight the returned error more and fixes agit suggestion to create PR on first submission. Closes: https://github.com/go-gitea/gitea/issues/32965 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Support performance trace (#32973)wxiaoguang2025-01-211-0/+4
| | | | | | | | | | | | | 1. Add a OpenTelemetry-like shim-layer to collect traces 2. Add a simple builtin trace collector and exporter, end users could download the diagnosis report to get the traces. This PR's design is quite lightweight, no hard-dependency, and it is easy to improve or remove. We can try it on gitea.com first to see whether it works well, and fine tune the details. --------- Co-authored-by: silverwind <me@silverwind.io>
* Fix ACME panic (#33178)wxiaoguang2025-01-091-2/+4
| | | | | | | | | | Fix #33177, Manually tested: ```` 1.7364311850484018e+09 info maintenance started background certificate maintenance {"cache": "0x1400ca64180"} 1.736431185054049e+09 info obtain acquiring lock {"identifier": "example.com"} 1.736431185058073e+09 info obtain lock acquired {"identifier": "example.com"} 1.736431185058133e+09 info obtain obtaining certificate {"identifier": "example.com"} ````
* Fix "stop time tracking button" on navbar (#33084)wxiaoguang2025-01-031-1/+1
| | | | | | | | Fix #33083 By the way (something I was working on): 1. relax color/background-color for more markup elements 2. fix a command line sentence error
* Try to fix ACME directory problem (#33072)wxiaoguang2025-01-021-1/+1
|
* Refactor env var related code (#33075)wxiaoguang2025-01-021-31/+10
| | | And add more comments
* unset XDG_HOME_CONFIG as gitea manages configuration locations (#33067)JonRB2025-01-021-0/+1
| | | | | | | | unset XDG_CONFIG_HOME early to enable gitea to manage git configuration. simple error checking to satisfy the linting. Closes #33039 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix settings not being loaded at CLI (#26402)cassio zareck2024-12-302-0/+15
| | | | | | | | | | Closes #25898 The problem was that the default settings weren't being loaded --------- Signed-off-by: cassiozareck <cassiomilczareck@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor LFS SSH and internal routers (#32473)wxiaoguang2024-11-121-8/+6
| | | | | | | | | | | | | | | | | | Gitea instance keeps reporting a lot of errors like "LFS SSH transfer connection denied, pure SSH protocol is disabled". When starting debugging the problem, there are more problems found. Try to address most of them: * avoid unnecessary server side error logs (change `fail()` to not log them) * figure out the broken tests/user2/lfs.git (added comments) * avoid `migratePushMirrors` failure when a repository doesn't exist (ignore them) * avoid "Authorization" (internal&lfs) header conflicts, remove the tricky "swapAuth" and use "X-Gitea-Internal-Auth" * make internal token comparing constant time (it wasn't a serous problem because in a real world it's nearly impossible to timing-attack the token, but good to fix and backport) * avoid duplicate routers (introduce AddOwnerRepoGitLFSRoutes) * avoid "internal (private)" routes using session/web context (they should use private context) * fix incorrect "path" usages (use "filepath") * fix incorrect mocked route point handling (need to check func nil correctly) * split some tests from "git general tests" to "git misc tests" (to keep "git_general_test.go" simple) Still no correct result for Git LFS SSH tests. So the code is kept there (`tests/integration/git_lfs_ssh_test.go`) and a FIXME explains the details.
* chore: fix some function names in comment (#32300)wangjingcun2024-10-221-1/+1
| | | fix some function names in comment
* Make git push options accept short name (#32245)wxiaoguang2024-10-121-9/+4
| | | | | Just like what most CLI parsers do: `--opt` means `opt=true` Then users could use `-o force-push` as `-o force-push=true`
* Add pure SSH LFS support (#31516)ConcurrentCrab2024-09-271-44/+85
| | | | | | | | | Fixes #17554 /claim #17554 Docs PR https://gitea.com/gitea/docs/pulls/49 To test, run pushes like: `GIT_TRACE=1` git push. The trace output should mention "pure SSH connection".
* Fix panic when cloning with wrong ssh format. (#32076)Lunny Xiao2024-09-241-4/+7
|
* bump to go 1.23 (#31855)techknowlogick2024-09-101-2/+2
|
* Save initial signup information for users to aid in spam prevention (#31852)techknowlogick2024-09-091-1/+1
| | | | | | | | | | | | | | This will allow instance admins to view signup pattern patterns for public instances. It is modelled after discourse, mastodon, and MediaWiki's approaches. Note: This has privacy implications, but as the above-stated open-source projects take this approach, especially MediaWiki, which I have no doubt looked into this thoroughly, it is likely okay for us, too. However, I would be appreciative of any feedback on how this could be improved. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Prevent update pull refs manually and will not affect other refs update (#31931)Lunny Xiao2024-09-021-0/+14
| | | | | | | | | | All refs under `refs/pull` should only be changed from Gitea inside but not by pushing from outside of Gitea. This PR will prevent the pull refs update but allow other refs to be updated on the same pushing with `--mirror` operations. The main changes are to add checks on `update` hook but not `pre-receive` because `update` will be invoked by every ref but `pre-receive` will revert all changes once one ref update fails.
* fix: allow actions artifacts storage migration to complete succesfully (#31251)Rowan Bohde2024-06-051-2/+16
| | | | | | | | | | | | | | | | | | | | | Change the copy to use `ActionsArtifact.StoragePath` instead of the `ArtifactPath`. Skip artifacts that are expired, and don't error if the file to copy does not exist. --- When trying to migrate actions artifact storage from local to MinIO, we encountered errors that prevented the process from completing successfully: * The migration tries to copy the files using the per-run `ArtifactPath`, instead of the unique `StoragePath`. * Artifacts that have been marked expired and had their files deleted would throw an error * Artifacts that are pending, but don't have a file uploaded yet will throw an error. This PR addresses these cases, and allow the process to complete successfully.
* Azure blob storage support (#30995)Lunny Xiao2024-05-301-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | This PR implemented object storages(LFS/Packages/Attachments and etc.) for Azure Blob Storage. It depends on azure official golang SDK and can support both the azure blob storage cloud service and azurite mock server. Replace #25458 Fix #22527 - [x] CI Tests - [x] integration test, MSSQL integration tests will now based on azureblob - [x] unit test - [x] CLI Migrate Storage - [x] Documentation for configuration added ------ TODO (other PRs): - [ ] Improve performance of `blob download`. --------- Co-authored-by: yp05327 <576951401@qq.com>
* Supports forced use of S3 virtual-hosted style (#30969)dicarne2024-05-151-0/+6
| | | | | Add a configuration item to enable S3 virtual-hosted style (V2) to solve the problem caused by some S3 service providers not supporting path style (V1).
* Move database operations of merging a pull request to post receive hook and ↵Lunny Xiao2024-05-071-0/+3
| | | | | | | | | | | | | | | | | | | | add a transaction (#30805) Merging PR may fail because of various problems. The pull request may have a dirty state because there is no transaction when merging a pull request. ref https://github.com/go-gitea/gitea/pull/25741#issuecomment-2074126393 This PR moves all database update operations to post-receive handler for merging a pull request and having a database transaction. That means if database operations fail, then the git merging will fail, the git client will get a fail result. There are already many tests for pull request merging, so we don't need to add a new one. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix missing migrate actions artifacts (#30874)Lunny Xiao2024-05-071-8/+16
| | | | The actions artifacts should be able to be migrate to the new storage place.
* Make sure git version&feature are always prepared (#30877)wxiaoguang2024-05-062-6/+3
| | | Otherwise there would be more similar issues like #29287
* Add some tests to clarify the "must-change-password" behavior (#30693)wxiaoguang2024-04-275-12/+67
| | | | | | | | | | Follow #30472: When a user is created by command line `./gitea admin user create`: Old behavior before #30472: the first user (admin or non-admin) doesn't need to change password. Revert to the old behavior before #30472
* Enable more `revive` linter rules (#30608)silverwind2024-04-221-1/+1
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Add --skip-db option to dump command (#30613)Kemal Zebari2024-04-211-24/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attempts to resolve #28720. --- Note that I am not a Gitea administrator so I don't normally use the gitea CLI. Just saw this issue and wanted an opportunity to understand how this subcommand works and see if I can add this feature :^) I tested both with `--skip-db` and without and it appears to not add any database-specific files to the generated archive i.e. I don't see a `gitea-db.sql` or `gitea.db` file: ```console $ TAGS="bindata sqlite sqlite_unlock_notify" make backend Running go generate... bindata for migration already up-to-date bindata for options already up-to-date bindata for public already up-to-date bindata for templates already up-to-date $ ./gitea dump --skip-db 2024/04/20 01:16:11 ...s/setting/session.go:77:loadSessionFrom() [I] Session Service Enabled 2024/04/20 01:16:11 ...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/attachments 2024/04/20 01:16:11 ...s/storage/storage.go:166:initAvatars() [I] Initialising Avatar storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/avatars 2024/04/20 01:16:11 ...s/storage/storage.go:192:initRepoAvatars() [I] Initialising Repository Avatar storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/repo-avatars 2024/04/20 01:16:11 ...s/storage/storage.go:186:initLFS() [I] Initialising LFS storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/lfs 2024/04/20 01:16:11 ...s/storage/storage.go:198:initRepoArchives() [I] Initialising Repository Archive storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/repo-archive 2024/04/20 01:16:11 ...s/storage/storage.go:208:initPackages() [I] Initialising Packages storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/packages 2024/04/20 01:16:11 ...s/storage/storage.go:219:initActions() [I] Initialising Actions storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/actions_log 2024/04/20 01:16:11 ...s/storage/storage.go:223:initActions() [I] Initialising ActionsArtifacts storage with type: local 2024/04/20 01:16:11 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /workspaces/gitea/data/actions_artifacts 2024/04/20 01:16:11 cmd/dump.go:172:runDump() [I] Dumping local repositories... /workspaces/gitea/data/gitea-repositories 2024/04/20 01:16:11 cmd/dump.go:195:runDump() [I] Skipping database 2024/04/20 01:16:11 cmd/dump.go:229:runDump() [I] Adding custom configuration file from /workspaces/gitea/custom/conf/app.ini 2024/04/20 01:16:11 cmd/dump.go:256:runDump() [I] Packing data directory.../workspaces/gitea/data 2024/04/20 01:16:11 cmd/dump.go:335:runDump() [I] Finish dumping in file /workspaces/gitea/gitea-dump-1713575771.zip $ unzip /workspaces/gitea/gitea-dump-1713575771.zip -d example Archive: /workspaces/gitea/gitea-dump-1713575771.zip . . . $ ls example/ app.ini custom data repos $ ls example/data/ actions_artifacts actions_log avatars home indexers jwt queues repo-archive repo-avatars tmp ``` Co-authored-by: Giteabot <teabot@gitea.io>
* chore: use errors.New to replace fmt.Errorf with no parameters will much ↵Cheng2024-04-217-11/+15
| | | | | better (#30621) use errors.New to replace fmt.Errorf with no parameters will much better
* Improve "must-change-password" logic and document (#30472)wxiaoguang2024-04-142-25/+27
| | | | | Unify the behaviors of "user create" and "user change-password". Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Performance optimization for git push (#30104)Lunny Xiao2024-04-091-13/+22
| | | | | Agit returned result should be from `ProcReceive` hook but not `PostReceive` hook. Then for all non-agit pull requests, it will not check the pull requests for every pushing `refs/pull/%d/head`.
* Clean up log messages (#30313)wxiaoguang2024-04-071-1/+1
| | | | | | `log.Xxx("%v")` is not ideal, this PR adds necessary context messages. Remove some unnecessary logs. Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor "dump" sub-command (#30240)wxiaoguang2024-04-031-223/+63
| | | | | | | | | | Major changes: * Move some functions like "addReader" / "isSubDir" / "addRecursiveExclude" to a separate package, and add tests * Clarify the filename&dump type logic and add tests * Clarify the logger behavior and remove FIXME comments Co-authored-by: Giteabot <teabot@gitea.io>
* Move some asymkey functions to service layer (#28894)Lunny Xiao2024-03-041-2/+2
| | | | After the moving, all models will not depend on `util.Rename` so that I can do next step refactoring.
* Start to migrate from `util.OptionalBool` to `optional.Option[bool]` (#29329)65432024-02-231-4/+4
| | | just create transition helper and migrate two structs
* Refactor cmd setup and remove deadcode (#29313)wxiaoguang2024-02-222-13/+2
| | | | | | * use `setup(ctx, c.Bool("debug"))` like all other callers * `setting.RunMode = "dev"` is a no-op. * `if _, err := os.Stat(setting.RepoRootPath); err != nil` could be simplified
* Refactor JWT secret generating & decoding code (#29172)wxiaoguang2024-02-161-1/+1
| | | | | | | | Old code is not consistent for generating & decoding the JWT secrets. Now, the callers only need to use 2 consistent functions: NewJwtSecretWithBase64 and DecodeJwtSecretBase64 And remove a non-common function Base64FixedDecode from util.go
* Fix push to create with capitalize repo name (#29090)Lunny Xiao2024-02-081-5/+7
| | | Fix #29073
* Unify user update methods (#28733)KN4CK3R2024-02-041-23/+21
| | | | | | | | | | | Fixes #28660 Fixes an admin api bug related to `user.LoginSource` Fixed `/user/emails` response not identical to GitHub api This PR unifies the user update methods. The goal is to keep the logic only at one place (having audit logs in mind). For example, do the password checks only in one method not everywhere a password is updated. After that PR is merged, the user creation should be next.
* Add `must-change-password` cli parameter (#27626)KN4CK3R2024-02-031-1/+9
| | | | | | | | | | This PR adds a new `must-change-password` parameter to the `change-password` cli command. We already have the `must-change-password` command but it feels natural to have this integrated into the `change-password` cli command. --------- Co-authored-by: 6543 <6543@obermui.de>
* Simplify how git repositories are opened (#28937)Lunny Xiao2024-01-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Purpose This is a refactor toward building an abstraction over managing git repositories. Afterwards, it does not matter anymore if they are stored on the local disk or somewhere remote. ## What this PR changes We used `git.OpenRepository` everywhere previously. Now, we should split them into two distinct functions: Firstly, there are temporary repositories which do not change: ```go git.OpenRepository(ctx, diskPath) ``` Gitea managed repositories having a record in the database in the `repository` table are moved into the new package `gitrepo`: ```go gitrepo.OpenRepository(ctx, repo_model.Repo) ``` Why is `repo_model.Repository` the second parameter instead of file path? Because then we can easily adapt our repository storage strategy. The repositories can be stored locally, however, they could just as well be stored on a remote server. ## Further changes in other PRs - A Git Command wrapper on package `gitrepo` could be created. i.e. `NewCommand(ctx, repo_model.Repository, commands...)`. `git.RunOpts{Dir: repo.RepoPath()}`, the directory should be empty before invoking this method and it can be filled in the function only. #28940 - Remove the `RepoPath()`/`WikiPath()` functions to reduce the possibility of mistakes. --------- Co-authored-by: delvh <dev.lh@web.de>
* Fix migrate storage bug (#28830)Lunny Xiao2024-01-201-0/+6
|
* Move doctor package from modules to services (#28856)Lunny Xiao2024-01-202-2/+2
|
* Return `responseText` instead of string in some functions (#28836)yp053272024-01-193-3/+3
| | | | Follow https://github.com/go-gitea/gitea/pull/28796#issuecomment-1891727591
* Move more functions to db.Find (#28419)Lunny Xiao2024-01-151-2/+2
| | | | | | | | | Following #28220 This PR move more functions to use `db.Find`. --------- Co-authored-by: delvh <dev.lh@web.de>