aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
Commit message (Collapse)AuthorAgeFilesLines
* Support Proxy protocol (#12527)zeripath2022-08-214-25/+23
| | | | | | | | | This PR adds functionality to allow Gitea to sit behind an HAProxy and HAProxy protocolled connections directly. Fix #7508 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Disable doctor logging on panic (#20847)zeripath2022-08-181-11/+42
| | | | | | | | | | | | | | | | | | | | * Disable doctor logging on panic If permissions are incorrect for writing to the doctor log simply disable the log file instead of panicing. Related #20570 Signed-off-by: Andrew Thornton <art27@cantab.net> * Update cmd/doctor.go * Update cmd/doctor.go Co-authored-by: delvh <dev.lh@web.de> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add migrate repo archiver and packages storage support on command line (#20757)Lunny Xiao2022-08-163-35/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add migrate repo archiver and packages storage support on command line * Fix typo * Use stdCtx * Use packageblob and fix command description * Add migrate packages unit tests * Fix comment year * Fix the migrate storage command line description * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Fix test Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
* Fix git.Init for doctor sub-command (#20782)wxiaoguang2022-08-141-6/+0
|
* Refactor legacy git init (#20376)wxiaoguang2022-08-091-3/+9
| | | | | | | | * merge `CheckLFSVersion` into `InitFull` (renamed from `InitWithSyncOnce`) * remove the `Once` during git init, no data-race now * for doctor sub-commands, `InitFull` should only be called in initialization stage Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Rework mailer settings (#18982)Clar Fon2022-08-021-4/+4
| | | | | | | | | | | * `PROTOCOL`: can be smtp, smtps, smtp+startls, smtp+unix, sendmail, dummy * `SMTP_ADDR`: domain for SMTP, or path to unix socket * `SMTP_PORT`: port for SMTP; defaults to 25 for `smtp`, 465 for `smtps`, and 587 for `smtp+startls` * `ENABLE_HELO`, `HELO_HOSTNAME`: reverse `DISABLE_HELO` to `ENABLE_HELO`; default to false + system hostname * `FORCE_TRUST_SERVER_CERT`: replace the unclear `SKIP_VERIFY` * `CLIENT_CERT_FILE`, `CLIENT_KEY_FILE`, `USE_CLIENT_CERT`: clarify client certificates here Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add Tar ZSTD support (#20493)Gusted2022-07-271-1/+1
| | | | | - Add `.tar.zst` as supported output type. - Resolves #14290
* Improve pprof doc (#20463)wxiaoguang2022-07-241-1/+2
|
* Add two factor status to admin cmd display (#20401)Tyrone Yeh2022-07-191-2/+3
|
* Make sure `repo_dir` is an empty directory or doesn't exist before ↵a10121127962022-07-141-1/+18
| | | | 'dump-repo' (#20205)
* Add option to purge users (#18064)zeripath2022-07-141-1/+5
| | | | | | | Add the ability to purge users when deleting them. Close #15588 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix various typos (#20338)luzpaz2022-07-121-1/+1
| | | | | | | * Fix various typos Found via `codespell -q 3 -S ./options/locale,./options/license,./public/vendor -L actived,allways,attachements,ba,befores,commiter,pullrequest,pullrequests,readby,splitted,te,unknwon` Co-authored-by: zeripath <art27@cantab.net>
* Allow enable LDAP source and disable user sync via CLI (#20206)Steven Kriegler2022-07-042-0/+71
| | | | | | | | | | | | | | | The current `admin auth` CLI for managing authentication source of type LDAP via BindDN and Simple LDAP does not allow enabling the respective source, once disabled via `--not-active`. The same applies to `--synchronize-users` specifially for LDAP via BindDN. These changes add two new flags to LDAP related CLI commands: - `--active` for both LDAP authentication source types - `--disable-synchronize-users` for LDAP via BindDN Signed-off-by: justusbunsi <61625851+justusbunsi@users.noreply.github.com>
* Fix cli command restore-repo: "units" should be splitted to string slice, to ↵wxiaoguang2022-07-012-6/+14
| | | | match the old behavior and match the dump-repo's behavior (#20183)
* Fix `dump-repo` git init, fix wrong error type for NullDownloader (#20182)wxiaoguang2022-07-011-0/+6
| | | | | * Fix `dump-repo` git init * fix wrong error type for NullDownloader
* Allow manager logging to set SQL (#20064)zeripath2022-06-241-0/+27
| | | | | | | | | | | This PR adds a new manager command to switch on SQL logging and to turn it off. ``` gitea manager logging log-sql gitea manager logging log-sql --off ``` Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add more linters to improve code readability (#19989)Wim2022-06-201-1/+1
| | | | | | | | | | Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability - nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. - unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions - wastedassign - https://github.com/sanposhiho/wastedassign - wastedassign finds wasted assignment statements. - notlintlint - Reports ill-formed or insufficient nolint directives - stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)
* Dump should only copy regular files and symlink regular files (#20015)v1.18.0-devwxiaoguang2022-06-181-3/+18
|
* Add fgprof pprof profiler (#20005)zeripath2022-06-181-0/+2
| | | | | | | | | | | | | | | | | | | | | fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together. Go's builtin sampling CPU profiler can only show On-CPU time, but it's better than fgprof at that. Go also includes tracing profilers that can analyze I/O, but they can't be combined with the CPU profiler. fgprof is designed for analyzing applications with mixed I/O and CPU workloads. This kind of profiling is also known as wall-clock profiling. Whilst fgprof can cause significant STW latencies in applications with a lot of goroutines (> 1-10k), these latencies only occur if the profile is requested - it doesn't cause a delay by simply being available. The fgprof profile is mounted on `http://localhost:6060/debug/fgprof?seconds=3` Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove legacy git code (ver < 2.0), fine tune markup tests (#19930)wxiaoguang2022-06-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * clean git support for ver < 2.0 * fine tune tests for markup (which requires git module) * remove unnecessary comments * try to fix tests * try test again * use const for GitVersionRequired instead of var * try to fix integration test * Refactor CheckAttributeReader to make a *git.Repository version * update document for commit signing with Gitea's internal gitconfig * update document for commit signing with Gitea's internal gitconfig Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Don't buffer doctor logger (#19982)Gusted2022-06-161-1/+1
| | | | | | | | | - We don't need to buffer the logger with a thousand capacity. It's not a high-throughput logger, this also caused issue whereby the logger can't keep up with repeated messages being send(somehow they are lost in the queue?). - Resolves #19969 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix cli command restore-repo: "units" should be parsed as StringSlice (#19953)wxiaoguang2022-06-151-3/+3
| | | | | | * Fix cli command restore-repo: "units" should be parsed as StringSlice because after #15790 it's read by c.StringSlice("units"). Before, the "units" were processed by strings.Split * Add checking for invalid unit names Co-authored-by: 6543 <6543@obermui.de>
* fix: some typos (#19956)yutotnh2022-06-131-1/+1
|
* Move some code into models/git (#19879)Lunny Xiao2022-06-122-4/+4
| | | | | | | | | | | | | | | | | | | * Move access and repo permission to models/perm/access * fix test * Move some git related files into sub package models/git * Fix build * fix git test * move lfs to sub package * move more git related functions to models/git * Move functions sequence * Some improvements per @KN4CK3R and @delvh
* Refactor git module, make Gitea use internal git config (#19732)wxiaoguang2022-06-101-23/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor git module, make Gitea use internal git config, add safe.directory config * introduce git.InitSimple and git.InitWithConfigSync, make serv cmd use gitconfig * use HOME instead of GIT_CONFIG_GLOBAL, because git always needs a correct HOME * fix cmd env in cmd/serv.go * fine tune error message * Fix a incorrect test case * fix configAddNonExist * fix configAddNonExist logic, add `--fixed-value` flag, add tests * add configSetNonExist function in case it's needed. * use configSetNonExist for `user.name` and `user.email` * add some comments * Update cmd/serv.go Co-authored-by: zeripath <art27@cantab.net> * Update cmd/serv.go Co-authored-by: zeripath <art27@cantab.net> * Update modules/git/git.go Co-authored-by: zeripath <art27@cantab.net> * Update modules/setting/setting.go Co-authored-by: zeripath <art27@cantab.net> * Update modules/git/repo_attribute.go Co-authored-by: zeripath <art27@cantab.net> * fix spaces in messages * use `configSet("core.protectNTFS", ...)` instead of `globalCommandArgs` * remove GIT_CONFIG_NOSYSTEM, continue to use system's git config * Update cmd/serv.go Co-authored-by: zeripath <art27@cantab.net> * fix merge * remove code for safe.directory * separate git.CommonEnvs to CommonGitCmdEnvs and CommonCmdServEnvs * avoid Golang's data race error Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Move some repository related code into sub package (#19711)Lunny Xiao2022-06-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Move some repository related code into sub package * Move more repository functions out of models * Fix lint * Some performance optimization for webhooks and others * some refactors * Fix lint * Fix * Update modules/repository/delete.go Co-authored-by: delvh <dev.lh@web.de> * Fix test * Merge * Fix test * Fix test * Fix test * Fix test Co-authored-by: delvh <dev.lh@web.de>
* Set Setpgid on child git processes (#19865)zeripath2022-06-031-0/+2
| | | | | | | | | | When Gitea is running as PID 1 git will occassionally orphan child processes leading to (defunct) processes. This PR simply sets Setpgid to true on these child processes meaning that these defunct processes will also be correctly reaped. Fix #19077 Signed-off-by: Andrew Thornton <art27@cantab.net>
* docs: update the ROOT documentation and error messages (#19832)singuliere2022-05-311-1/+1
| | | | | | | | | | | | | | | * docs: update the ROOT documentation and error messages * The documentation now reflects what happens in the setting/repository.go::newRepository function: filepath.Join(AppWorkPath, RepoRootPath) was missing. * The error message displayed when RepoRootPath is not found now displays the value of RepoRootPath. Given the complexity of the construction of this value, only referring to it in the abstract is likely to be misleading to the Gitea admin trying to interpret the message. Co-authored-by: delvh <dev.lh@web.de>
* Move almost all functions' parameter db.Engine to context.Context (#19748)Lunny Xiao2022-05-201-3/+3
| | | | * Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
* [doctor] update the help with fix capabilities (#19762)silentcodeg2022-05-201-2/+2
| | | * [doctor] update the help with fix capabilities
* Update go deps (#19665)65432022-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * update gitea.com/go-chi/binding * update github.com/42wim/sshsig * update github.com/PuerkitoBio/goquery * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/duo-labs/webauthn * update github.com/editorconfig/editorconfig-core-go/v2 * update github.com/emirpasic/gods * update github.com/gliderlabs/ssh * update github.com/go-chi/cors * update github.com/go-enry/go-enry/v2 * update github.com/go-git/go-git/v5 * update github.com/go-ldap/ldap/v3 * update github.com/golang-jwt/jwt/v4 * update github.com/google/pprof * update github.com/klauspost/compress * update github.com/lib/pq * update github.com/markbates/goth * update github.com/minio/minio-go/v7 * update github.com/olivere/elastic/v7 * update github.com/unrolled/render * update github.com/urfave/cli * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark * adopt breaking changes of certmagic
* Move some helper files out of models (#19355)Lunny Xiao2022-05-082-29/+30
| | | | | | | * Move some helper files out of models * Some improvements Co-authored-by: delvh <dev.lh@web.de>
* Remove legacy `+build:` constraint (#19582)wxiaoguang2022-05-022-2/+0
| | | Go 1.17 and later use modern `//go:build` constraints, the old `// +build:` constraints should be removed.
* Federation: return useful statistic information for nodeinfo (#19561)65432022-05-021-1/+1
| | | Add statistic information for total user count, active user count, issue count and comment count for `/nodeinfo`
* Respect DefaultUserIsRestricted system default when creating new user (#19310)Jimmy Praet2022-04-291-3/+17
| | | | | | | | | | | | | | | | | | | * Apply DefaultUserIsRestricted in CreateUser * Enforce system defaults in CreateUser Allow for overwrites with CreateUserOverwriteOptions * Fix compilation errors * Add "restricted" option to create user command * Add "restricted" option to create user admin api * Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed * Revert "Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed" This reverts commit ee95d3e8dc9e9fff4fa66a5111e4d3930280e033.
* Allow package dump skipping (#19506)KN4CK3R2022-04-261-23/+35
| | | | | | | | | | | | | | * Added addReader to support verbose. * Allow skipping packages. * Updated docs. * Update cmd/dump.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* When dumping trim the standard suffices instead of a random suffix (#19440)zeripath2022-04-201-2/+7
| | | | | | | | | | | | | | * When dumping trim the standard suffices instead of a random suffix Instead of using the `path.Ext()` to trim the last "extension" suffix, just iterate through the supported suffices and trim those. Fix #19424 Signed-off-by: Andrew Thornton <art27@cantab.net> * fix enum with to have correct supported types only Co-authored-by: 6543 <6543@obermui.de>
* Warn on SSH connection for incorrect configuration (#19317)Gusted2022-04-051-0/+9
| | | | | | | | | | | | | | | | | | | * Warn on SSH connection for incorrect configuration - When `setting.RepoRootPath` cannot be found(most likely due to incorrect configuration) show "Gitea: Incorrect configuration" on the client-side to help easier with debugging the problem. * Update cmd/serv.go Co-authored-by: delvh <dev.lh@web.de> * Don't leak configuration * Update cmd/serv.go Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Remove legacy `unknwon/com` package (#19298)wxiaoguang2022-04-021-0/+1
| | | | | | | Follows: #19284 * The `CopyDir` is only used inside test code * Rewrite `ToSnakeCase` with more test cases * The `RedisCacher` only put strings into cache, here we use internal `toStr` to replace the legacy `ToStr` * The `UniqueQueue` can use string as ID directly, no need to call `ToStr`
* Remove `git.Command.Run` and `git.Command.RunInDir*` (#19280)wxiaoguang2022-04-011-1/+1
| | | | | | Follows #19266, #8553, Close #18553, now there are only three `Run..(&RunOpts{})` functions. * before: `stdout, err := RunInDir(path)` * now: `stdout, _, err := RunStdString(&git.RunOpts{Dir:path})`
* Add Goroutine stack inspector to admin/monitor (#19207)zeripath2022-03-314-349/+424
| | | | | | | | | | | | | | | | | | | Continues on from #19202. Following the addition of pprof labels we can now more easily understand the relationship between a goroutine and the requests that spawn them. This PR takes advantage of the labels and adds a few others, then provides a mechanism for the monitoring page to query the pprof goroutine profile. The binary profile that results from this profile is immediately piped in to the google library for parsing this and then stack traces are formed for the goroutines. If the goroutine is within a context or has been created from a goroutine within a process context it will acquire the process description labels for that process. The goroutines are mapped with there associate pids and any that do not have an associated pid are placed in a group at the bottom as unbound. In this way we should be able to more easily examine goroutines that have been stuck. A manager command `gitea manager processes` is also provided that can export the processes (with or without stacktraces) to the command line. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Make git.OpenRepository accept Context (#19260)65432022-03-301-1/+1
| | | | | * OpenRepositoryCtx -> OpenRepository * OpenRepository -> openRepositoryWithDefaultContext, only for internal usage
* Update HTTP status codes to modern codes (#18063)KN4CK3R2022-03-231-1/+1
| | | | | | * 2xx/3xx/4xx/5xx -> http.Status... * http.StatusFound -> http.StatusTemporaryRedirect * http.StatusMovedPermanently -> http.StatusPermanentRedirect
* Use `ctx` instead of `db.DefaultContext` in some ↵wxiaoguang2022-03-221-1/+1
| | | | | | | | | | | | packages(routers/services/modules) (#19163) * Remove `db.DefaultContext` usage in routers, use `ctx` directly * Use `ctx` directly if there is one, remove some `db.DefaultContext` in `services` * Use ctx instead of db.DefaultContext for `cmd` and some `modules` packages * fix incorrect context usage
* Fix the bug: deploy key with write access can not push (#19010)wxiaoguang2022-03-222-3/+3
| | | Use DeployKeyID to replace the IsDeployKey, then CanWriteCode uses the DeployKeyID to check the write permission.
* Fix flag validation (#19046)Norwin2022-03-101-1/+1
| | | | Regression from #5785
* Add a "admin user generate-access-token" subcommand (#17722)mscherer2022-03-041-0/+57
| | | | | | | | | | | | | | | | | | | | * Add a "admin user generate-access-token" subcommand Fixes #17721 * Update cmd/admin.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> * Update cmd/admin.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> * Fix code to match new interfaces Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Add LDAP group sync to Teams, fixes #1395 (#16299)Sven Seeberg2022-02-111-1/+0
| | | | | | | | | | * Add setting for a JSON that maps LDAP groups to Org Teams. * Add log when removing or adding team members. * Sync is being run on login and periodically. * Existing group filter settings are reused. * Adding and removing team members. * Sync not existing LDAP group. * Login with broken group map JSON.
* Support custom ACME provider (#18340)Cristian Le2022-02-082-14/+48
| | | | | | * Added ACMECAURL option to support custom ACME provider. Closes #18306 * Refactor setting.go https settings, renamed options and variables, and documented app.example.ini * Refactored runLetsEncrypt to runACME * Improved documentation
* Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552)65432022-02-061-1/+1
|