aboutsummaryrefslogtreecommitdiffstats
path: root/modules/options
Commit message (Collapse)AuthorAgeFilesLines
* Introduce path Clean/Join helper functions (#23495)wxiaoguang2023-03-213-85/+69
| | | | | | | | | | | | | | | Since #23493 has conflicts with latest commits, this PR is my proposal for fixing #23371 Details are in the comments And refactor the `modules/options` module, to make it always use "filepath" to access local files. Benefits: * No need to do `util.CleanPath(strings.ReplaceAll(p, "\\", "/"))), "/")` any more (not only one before) * The function behaviors are clearly defined
* Use CleanPath instead of path.Clean (#23371)Lunny Xiao2023-03-081-5/+5
| | | As title.
* Reduce duplicate and useless code in options (#23369)Jason Song2023-03-084-152/+68
| | | | | | | | Avoid maintaining two copies of code, some functions can be used with both `bindata` and `no bindata`. And removed `GetRepoInitFile`, it's useless now. `Readme`/`Gitignore`/`License`/`Labels` will clean the name and use custom files when available.
* Clean Path in Options (#23006)JakobDev2023-03-082-8/+8
| | | | | | | | | | | | | | | At the Moment it is possible to read files in another Directory as supposed using the Options functions. e.g. `options.Gitignore("../label/Default) `. This was discovered while working on #22783, which exposes `options.Gitignore()` through the public API. At the moment, this is not a security problem, as this function is only used internal, but I thought it would be a good idea to make a PR to fix this for all types of Options files, not only Gitignore, to make it safe for the further. This PR should be merged before the linked PR. --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Add loading yaml label template files (#22976)Lauris BH2023-03-021-0/+44
| | | | | | | | Extract from #11669 and enhancement to #22585 to support exclusive scoped labels in label templates * Move label template functionality to label module * Fix handling of color codes * Add Advanced label template
* Implement FSFE REUSE for golang files (#21840)flynnnnnnnnnn2022-11-275-10/+5
| | | | | | | | | 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>
* Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)delvh2022-10-241-4/+4
| | | | | | | | | Found using `find . -type f -name '*.go' -print -exec vim {} -c ':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;` Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix and improve incorrect error messages (#21342)delvh2022-10-061-5/+4
| | | L
* Share HTML template renderers and create a watcher framework (#20218)zeripath2022-08-283-1/+65
| | | | | | | | | | | | | | | | | | | | | | | | | The recovery, API, Web and package frameworks all create their own HTML Renderers. This increases the memory requirements of Gitea unnecessarily with duplicate templates being kept in memory. Further the reloading framework in dev mode for these involves locking and recompiling all of the templates on each load. This will potentially hide concurrency issues and it is inefficient. This PR stores the templates renderer in the context and stores this context in the NormalRoutes, it then creates a fsnotify.Watcher framework to watch files. The watching framework is then extended to the mailer templates which were previously not being reloaded in dev. Then the locales are simplified to a similar structure. Fix #20210 Fix #20211 Fix #20217 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove legacy `+build:` constraint (#19582)wxiaoguang2022-05-023-3/+0
| | | Go 1.17 and later use modern `//go:build` constraints, the old `// +build:` constraints should be removed.
* format with gofumpt (#18184)65432022-01-202-18/+6
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Remove golang vendored directory (#18277)techknowlogick2022-01-141-1/+1
| | | | | | | * rm go vendor * fix drone yaml * add to gitignore
* refactor: move from io/ioutil to io and os package (#17109)Eng Zer Jun2021-09-222-7/+8
| | | | | | | | | The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add bundle download for repository (#14538)John Olheiser2021-08-243-5/+8
| | | | | | | | | | | | | | | | | * Add bundle download Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix fmt Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix build tags Signed-off-by: jolheiser <john.olheiser@gmail.com> * Download specific commit Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Add StatDir and replace com.StatDir (#14099)Lunny Xiao2020-12-222-7/+3
| | | | | | | | | * Add StatDir and replace com.StatDir * a nit * Remove wrong file Co-authored-by: 6543 <6543@obermui.de>
* Handle and propagate errors when checking if paths are Dirs, Files or Exist ↵zeripath2020-11-272-7/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | (#13186) * Ensure errors from IsDir propagate * Handle errors when checking IsFile * Handle and propagate errors from IsExist * Update modules/templates/static.go * Update modules/templates/static.go * Return after ctx.ServerError * Apply suggestions from code review * Fix tests The previous merge managed to break repo_form.go Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv>
* Rename scripts to build and add revive command as a new build tool command ↵Lunny Xiao2020-04-031-1/+1
| | | | | (#10942) Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Implement "embedded" command to extract static resources (#9982)guillep2k2020-02-021-0/+31
| | | | | | | | | | | | | | | | | | | | | | | * draft * Implement extract command * Fix nits and force args on extract * Add !bindata stub, support Windows, fmt * fix vendored flag * Remove leading slash for matching * Add docs * Fix typos * Add embedded view command Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Implement basic app.ini and path checks to doctor cmd (#10064)guillep2k2020-01-302-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | * Add doctor check of app.ini paths * Make /custom dir not mandatory * Fix message and improve interface * Update cmd/doctor.go Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com> * Apaise lint * Isn't the linter a sweet? (1) * Isn't the linter a sweet? (2) * Isn't the linter a sweet?? (3) * Restart CI Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com> Co-authored-by: zeripath <art27@cantab.net>
* Generate Bindata iff TAGS="bindata" and not up-to-date (#10004)zeripath2020-01-273-25/+9
| | | | | | | | | | | | | | | | | | | | | | * Only generate bindata if necessary * Only generate bindata if they are not up-to-date * generate a hash of the fileinfo and use that to keep up-to-date * Newer test is redundant * handle missing bindata and clean * Only update hash after successful write * switch to sha1 hash * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Use gitea forked macaron (#7933)Tamal Saha2019-08-232-2/+4
| | | Signed-off-by: Tamal Saha <tamal@appscode.com>
* remove unnecessary fmt on generate bindata (#7706)Lunny Xiao2019-08-011-1/+0
|
* Use vfsgen instead of go-bindata (#7080)Lunny Xiao2019-06-033-5/+50
| | | | | | | | | | * use vfsgen instead of go-bindata * fix templates * fix fmt * vendor vsfgen
* Fix typos in models/ and modules/ (#1248)Ethan Koenig2017-03-152-2/+2
|
* Add default values for settings (#455)Lunny Xiao2016-12-232-0/+10
| | | | | | | | | | * add default values for settings * more default values * more default settings and labels resource * mv locale to options
* Bindata is optional and over-writable on restart (#354)Thomas Boerger2016-12-223-0/+229
* Moved conf assets into options folder * Dropped old bindata * Started to integrate options bindata and accessors * Do not enforce a builtin app.ini * Replaced bindata calls with options * Dropped bindata task from makefile, it's the generate task now * Always embedd app.ini to provide sane config defaults * Use sane defaults for the configuration * Defined default value for SSH_KEYGEN_PATH * Dropped "NEVER EVER MODIFY THIS FILE" header from app.ini * Fixed new paths in latest test additions * Drop bindata with make clean task * Set more proper default values