Added `/local/` folder in `.gitignore` for developer personal files (rebuild, deploy with custom config, backups, sqlite databases, test curl query scripts, custom configs).
In case of building, deploing, testing locally developer needs some folder for custom personal scripts, configs, data. `/local/` folder in project root is a good place to store all this files.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/1816
Co-authored-by: Alex Syrnikov <alex19srv@gmail.com>
Co-committed-by: Alex Syrnikov <alex19srv@gmail.com>
(cherry picked from commit c8138849ebecd88d62d10584195a748263de4710)
(cherry picked from commit 7880660738574929184dcb787687c3de3baa2205)
(cherry picked from commit cf9af01d88cf4e6429417189d52c269f9fd8efb9)
(cherry picked from commit 8d1dcc9e0ec933ca99190700c99ff63106db2839)
(cherry picked from commit 93dd605948635acb358960fc25563031d4aa5527)
(cherry picked from commit 74972ae17f5e25c9fa141d4d667e730a95f166f9)
(cherry picked from commit f76ce785782848318ba8d58336e02ef930455752)
(cherry picked from commit eb3e46cd3be5408cb53e1f61dab408787b4d317d)
(cherry picked from commit 5b0125591d4005c7465da21dc8a8e290858db9d4)
(cherry picked from commit 31d86205d25f4fd5a5b2726eaf701a387c9f3391)
(cherry picked from commit c2e62c6705a1979883d1b164118fb36360835a32)
- Add the experimental
[deacode](https://pkg.go.dev/golang.org/x/tools/internal/cmd/deadcode)
linter to Forgejo.
- To deal with false positives that can happen due to build tags or with code
that's currently only referenced by test code, the output of the tool is
compared against a known-good output.
- This commit doesn't make any attempt to remove any deadcode.
(cherry picked from commit ac462279e9361070326d512fc209b6f148f27865)
(cherry picked from commit b5ea6e85acecb8c02d18d51ec489bb1d329a33ce)
(cherry picked from commit 5915f3643c1939ab09dcac8f9fcb74bd4231a16d)
[CLEANUP] Remove deadcode
- This is deadcode since https://codeberg.org/forgejo/forgejo/pulls/1802
removed the usage of it.
(cherry picked from commit d840b9923e1a7aad7306c6b4d02df771ed0f40f4)
(cherry picked from commit 9442bab6266807141a14a647d3bc383233fc56e9)
(cherry picked from commit 0de9d18863c6af44941c7021548cdb07173ba3c0)
(cherry picked from commit 26abf783746ef29e66eea966160e2f9c139add26)
(cherry picked from commit 05d3a143c3785f3cc5e7f561aa2ad2ba556b55cc)
(cherry picked from commit 4b3d38d5e15b0fd02839d5687b634e7999e12666)
(cherry picked from commit a726e7198613b330a58c8c6dfc8866c360fbe555)
(cherry picked from commit cb62ae5b9885bcd5c2b6cb60f0e9cce6a991cc3c)
(cherry picked from commit 8195ba06d52fc1a05e9907149bb441b66887870e)
(cherry picked from commit 4570fb591aac0359a36800c8cadcd71613bdc7df)
(cherry picked from commit 1f4d33de2b68c776a305fe38fe6be5ae510ce983)
(cherry picked from commit 5e418789d930ef8dc27bc5cb32f96350f5d64e06)
(cherry picked from commit 3af6fd2ad38bfbe98ad72e20257704bced7988fa)
(cherry picked from commit 6926787d67778f2a3bb2c9d79137a74b894e8b7d)
(cherry picked from commit fe58e86a97d4ab0017908a55a9a1f240e241e3f8)
(cherry picked from commit 5bf7ead6255889b5cc4ae81c3ce52d6d09e0aef3)
(cherry picked from commit 44480ea79426581df15242d6ee7222be97709268)
(cherry picked from commit 813848cebe61752568b9c28b9e912170e70bffb8)
(cherry picked from commit 9c8d889e782ccaf3b3e71bd3abdc0777b2fd5cf5)
(cherry picked from commit 914b1dcaf6d71354fd66c8c81121ad1f3e251e46)
(cherry picked from commit 5449933efa74474273d882e7eb7c7840cc2990b0)
(cherry picked from commit 67f007b8244c827bf9a9597834c8657440ce89f9)
(cherry picked from commit cf93863cd2378b3f239b853ed5b7985fc342cd24)
(cherry picked from commit 82177a0f667754d8234765551a4359b4b05b8086)
(cherry picked from commit 3ef1fe468ac20e609b20eb7e93ed8cc2356c130a)
(cherry picked from commit 305c935508cec1d4d41bac897c77f0ab80c51a7a)
(cherry picked from commit 268f12c53c60d46372d448af7d5ce8cef3998d21)
(cherry picked from commit 2e6c29fb2f5a3cb800b4d5881de8861f34b29fcb)
(cherry picked from commit 173aa4b3b1823f4b1cf9f1e4b4c0cc7c8c07b470)
(cherry picked from commit 9112b323d18317f0cf542fdbd98868a4f8382982)
(cherry picked from commit 54031769ee355b4888aa4128df822ab154e4ee50)
(cherry picked from commit afc287c17901c292c1b41270ceed4086c2f7faca)
(cherry picked from commit 225d6f7ab7966a358e138afe7038d27b093102f4)
(cherry picked from commit 41001442e35365e2e6180b4e8dade6fbd57508d7)
Mainly for MySQL/MSSQL.
It is important for Gitea to use case-sensitive database charset
collation. If the database is using a case-insensitive collation, Gitea
will show startup error/warning messages, and show the errors/warnings
on the admin panel's Self-Check page.
Make `gitea doctor convert` work for MySQL to convert the collations of
database & tables & columns.
* Fix #28131
## ⚠️ BREAKING ⚠️
It is not quite breaking, but it's highly recommended to convert the
database&table&column to a consistent and case-sensitive collation.
Now that we have the `/assets` directory, we can put`licenses.txt`
directly into it instead of incorrect `/js` path which was previously
only done to avoid reserving a username.
---------
Co-authored-by: Giteabot <teabot@gitea.io>
Move `public/*` to `public/assets/*`
Some old PRs (like #15219) introduced inconsistent directory system.
For example: why the local directory "public" is accessed by
`http://site/assets`? How to serve the ".well-known" files properly in
the public directory?
For convention rules, the "public" directory is widely used for the
website's root directory. It shouldn't be an exception for Gitea.
So, this PR makes the things consistent:
* `http://site/assets/foo` means `{CustomPath}/public/assets/foo`.
* `{CustomPath}/public/.well-known` and `{CustomPath}/public/robots.txt`
can be used in the future.
This PR is also a prerequisite for a clear solution for:
* #21942
* #25892
* discourse.gitea.io: [.well-known path serving custom files behind
proxy?](https://discourse.gitea.io/t/well-known-path-serving-custom-files-behind-proxy/5445/1)
This PR is breaking for users who have custom "public" files (CSS/JS).
After getting approvals, I will update the documents.
----
## ⚠️ BREAKING ⚠️
If you have files in your "custom/public/" folder, please move them to
"custom/public/assets/".
---------
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Giteabot <teabot@gitea.io>
# The problem
There were many "path tricks":
* By default, Gitea uses its program directory as its work path
* Gitea tries to use the "work path" to guess its "custom path" and
"custom conf (app.ini)"
* Users might want to use other directories as work path
* The non-default work path should be passed to Gitea by GITEA_WORK_DIR
or "--work-path"
* But some Gitea processes are started without these values
* The "serv" process started by OpenSSH server
* The CLI sub-commands started by site admin
* The paths are guessed by SetCustomPathAndConf again and again
* The default values of "work path / custom path / custom conf" can be
changed when compiling
# The solution
* Use `InitWorkPathAndCommonConfig` to handle these path tricks, and use
test code to cover its behaviors.
* When Gitea's web server runs, write the WORK_PATH to "app.ini", this
value must be the most correct one, because if this value is not right,
users would find that the web UI doesn't work and then they should be
able to fix it.
* Then all other sub-commands can use the WORK_PATH in app.ini to
initialize their paths.
* By the way, when Gitea starts for git protocol, it shouldn't output
any log, otherwise the git protocol gets broken and client blocks
forever.
The "work path" priority is: WORK_PATH in app.ini > cmd arg --work-path
> env var GITEA_WORK_DIR > builtin default
The "app.ini" searching order is: cmd arg --config > cmd arg "work path
/ custom path" > env var "work path / custom path" > builtin default
## ⚠️ BREAKING
If your instance's "work path / custom path / custom conf" doesn't meet
the requirements (eg: work path must be absolute), Gitea will report a
fatal error and exit. You need to set these values according to the
error log.
----
Close #24818
Close #24222
Close #21606
Close #21498
Close #25107
Close #24981
Maybe close #24503
Replace #23301
Replace #22754
And maybe more
So I found this [linter](https://github.com/Riverside-Healthcare/djlint)
which features a mode for go templates, so I gave it a try and it did
find a number of valid issue, like unbalanced tags etc. It also has a
number of bugs, I had to disable/workaround many issues.
Given that this linter is written in python, this does add a dependency
on `python` >= 3.8 and `poetry` to the development environment to be
able to run this linter locally.
- `e.g.` prefixes on placeholders are removed because the linter had a
false-positive on `placeholder="e.g. cn=Search"` for the `attr=value`
syntax and it's not ideal anyways to write `e.g.` into a placeholder
because a placeholder is meant to hold a sample value.
- In `templates/repo/settings/options.tmpl` I simplified the logic to
not conditionally create opening tags without closing tags because this
stuff confuses the linter (and possibly the reader as well).
It's been disabled by default since 1.17
(https://github.com/go-gitea/gitea/pull/18914), and it never really
delivered any benefit except being another cache layer that has its own
unsolved invalidation issues. HTTP cache works, we don't need two cache
layers at the browser for assets.
## ⚠️ BREAKING
You can remove the config `[ui].USE_SERVICE_WORKER` from your `app.ini`
now.
`make go-licenses` will generate `assets/go-licenses.json` which is then included in the webpack build.
This step depends on both go and node being present, so unfortunately, I could not automate the generation by hooking it up to `tidy` as that target is triggered on CI where we do not have a docker image with both go an node.
It should be ran from time to time, ideally after each go mod update.
- Update all JS dependencies to latest version
- Use Node 16 on CI
- Add new lint rules
- Add some gitignore entries for debug files
Co-authored-by: Lauris BH <lauris@nix.lv>
* Benchmark Integration TESTS
* CI: add benching-arm64 pipeline
* BenchmarkRepo: name test case tests
* Fix BenchmarkRepoBranchCommit beside Create new Branch
* CI: benching use amd64
* rm total broken "BenchmarkRepo"
* dont run benchmark in CI
- Don't package node_modules in tarballs, they are not cross-platform
anymore and npm cache should not be messed with directly. Instead,
require an internet connection to rebuild the UI, which is not necessary
in the general use case because prebuilt UI files are shipped in the
public directory.
- Simplify the fomantic build and make the target phony. We don't need
anything more for something that is rarely ran.
- Use regular tar again to build tarballs and add variable for excludes
- Disable annoying npm update notifications
Fixes: https://github.com/go-gitea/gitea/pull/14578
Fixes: https://github.com/go-gitea/gitea/pull/15256
Fixes: https://github.com/go-gitea/gitea/pull/15262
Co-authored-by: 6543 <6543@obermui.de>
* Vendor node mods as cache; fix esbuild/fomantic offline build
* Fix --exclude; use bsdtar for consistent globbing
* Fall back to GNU tar; forward-compatible for APT 2.0
* Avoid having extd. attrs with bsdtar
* Dependency and misc. optimizations
* Remove extra code after esbuild-loader update
Co-authored-by: Mike L <cl.jeremy@qq.com>
We rarely change fomantic-ui or its configuration so it's kind of a
waste to have it rebuild on every CI run. These changes remove the
fomantic files from the build and instead add the relevant output files
to the git index, which should shave of 2-3 minutes on every CI run.
`make fomantic` should still work and should be ran whenever fomantic is
updated or its configuration is changed.
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Move jquery-minicolors to npm/webpack
- Unvendor and add as npm dependency
- Removed unneeded backend variable
- Fixed existing bug where picker would previously initizalize to the
same green color when editing a label.
There was probably a version bump because the previous version was
over 3 years old but it seems to be compatible.
* use file-loader
* trailing comma and comment update
* misc tweaks
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add 'watch-backend'
This leverages `air` to watch the backend files and trigger `make
backend` automatically when they change. It seems to work rather well
together with `watch-frontend`.
Fixes: https://github.com/go-gitea/gitea/issues/12318
* rework docs to a new section for continuous build
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Introduce 'make svg' which calls a node script that compiles svg files
to `public/img/svg`. These files are vendored to not create a dependency
on Node for the backend build.
On the frontend side, configure webpack using `raw-loader` so SVGs can
be imported as string.
Also moved our existing SVGs to web_src/svg for consistency.
Fixes: https://github.com/go-gitea/gitea/issues/11618
This saves around 3 MB binary size by not including useless fomantic
files in the build. Also, this allows us to move jQuery into the main
bundle as well which eliminates a few HTTP requests.
Also included are webpack config changes:
- split less and css loaders to speed up compliation
- enable css sourcemaps
- switch css minfier plugin to cssnano-webpack-plugin which works better
for sourcemaps than the previous plugin
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Rename custom/conf/app.ini.sample to custom/conf/app.sample.ini for better syntax light on editor
* rename to app.example.ini
* per @6543 's comment, update all references on docs
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
#11538 moved the serviceworker to webbox but unfortunately
created the serviceworker in public/js rather than public/
This PR fixes this, fixing multiple issues with broken js
as a result of that change.
Signed-off-by: Andrew Thornton art27@cantab.net
* Switch code editor to Monaco
This switches out CodeMirror for Monaco which is based on the same code
base as VS code and should work pretty similar to it.
It does add a few async chunks, totalling around 10MB to our build. It
currently supports around 65 languages and in the default configuration,
each language would emit one ugly [number].js chunk, so I opted to
combine them all into a single file for now.
CodeMirror is still being used under the hood by SimpleMDE so it can not
be removed yet.
* inline editorconfig, fix diff, use for markdown, remove more dead code
* refactors, remove jquery usage
* use tab_width
* fix intellisense
* rename function for clarity
* misc tweaks, enable webpack progress display
* only use --progress on dev build
* remove useless borders in arc-green
* fix typo
* remove obsolete comment
* small refactor
* fix file creation and various refactors
* unset useTabStops too when no editorconfig
* small refactor
* disable webpack's [big] warnings
* remove useless await
* fix dark theme check
* rename chunk to 'monaco'
* add to .gitignore and delete webpack dest before build
* increase editor height
* support more editorconfig properties
* remove empty element filter
* rename
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Add option to use /tmp for test repositories
* Fix exit status
* Add feedback about using tmp repos
Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Prevent Firefox from using apple-touch-icon
The opaque background does not work well in Firefox which uses the icon
as a "rich icon". Prevent this by not specifying it in HTML. Real Apple
devices will still request the icon on the static path.
Fixes: https://github.com/go-gitea/gitea/issues/10394
Also adjust gitignore so app.ini.sample becomes searchable and fixed a
variable name in app.ini.sample.
* fix gitignore
* Add frontend/backend make targets, fix source release
- Add 'make backend' and 'make frontend' make targets which are used to
build go and js/css/svg files respectively.
- The 'backend' target can be invoked without requiring Node.js to be
present on the system if pre-built frontend assets are present like
in the release source tarballs.
- Fix source releases missing 'dist' folders inside 'node_modules' which
were erronously excluded from tar.
- Store VERSION in file VERSION for the release tarballs and prefer that
file over git-derived version.
* fix release task
* fix typo
* fix another typo
* Use evidence file as dependency instead of dir
* fix eol
* Update .gitignore
Co-Authored-By: silverwind <me@silverwind.io>
* Use FOMANTIC_SOURCES to establish dependencies as per @silverwind
Co-authored-by: silverwind <me@silverwind.io>
* 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 npm to manage fomantic
* Only build needed semantic components
* Fix make
* Don't import fonts from google sites since we have loaded
* [misc] devendor fomantic-ui and rebuild upon src or config changes only
Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
* Change sort alphabetically of semantic components
* Fix trailing slash
* fix makefile
* Remove dependency to gulp from package.json
* Fix something
* Simplife the makefile
* add missed fomantic compnent
Co-authored-by: Jakob Ackermann <das7pad@outlook.com>
Instead of just adding test generated files to .gitignore prevent
them from being produced in the first place.
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* add 'npm' and 'npm-update' make targets and lockfile
- `make npm` installs and updates node_modules, triggered automatically
on `make css` and `make js` as it completes reasonably fast and
ensures consistent modules.
- `make npm-update` updates all dependencies to their latest version,
regenerates `node_modules` from scratch and updates
`package-lock.json`. It uses npm modules `updates` written by yours
truly to find the latest version of each dependency.
* add suggested make dependencies
* remove package-lock.json during npm-update
* regenerate package-lock.json
* remove and disable package-lock
Using exact versions in package.json has the same effect as lockfiles
without all the troubles the lockfiles bring (different versions of
package manager generating different lockfiles primarily).
Ensured we only use exact versions in package.json and stopped
generation of new lockfiles via .npmrc which is support by both the npm
and yarn package managers.
Fixes: https://github.com/go-gitea/gitea/issues/6967
* enable save-exact
* Added test environment for m$sql
* Added template for test environment for m$sql
* Fix password
* Fix password (again)
* Fix password (again again)
* Fix db
* Ci trigger (Looking at you drone....)
* Ci trigger (Looking at you drone....)
* Ci trigger (Looking at you drone....)
* Ci trigger (Looking at you drone....)
* Create master database for mssql integration tests
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Create database only if master do not exist
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Fix mssql integration tests by using custom database "gitea"
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Moved defer
* bump xorm
* updated xorm
* Fixed build
* Modify tbraeutigam/gogs-snap for gitea
* Fix building on 16.04 (manually build go-bindata).
-> add _source.tar.bz2 to .gitignore (used by snapcraft cleanbuild)
* Streamline Snap packaging:
- Take advantage of install-hooks (snapd 2.27)
- Use snapctl configuration storage for unchanging values
* Move to using Snap Hooks for configuration
* Missed re-adding daemon statement
* Fix two warnings from Codacy.