aboutsummaryrefslogtreecommitdiffstats
path: root/modules/util
Commit message (Collapse)AuthorAgeFilesLines
* Refactor error system (#33771)wxiaoguang12 days1-20/+20
| | | It should not expose `util.SilentWrap` or construct it manually.
* Upgrade golangci-lint to v1.64.5 (#33654)wxiaoguang2025-02-211-1/+1
| | | | | Use `usetesting` instead of deprecated `tenv`. 1. Follow up #33648 2. Make lint pass and add some comments
* Use test context in tests and new loop system in benchmarks (#33648)TheFox0x72025-02-202-3/+3
| | | | | | | | Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor error system (#33626)wxiaoguang2025-02-171-6/+9
|
* Fix various problems (artifact order, api empty slice, assignee check, fuzzy ↵wxiaoguang2025-02-131-0/+7
| | | | | | | | | | prompt, mirror proxy, adopt git) (#33569) * Make artifact list output a stable order * Fix #33506 * Fix #33521 * Fix #33288 * Fix #33196 * Fix #33561
* Feature: Support workflow event dispatch via API (#33545)wxiaoguang2025-02-111-0/+29
| | | | | | | | | Fix: https://github.com/go-gitea/gitea/issues/31765 (Re-open #32059) --------- Co-authored-by: Bence Santha <git@santha.eu> Co-authored-by: Bence Sántha <7604637+bencurio@users.noreply.github.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
* Worktime tracking for the organization level (#19808)K Kovacs2025-02-032-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dear Gitea team, first of all, thanks for the great work you're doing with this project. I'm planning to introduce Gitea at a client site, and noticed that while there is time recording, there are no project-manager-friendly reports to actually make use of that data, as were also mentioned by others in #4870 #8684 and #13531. Since I had a little time last weekend, I had put together something that I hope to be a useful contribution to this great project (while of course useful for me too). This PR adds a new "Worktime" tab to the Organisation level. There is a date range selector (by default set to the current month), and there are three possible views: - by repository, - by milestone, and - by team member. Happy to receive any feedback! There are several possible future improvements of course (predefined date ranges, charts, a member time sheet, matrix of repos/members, etc) but I hope that even in this relatively simple state this would be useful to lots of people. <img width="1161" alt="Screen Shot 2022-05-25 at 22 12 58" src="https://user-images.githubusercontent.com/118010/170366976-af00c7af-c4f3-4117-86d7-00356d6797a5.png"> Keep up the good work! Kristof --------- Co-authored-by: user <user@kk-git1> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make tracked time representation display as hours (#33315)Vladimir Sysoev2025-01-192-64/+16
| | | | | | | | | | Estimated time represented in hours it might be convenient to have tracked time represented in the same way to be compared and managed. --------- Co-authored-by: Sysoev, Vladimir <i@vsysoev.ru> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor older tests to use testify (#33140)TheFox0x72025-01-091-4/+6
| | | | | Refactor checks to use assert/require Use require.Eventually for waiting in elastic and meilisearch tests Use require to exit early instead of assert
* Fix unittest and repo create bug (#33061)wxiaoguang2024-12-312-59/+48
| | | | | | | 1. `StatDir` was not right, fix the FIXME 2. Clarify the test cases for `IsUsableRepoName` 3. Fix regression bug in `repo-new.ts` Fix #33060
* [Feature] Private README.md for organization (#32872)Chai-Shi2024-12-311-0/+1
| | | | | | | | Implemented #29503 --------- Co-authored-by: Ben Chang <ben_chang@htc.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Improve "ellipsis string" (#32989)wxiaoguang2024-12-262-8/+60
|
* Refactor "string truncate" (#32984)wxiaoguang2024-12-262-46/+158
|
* Do not render truncated links in markdown (#32980)wxiaoguang2024-12-263-17/+25
| | | Fixes #31780
* Refactor pprof labels and process desc (#32909)wxiaoguang2024-12-202-0/+45
| | | | | | * Deprecate "gopid" in log, it is not useful and requires very hacky approach * Remove "git.Command.SetDescription" because it is not useful and only makes the logs too flexible
* Update go tool dependencies (#32916)silverwind2024-12-192-3/+3
| | | | | | | | | | | | | | | | | Update all go tool dependencies to latest version. WIP because I think there are new gopls errors, would like to confirm them on CI first. Here is from a local run: ``` modules/markup/markdown/goldmark.go:115:37-53: unnecessary type arguments modules/markup/html.go:45:32-49: unnecessary type arguments modules/markup/internal/renderinternal.go:20:33-49: unnecessary type arguments modules/markup/common/linkify.go:27:32-49: unnecessary type arguments modules/util/time_str.go:28:39-63: unnecessary type arguments routers/web/repo/pull.go:704:19: impossible condition: non-nil == nil modules/util/util_test.go:248:14-23: unused parameter: other ``` ~~Backport because the `gxz` update might have security benefits.~~
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-154-16/+15
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* Issue time estimate, meaningful time tracking (#23113)Illya Marchenko2024-12-052-0/+140
| | | | | | | | | | | | | Redesign the time tracker side bar, and add "time estimate" support (in "1d 2m" format) Closes #23112 --------- Co-authored-by: stuzer05 <stuzer05@gmail.com> Co-authored-by: Yarden Shoham <hrsi88@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Validate OAuth Redirect URIs (#32643)Rowan Bohde2024-11-281-0/+2
| | | | | | | This fixes a TODO in the code to validate the RedirectURIs when adding or editing an OAuth application in user settings. This also includes a refactor of the user settings tests to only create the DB once per top-level test to avoid reloading fixtures.
* Refactor markup package (#32399)wxiaoguang2024-11-041-0/+6
| | | | | | To make the markup package easier to maintain: 1. Split some go files into small files 2. Use a shared util.NopCloser, remove duplicate code 3. Remove unused functions
* Refactor tests to prevent from unnecessary preparations (#32398)wxiaoguang2024-11-012-0/+32
|
* Refactor to use UnsafeStringToBytes (#31358)Oleksandr Redko2024-06-142-5/+3
| | | | | | | The PR replaces all `goldmark/util.BytesToReadOnlyString` with `util.UnsafeBytesToString`, `goldmark/util.StringToReadOnlyBytes` with `util.UnsafeStringToBytes`. This removes one `TODO`. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enable `unparam` linter (#31277)silverwind2024-06-111-6/+3
| | | | | | | | | | | | Enable [unparam](https://github.com/mvdan/unparam) linter. Often I could not tell the intention why param is unused, so I put `//nolint` for those cases like webhook request creation functions never using `ctx`. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Azure blob storage support (#30995)Lunny Xiao2024-05-301-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix project column title overflow (#31011)wxiaoguang2024-05-201-4/+5
| | | | | | By the way: * Re-format the "color.go" to Golang code style * Remove unused `overflow-y: scroll;` from `.project-column` because there is `overflow: visible`
* Enable more `revive` linter rules (#30608)silverwind2024-04-221-3/+3
| | | | | | | | | | | 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`.
* Fix and rewrite contrast color calculation, fix project-related bugs (#30237)silverwind2024-04-072-49/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | 1. The previous color contrast calculation function was incorrect at least for the `#84b6eb` where it output low-contrast white instead of black. I've rewritten these functions now to accept hex colors and to match GitHub's calculation and to output pure white/black for maximum contrast. Before and after: <img width="94" alt="Screenshot 2024-04-02 at 01 53 46" src="https://github.com/go-gitea/gitea/assets/115237/00b39e15-a377-4458-95cf-ceec74b78228"><img width="90" alt="Screenshot 2024-04-02 at 01 51 30" src="https://github.com/go-gitea/gitea/assets/115237/1677067a-8d8f-47eb-82c0-76330deeb775"> 2. Fix project-related issues: - Expose the new `ContrastColor` function as template helper and use it for project cards, replacing the previous JS solution which eliminates a flash of wrong color on page load. - Fix a bug where if editing a project title, the counter would get lost. - Move `rgbToHex` function to color utils. @HesterG fyi --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Giteabot <teabot@gitea.io>
* 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-0/+8
| | | | | | | | | | 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>
* Add API for `Variables` (#29520)sillyguodong2024-03-282-0/+14
| | | | | | | close #27801 --------- Co-authored-by: silverwind <me@silverwind.io>
* Performance improvements for pull request list page (#29900)Lunny Xiao2024-03-211-1/+10
| | | | | | | | | | | This PR will avoid load pullrequest.Issue twice in pull request list page. It will reduce x times database queries for those WIP pull requests. Partially fix #29585 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Add test for webhook (#29755)wxiaoguang2024-03-141-0/+9
| | | Follow #29690
* Some performance optimization on dashboard and issues page (#29010)Lunny Xiao2024-03-121-0/+9
| | | | | | | | | This PR do some loading speed optimization for feeds user interface pages. - Load action users batchly but not one by one. - Load action repositories batchly but not one by one. - Load action's Repo Owners batchly but not one by one. - Load action's possible issues batchly but not one by one. - Load action's possible comments batchly but not one by one.
* remove util.OptionalBool and related functions (#29513)65432024-03-021-51/+0
| | | | | | and migrate affected code _last refactoring bits to replace **util.OptionalBool** with **optional.Option[bool]**_
* migrate some more "OptionalBool" to "Option[bool]" (#29479)65432024-02-292-14/+16
| | | | | | | | just some refactoring bits towards replacing **util.OptionalBool** with **optional.Option[bool]** --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Use `crypto/sha256` (#29386)KN4CK3R2024-02-252-3/+2
| | | | | | | | Go 1.21 improved the performance of `crypto/sha256`. It's now similar to `minio/sha256-simd`, so we should just use the standard libs. https://go.dev/doc/go1.21#crypto/sha256 https://go-review.googlesource.com/c/go/+/408795 https://github.com/multiformats/go-multihash/pull/173
* Add `io.Closer` guidelines (#29387)KN4CK3R2024-02-251-0/+1
| | | Co-authored-by: Yarden Shoham <git@yardenshoham.com>
* Start to migrate from `util.OptionalBool` to `optional.Option[bool]` (#29329)65432024-02-231-0/+18
| | | just create transition helper and migrate two structs
* Refactor JWT secret generating & decoding code (#29172)wxiaoguang2024-02-162-25/+0
| | | | | | | | 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 some RPM registry flaws (#28782)KN4CK3R2024-01-191-0/+8
| | | | | | | | | | | | | | | | | | | Related #26984 (https://github.com/go-gitea/gitea/pull/26984#issuecomment-1889588912) Fix admin cleanup message. Fix models `Get` not respecting default values. Rebuild RPM repository files after cleanup. Do not add RPM group to package version name. Force stable sorting of Alpine/Debian/RPM repository data. Fix missing deferred `Close`. Add tests for multiple RPM groups. Removed non-cached `ReplaceAllStringRegex`. If there are multiple groups available, it's stated in the package installation screen: ![grafik](https://github.com/go-gitea/gitea/assets/1666336/8f132760-882c-4ab8-9678-77e47dfc4415)
* Add option to disable ambiguous unicode characters detection (#28454)wxiaoguang2023-12-171-2/+12
| | | | | | | | * Close #24483 * Close #28123 * Close #23682 * Close #23149 (maybe more)
* Upgrade to golangci-lint@v1.55.0 (#27756)silverwind2023-10-241-2/+1
| | | https://github.com/golangci/golangci-lint/releases/tag/v1.55.0
* Refactor lfs requests (#26783)Chongyi Zheng2023-09-181-0/+1
| | | | | | | | | | | | | | - Refactor lfs request code - The original code uses `performRequest` function to create the request, uses a callback to modify the request, and then send the request. - Now it's replaced with `createRequest` that only creates request and `performRequest` that only sends the request. - Reuse `createRequest` and `performRequest` in `http_client.go` and `transferadapter.go` --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add `RemoteAddress` to mirrors (#26952)KN4CK3R2023-09-161-0/+9
| | | | | 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.
* Replace `util.SliceXxx` with `slices.Xxx` (#26958)CaiCandong2023-09-072-83/+7
|
* Use Go 1.21 and update dependencies (#26878)wxiaoguang2023-09-031-16/+0
| | | | | | To make sure Gitea's next release's lifecycle could have active Golang support. And min/max are builtin now.
* Handle base64 decoding correctly to avoid panic (#26483)wxiaoguang2023-08-142-0/+25
| | | Fix the panic if the "base64 secret" is too long.
* Less naked returns (#25713)65432023-07-072-0/+14
| | | | | just a step towards #25655 and some related refactoring
* Replace `interface{}` with `any` (#25686)silverwind2023-07-045-12/+12
| | | | | Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`. Basically the same [as golang did](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
* Store and use seconds for timeline time comments (#25392)65432023-06-231-1/+3
| | | | | | | | | | | this will allow us to fully localize it later PS: we can not migrate back as the old value was a one-way conversion prepare for #25213 --- *Sponsored by Kithara Software GmbH*