]> source.dussan.org Git - gitea.git/log
gitea.git
2 years agotests: s/GITEA_UNIT_TESTS_VERBOSE/GITEA_UNIT_TESTS_LOG_SQL/ (#18142)
singuliere [Sat, 1 Jan 2022 03:31:24 +0000 (04:31 +0100)]
tests: s/GITEA_UNIT_TESTS_VERBOSE/GITEA_UNIT_TESTS_LOG_SQL/ (#18142)

The GITEA_UNIT_TESTS_VERBOSE variable is an undocumented variable
introduced in 2017 (see 1028ef2defd94a64f2433b07fe5d93681864cebb)
whose sole purpose has been to log SQL statements when running unit
tests.

It is renamed for clarity and a warning is displayed for backward
compatibility for people and scripts that know about it.

The documentation is updated to reflect this change.

2 years agoservices/repository: fix ListUnadoptedRepositories incorrect total count (#17865)
singuliere [Sat, 1 Jan 2022 02:52:00 +0000 (03:52 +0100)]
services/repository: fix ListUnadoptedRepositories incorrect total count (#17865)

The total count returned by ListUnadoptedRepositories is incorrectly
calculated.

The code snippet within ListUnadoptedRepositories used to verify
unadopted repositories is repeated three times in the function. It is
moved in the checkUnadoptedRepositories function and a unit test is
added to verify it works as expected.

A unit test is added to verify the total count returned by
ListUnadoptedRepositories is as expected.

Signed-off-by: singuliere <singuliere@autistici.org>
2 years agoImprove document for developers: Windows CGO, unit test option (#18140)
wxiaoguang [Fri, 31 Dec 2021 14:21:11 +0000 (22:21 +0800)]
Improve document for developers: Windows CGO, unit test option (#18140)

2 years agoReset the conflicted files list in testpatch (#18139)
zeripath [Fri, 31 Dec 2021 12:33:55 +0000 (12:33 +0000)]
Reset the conflicted files list in testpatch (#18139)

Although #18004 will seriously reduce the likelihood of finding
conflicts in the first place - one bug was introduced whereby the
conflicted files status was not being reset properly. This leads to
conflicted PRs remaining conflicted when the conflict has been resolved.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoUse correct translation key (#18135)
Gusted [Fri, 31 Dec 2021 08:43:03 +0000 (08:43 +0000)]
Use correct translation key (#18135)

- Resolves #18122

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 31 Dec 2021 00:28:31 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years ago[Frontport] Changelog v1.15.9 (#18136)
6543 [Thu, 30 Dec 2021 17:54:46 +0000 (18:54 +0100)]
[Frontport] Changelog v1.15.9 (#18136)

* Changelog ## [1.15.9](https://github.com/go-gitea/gitea/releases/tag/v1.15.9) - 2021-12-30

* docs: bump version

2 years agoFix wrong redirect on org labels (#18128)
KN4CK3R [Thu, 30 Dec 2021 06:44:42 +0000 (07:44 +0100)]
Fix wrong redirect on org labels (#18128)

2 years agoFix performance regression when user has many organization (#18125)
Lunny Xiao [Thu, 30 Dec 2021 05:03:40 +0000 (13:03 +0800)]
Fix performance regression when user has many organization (#18125)

2 years agodocs: add various ways to install from package (#18120)
Tony [Thu, 30 Dec 2021 04:28:56 +0000 (12:28 +0800)]
docs: add various ways to install from package (#18120)

zh-cn

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years agoRemoved unused method. (#18129)
KN4CK3R [Thu, 30 Dec 2021 03:56:12 +0000 (04:56 +0100)]
Removed unused method. (#18129)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 30 Dec 2021 00:28:34 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoRemoved unused endpoint. (#18127)
KN4CK3R [Wed, 29 Dec 2021 22:57:30 +0000 (23:57 +0100)]
Removed unused endpoint. (#18127)

2 years agoUse conditions but not repo ids as query condition (#16839)
Lunny Xiao [Wed, 29 Dec 2021 13:02:12 +0000 (21:02 +0800)]
Use conditions but not repo ids as query condition (#16839)

* Use conditions but not repo ids as query condition

* Improve the performance of pulls/issue

* Remove duplicated code

* fix lint

* Fix bug

* Fix stats

* More fixes

* Fix build

* Fix lint

* Fix test

* Fix build

* Adjust the logic

* Merge

* Fix conflicts

* improve the performance

* Add comments for the query conditions functions

* Some improvements

2 years agoSet HeadCommit when creating tags. (#18116)
KN4CK3R [Wed, 29 Dec 2021 11:40:57 +0000 (12:40 +0100)]
Set HeadCommit when creating tags. (#18116)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years agoFix: unstable sort skips/duplicates issues across pages (#18094)
DuckDuckWhale [Wed, 29 Dec 2021 03:12:19 +0000 (19:12 -0800)]
Fix: unstable sort skips/duplicates issues across pages (#18094)

When viewing issues in sorted order, some issues are duplicated across
pages and some are missing.  This is caused by the lack of tie-breakers
in database queries, making pagination inconsistent.

2 years agoHandle invalid issues (#18111)
Gusted [Tue, 28 Dec 2021 13:28:27 +0000 (13:28 +0000)]
Handle invalid issues (#18111)

* Handle invalid issues

- When you hover over a issue reference, and the issue doesn't exist, it
will just hang on the loading animation.
- This patch fixes that by showing them the pop-up with a "Error
occured" message.

* Add I18N

* refactor

* fix comment for lint

* fix unit test for i18n

* fix unit test for i18n

* add comments

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 27 Dec 2021 00:28:36 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoFix documents for Windows development (#18109)
wxiaoguang [Sun, 26 Dec 2021 15:27:18 +0000 (23:27 +0800)]
Fix documents for Windows development (#18109)

* Fix documents for Windows development

2 years agoEnable linter [rule.modifies-value-receiver] and refactor RoleDescriptor (#18093)
Gusted [Sun, 26 Dec 2021 14:56:14 +0000 (14:56 +0000)]
Enable linter [rule.modifies-value-receiver] and refactor RoleDescriptor (#18093)

2 years agodoc: clarify INSTALL_LOCK behavior (#17945)
Rolf Kaiser [Sun, 26 Dec 2021 03:25:42 +0000 (19:25 -0800)]
doc: clarify INSTALL_LOCK behavior (#17945)

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Sun, 26 Dec 2021 00:28:42 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoAdd issue hyperlinks in the webhook of wechatwork (#18102)
zjjhot [Sat, 25 Dec 2021 13:30:09 +0000 (21:30 +0800)]
Add issue hyperlinks in the webhook of wechatwork (#18102)

Co-authored-by: zjj <2031381130@qq.com>
2 years agoFix a navbar UI bug in Safari (#18092)
wxiaoguang [Fri, 24 Dec 2021 21:42:01 +0000 (05:42 +0800)]
Fix a navbar UI bug in Safari (#18092)

2 years agoInstead of using routerCtx just escape the url before routing (#18086)
zeripath [Fri, 24 Dec 2021 16:50:49 +0000 (16:50 +0000)]
Instead of using routerCtx just escape the url before routing (#18086)

A consequence of forcibly setting the RoutePath to the escaped url is that the
auto routing to endpoints without terminal slashes fails (Causing #18060.) This
failure raises the possibility that forcibly setting the RoutePath causes other
unexpected behaviors too.

Therefore, instead we should simply pre-escape the URL in the process registering
handler. Then the request URL will be properly escaped for all the following calls.

Fix #17938
Fix #18060
Replace #18062
Replace #17997

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoWhen the git repository on storage is changed, the repository modal should also be...
wxiaoguang [Fri, 24 Dec 2021 15:36:26 +0000 (23:36 +0800)]
When the git repository on storage is changed, the repository modal should also be updated (#18088)

User would keep seeing an empty repo if:
* An error occurs during the first git pushing/receiving
* A user replaces the Gitea's empty repository manually
Fix: when a user is viewing the repository web page, if the repoModal.IsEmpty is true, we check the git repository again to detect whether it is really empty.

However: the IsEmpty flag is deeply broken and should be removed. For example it's possible for a repository to be non-empty by that flag but still 500 because there are no branches - only tags -or the default branch is non-extant as it has been 0-pushed.

2 years ago- name: new parameter in CreateForkOption to give the forked repository (#18066)
Aravinth Manivannan [Fri, 24 Dec 2021 14:43:00 +0000 (14:43 +0000)]
- name: new parameter in CreateForkOption to give the forked repository (#18066)

a custom name, intended to be used when there's a name conflict
- When a fork request results in a name conflict, HTTP 409: Conflict is
  returned instead of 500
- API documentation for the above mentioned changes

Signed-off-by: realaravinth <realaravinth@batsense.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2 years agoWhen attempting to subscribe other user to issue report why access denied (#18091)
zeripath [Fri, 24 Dec 2021 13:47:42 +0000 (13:47 +0000)]
When attempting to subscribe other user to issue report why access denied (#18091)

Fix #18090

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years agoImprove interface when comparing a branch which has created a pull request (#17911)
Lunny Xiao [Fri, 24 Dec 2021 12:14:42 +0000 (20:14 +0800)]
Improve interface when comparing a branch which has created a pull request (#17911)

* Improve interface when comparing a branch which has created a pull request

* Take the note back

2 years agoAdd API to manage repo tranfers (#17963)
qwerty287 [Fri, 24 Dec 2021 04:26:52 +0000 (05:26 +0100)]
Add API to manage repo tranfers (#17963)

2 years agoFix various typos of software names (#18083)
qwerty287 [Fri, 24 Dec 2021 03:56:57 +0000 (04:56 +0100)]
Fix various typos of software names (#18083)

* `git` -> `Git`
* `Github` and `github` -> `GitHub`
* `crowdin` -> `Crowdin`
* `git-lfs` -> `Git LFS`
* `githooks`, `git hooks`, `git-hooks` -> `Git Hooks`
* `discord` -> `Discord`
* `2fa` -> `2FA`
* `gitlab` and `Gitlab` -> `GitLab`
* `web hook` -> `webhook`
* `linux` -> `Linux`
* `sqlite` -> `SQLite`
* `MYSQL` and `mysql` -> `MySQL`
* rename refs to `master` branch -> `main`
* Fix English grammar

2 years agoPrevent NPE if gitea uploader fails to open url (#18080)
zeripath [Thu, 23 Dec 2021 16:27:33 +0000 (16:27 +0000)]
Prevent NPE if gitea uploader fails to open url (#18080)

If http.Get() returns an error return nil and err before attempting to
use the broken file.

Thanks to walker xiong for spotting this bug.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoDo not read or write git reference files directly (#18079)
zeripath [Thu, 23 Dec 2021 13:44:00 +0000 (13:44 +0000)]
Do not read or write git reference files directly (#18079)

Git will and can pack references into packfiles and therefore if you write/read the
files directly you will get false results. Instead you should use update-ref and
show-ref. To that end I have created three new functions in git/repo_commit.go that
will do this correctly.

Related #17191

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoMigrated Repository will show modifications when possible (#17191)
99rgosse [Thu, 23 Dec 2021 08:32:29 +0000 (09:32 +0100)]
Migrated Repository will show modifications when possible (#17191)

* Read patches to get history

2 years agoQuote references to the user table in consistency checks (#18072)
zeripath [Wed, 22 Dec 2021 23:52:57 +0000 (23:52 +0000)]
Quote references to the user table in consistency checks (#18072)

Although #17487 ensured that the table was quoted in the join it missed that the
query part of the check also needed to be quoted.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoOnly create pprof files for gitea serv if explicitly asked for (#18068)
zeripath [Wed, 22 Dec 2021 16:48:12 +0000 (16:48 +0000)]
Only create pprof files for gitea serv if explicitly asked for (#18068)

2 years agoAdd NotFound handler (#18062)
zeripath [Wed, 22 Dec 2021 10:39:28 +0000 (10:39 +0000)]
Add NotFound handler (#18062)

PR #17997 means that urls with terminal '/' are no longer immediately mapped
to the url without a terminal slash. However, it has revealed that the NotFound handler
appears to have been lost.

This PR adds back in a NotFound handler that simply redirects to a path without the
terminal slash or runs the NotFound handler.

Fix #18060

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoAdd API to get file commit history (#17652)
qwerty287 [Wed, 22 Dec 2021 06:17:33 +0000 (07:17 +0100)]
Add API to get file commit history (#17652)

Adds an API endpoint `api/v1/repos/{owner}/{repo}/git/history/{filepath}` to get the commits affecting the given file or directory.

Closes https://github.com/go-gitea/gitea/issues/16206 and closes https://github.com/go-gitea/gitea/issues/16703

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 22 Dec 2021 00:28:37 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoAdd List-Unsubscribe header (#17804)
mscherer [Tue, 21 Dec 2021 22:53:03 +0000 (23:53 +0100)]
Add List-Unsubscribe header (#17804)

Fixes #13283

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoAvoid running go vet twice (#18059)
Gusted [Tue, 21 Dec 2021 18:22:33 +0000 (19:22 +0100)]
Avoid running go vet twice (#18059)

2 years ago[Frontport] Changelog v1.15.8 (#18052)
6543 [Tue, 21 Dec 2021 08:08:48 +0000 (09:08 +0100)]
[Frontport] Changelog v1.15.8 (#18052)

* Changelog v1.15.8

* bump version

2 years agoFix continuance tests (#18027)
Gusted [Tue, 21 Dec 2021 03:12:27 +0000 (04:12 +0100)]
Fix continuance tests (#18027)

2 years agoupdate docker image to latest go version (#18048)
techknowlogick [Tue, 21 Dec 2021 03:11:10 +0000 (22:11 -0500)]
update docker image to latest go version (#18048)

2 years agoTestRepository_GetTag intermittently panics due to an NPE (#18043)
zeripath [Tue, 21 Dec 2021 03:10:16 +0000 (03:10 +0000)]
TestRepository_GetTag intermittently panics due to an NPE (#18043)

There are repeated panics in tests due to TestRepository_GetTag failing
to run properly.  This happens when we attempt to reset the internal
repo for a tag which has failed to load. The problem is - the panic that
this is causing is preventing us from finding what the real error is.

This PR simply moves the failure out so we have a chance to see what
really is failing.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years agoEnsure that git repository is closed before transfer (#18049)
zeripath [Tue, 21 Dec 2021 02:01:58 +0000 (02:01 +0000)]
Ensure that git repository is closed before transfer (#18049)

Repository Transfer requires that the repository directory is renamed - which
is not possible on Windows if the git repository is open.

Fix #17885

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Tue, 21 Dec 2021 00:28:39 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoMake test work with different default branch config (#18038)
mscherer [Mon, 20 Dec 2021 20:55:05 +0000 (21:55 +0100)]
Make test work with different default branch config (#18038)

* Make test work with different default branch config

On a system configured with a different default branch name, doGitInitTestRepository
will create a repository with a branch named differently, and so further tests
would break:

  --- FAIL: TestGit/HTTP/PushCreate/SuccessfullyPushAndCreateTestRepository (0.02s)
      git_helper_for_declarative_test.go:167:
           Error Trace: git_helper_for_declarative_test.go:167
           Error:       Received unexpected error:
                        exit status 1 - error: src refspec master does not match any
                        error: failed to push some refs to 'http://127.0.0.1:3003/user2/repo-tmp-push-create-http.git'
           Test:        TestGit/HTTP/PushCreate/SuccessfullyPushAndCreateTestRepository
  git_test.go:587:
       Error Trace: git_test.go:587
       Error:       Received unexpected error:
                    repository does not exist [id: 0, uid: 0, owner_name: user2, name: repo-tmp-push-create-http]
       Test:        TestGit/HTTP/PushCreate

* Update integrations/git_helper_for_declarative_test.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2 years agoExtract CodeMirror styles (#17960)
silverwind [Mon, 20 Dec 2021 20:07:49 +0000 (12:07 -0800)]
Extract CodeMirror styles (#17960)

- Extract CodeMirror-related styles to separate files
- Generalize CodeMirror styles where possible
- Improve fullscreen and side-by-side mode for dark theme

Co-authored-by: 6543 <6543@obermui.de>
2 years agoMigration 204 use Sync2 (#18044)
6543 [Mon, 20 Dec 2021 17:58:38 +0000 (18:58 +0100)]
Migration 204 use Sync2 (#18044)

* format nit

* Sync2

2 years agoMove POST /{username}/action/{action} to simply POST /{username} (#18045)
zeripath [Mon, 20 Dec 2021 17:18:26 +0000 (17:18 +0000)]
Move POST /{username}/action/{action} to simply POST /{username} (#18045)

The current code unfortunately requires that `action` be a reserved
repository name as it prevents posts to change the settings for
action repositories. However, we can simply change action handler
to work on POST /{username} instead.

Fix #18037

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoFix delete u2f keys modal (#18040)
Lunny Xiao [Mon, 20 Dec 2021 14:49:06 +0000 (22:49 +0800)]
Fix delete u2f keys modal (#18040)

2 years agoReset Session ID on login (#18018)
zeripath [Mon, 20 Dec 2021 14:12:26 +0000 (14:12 +0000)]
Reset Session ID on login (#18018)

* Reset Session ID on login

When logging in the SessionID should be reset and the session cleaned up.

Signed-off-by: Andrew Thornton <art27@cantab.net>
* with new session.RegenerateID function

Signed-off-by: Andrew Thornton <art27@cantab.net>
* update go-chi/session

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Ensure that session id is changed after oauth data is set and between account linking pages too

Signed-off-by: Andrew Thornton <art27@cantab.net>
* placate lint

Signed-off-by: Andrew Thornton <art27@cantab.net>
* as per review

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoAdd grafana gitea-mixin (#17758)
Vitaly Zhuravlev [Mon, 20 Dec 2021 07:52:33 +0000 (10:52 +0300)]
Add grafana gitea-mixin (#17758)

This PR adds gitea-mixin, configurable Grafana dashboards (and potentially prometheus alerts+recording rules) based on Gitea [metrics](https://docs.gitea.io/en-us/config-cheat-sheet/#metrics-metrics).

The overview dashboard is described using jsonnet and grafonnet library: https://grafana.github.io/grafonnet-lib/

Mixins help to define dashboard and alerts as code so they can be collaboratively improved by the users.

![image](https://user-images.githubusercontent.com/14870891/142862822-fe57b384-c74a-4103-8548-033e92f90751.png)

__
## Generate config files

You can manually generate dashboards, but first you should install some tools:

```bash
go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
go get github.com/google/go-jsonnet/cmd/jsonnet
# or in brew: brew install go-jsonnet
```

For linting and formatting, you would also need `mixtool` and `jsonnetfmt` installed. If you
have a working Go development environment, it's easiest to run the following:

```bash
go get github.com/monitoring-mixins/mixtool/cmd/mixtool
go get github.com/google/go-jsonnet/cmd/jsonnetfmt
```

The files in `dashboards_out` need to be imported
into your Grafana server.  The exact details will be depending on your environment.

Edit `config.libsonnet` (for example, list of Gitea metrics to be shown under stats can be adjusted). if required and then build JSON dashboard files for Grafana:

```bash
make
```

For more about mixins, please see:
https://github.com/monitoring-mixins/docs
https://www.youtube.com/watch?v=GDdnL5R_l-Y* add gitea mixin

* remove alerts/rules

* gitea-mixin: add interval factor of 1/2 to remove duplicated change events

* gitea-mixin: fix changes panel, add aggregation interval for changes panel

* gitea-mixin: add totals singlestat

* gitea mixin: switch change graph to timeseries type

* add color overrides for issue labels

* bump grafonnet version

* gitea-mixin: convert graphs to timeseries

* gitea-mixin:  make fmt

* gitea-mixin: add .PHONE in Makefile

* gitea-mixin: add time configration

* gitea-mixin: make fmt and collapse addPanel grid

* gitea-mixin: add static ids for shared panels

* gitea-mixin: add flags showIssuesByRepository, showIssuesByLabel to show/hide corresponding panels

* gitea-mixin: update aggregation interval

* gitea-mixin: update defaults

* gitea-mixin: update panel names

* rename dir to gitea-monitoring-mixin

* gitea-mixin: add gitea_issues_open, gitea_issues_closed metrics

* gitea-mixin: update visible name for datasource

* gitea-mixin: update README

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2 years agoSimplify parameter types (#18006)
Gusted [Mon, 20 Dec 2021 04:41:31 +0000 (05:41 +0100)]
Simplify parameter types (#18006)

Remove repeated type declarations in function definitions.

2 years agoUpdate chroma (#18033)
zeripath [Mon, 20 Dec 2021 02:49:38 +0000 (02:49 +0000)]
Update chroma (#18033)

Update chroma to 0.9.4

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoPrevent off-by-one error on comments on newly appended lines (#18029)
zeripath [Mon, 20 Dec 2021 02:15:49 +0000 (02:15 +0000)]
Prevent off-by-one error on comments on newly appended lines (#18029)

* Prevent off-by-one error on comments on newly appended lines

There was a bug in CutDiffAroundLine whereby if a file without a terminal new line
has a patch which appends lines to it and a comment is placed on one of those lines
the comment diff will be a line out of place.

This fixes CutDiffAroundLine to simply ignore the missing terminal newline - however,
we should really improve this rendering to add a marker to say that there was a
previously missing terminal newline.

Fix #17875

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoAbort merge if head has been updated before pressing merge (#18032)
zeripath [Mon, 20 Dec 2021 00:32:54 +0000 (00:32 +0000)]
Abort merge if head has been updated before pressing merge (#18032)

* Abort merge if head has been updated before pressing merge

It is possible that a PR head may be pushed to between the merge page being shown
and the merge button being pressed. Pass the current expected head in as a parameter
and cancel the merge if it has changed.

Fix #18028

Signed-off-by: Andrew Thornton <art27@cantab.net>
* adjust swagger

Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix test

Signed-off-by: Andrew Thornton <art27@cantab.net>
* placate lint

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agono need for docker image mirror (#18031)
techknowlogick [Sun, 19 Dec 2021 21:53:15 +0000 (16:53 -0500)]
no need for docker image mirror (#18031)

Co-authored-by: zeripath <art27@cantab.net>
2 years agoStop printing 03d after escaped characters in logs (#18030)
zeripath [Sun, 19 Dec 2021 21:00:22 +0000 (21:00 +0000)]
Stop printing 03d after escaped characters in logs (#18030)

Strangely a weird bug was present in the log escaping code whereby any escaped
character would gain 03d - this was due to a mistake in the format string where
it should have read %03o but read instead %o03d. This has led to spurious 03d
trailing characters on these escaped characters!

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoReset locale on login (#18023)
zeripath [Sun, 19 Dec 2021 13:31:43 +0000 (13:31 +0000)]
Reset locale on login (#18023)

* Reset locale on login

Fix #18020

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update routers/web/user/auth.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
2 years agoAdd support for ssh commit signing (#17743)
Wim [Sun, 19 Dec 2021 05:37:18 +0000 (06:37 +0100)]
Add support for ssh commit signing (#17743)

* Add support for ssh commit signing

* Split out ssh verification to separate file

* Show ssh key fingerprint on commit page

* Update sshsig lib

* Make sure we verify against correct namespace

* Add ssh public key verification via ssh signatures

When adding a public ssh key also validate that this user actually
owns the key by signing a token with the private key.

* Remove some gpg references and make verify key optional

* Fix spaces indentation

* Update options/locale/locale_en-US.ini

Co-authored-by: Gusted <williamzijl7@hotmail.com>
* Update templates/user/settings/keys_ssh.tmpl

Co-authored-by: Gusted <williamzijl7@hotmail.com>
* Update options/locale/locale_en-US.ini

Co-authored-by: Gusted <williamzijl7@hotmail.com>
* Update options/locale/locale_en-US.ini

Co-authored-by: Gusted <williamzijl7@hotmail.com>
* Update models/ssh_key_commit_verification.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>
* Reword ssh/gpg_key_success message

* Change Badsignature to NoKeyFound

* Add sign/verify tests

* Fix upstream api changes to user_model User

* Match exact on SSH signature

* Fix code review remarks

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years agoImprove TestPatch to use git read-tree -m and implement git-merge-one-file functional...
zeripath [Sun, 19 Dec 2021 04:19:25 +0000 (04:19 +0000)]
Improve TestPatch to use git read-tree -m and implement git-merge-one-file functionality (#18004)

The current TestPatch conflict code uses a plain git apply which does not properly
account for 3-way merging. However, we can improve things using `git read-tree -m` to
do a three-way merge then follow the algorithm used in merge-one-file. We can also use
`--patience` and/or `--histogram` to generate a nicer diff for applying patches too.

Fix #13679
Fix #6417

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years ago[skip ci] Updated licenses and gitignores
GiteaBot [Sun, 19 Dec 2021 00:29:01 +0000 (00:29 +0000)]
[skip ci] Updated licenses and gitignores

2 years agoChange <a> elements to underline on hover (#17898)
silverwind [Sat, 18 Dec 2021 05:29:00 +0000 (21:29 -0800)]
Change <a> elements to underline on hover (#17898)

Fomantic brings a opinionated style that removed underline on mouse
hover which I think is important UX to have.

This re-enables the underline in the Fomantic config and fixes a few
cases where underline was deemed disruptive.

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Sat, 18 Dec 2021 00:28:35 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoSupport open compare page directly (#17975)
Lunny Xiao [Fri, 17 Dec 2021 22:20:27 +0000 (06:20 +0800)]
Support open compare page directly (#17975)

* Support open compare page directly

* simple code

* Some improvements

Co-authored-by: 6543 <6543@obermui.de>
2 years agoAdd option to define refs in issue templates (#17842)
qwerty287 [Fri, 17 Dec 2021 21:29:09 +0000 (22:29 +0100)]
Add option to define refs in issue templates (#17842)

Adds a markdown header option `ref` that allows you to set the ref the issue should belong.

2 years agoFix outType on gitea dump (#18000)
Gusted [Fri, 17 Dec 2021 13:38:45 +0000 (14:38 +0100)]
Fix outType on gitea dump (#18000)

- Force to output the dump file to use the given `--type`.
- Resolves #17959

2 years agoFix rename notification bug (#18008)
Lunny Xiao [Fri, 17 Dec 2021 06:24:47 +0000 (14:24 +0800)]
Fix rename notification bug (#18008)

2 years agoEnsure complexity, minlength and ispwned are checked on password setting (#18005)
zeripath [Fri, 17 Dec 2021 02:03:39 +0000 (02:03 +0000)]
Ensure complexity, minlength and ispwned are checked on password setting (#18005)

It appears that there are several places that password length, complexity and ispwned
are not currently been checked when changing passwords. This PR adds these.

Fix #17977

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years agoUse JSON module instead of stdlib json (#18003)
Gusted [Fri, 17 Dec 2021 01:15:02 +0000 (02:15 +0100)]
Use JSON module instead of stdlib json (#18003)

2 years agoPrevent hang in git cat-file if repository is not a valid repository and other fixes...
zeripath [Thu, 16 Dec 2021 19:01:14 +0000 (19:01 +0000)]
Prevent hang in git cat-file if repository is not a valid repository and other fixes (#17991)

This PR contains multiple fixes. The most important of which is:

* Prevent hang in git cat-file if the repository is not a valid repository

    Unfortunately it appears that if git cat-file is run in an invalid
    repository it will hang until stdin is closed. This will result in
    deadlocked /pulls pages and dangling git cat-file calls if a broken
    repository is tried to be reviewed or pulls exists for a broken
    repository.

    Fix #14734
    Fix #9271
    Fix #16113

Otherwise there are a few small other fixes included which this PR was initially intending to fix:

* Fix panic on partial compares due to missing PullRequestWorkInProgressPrefixes
* Fix links on pulls pages  due to regression from #17551 - by making most /issues routes match /pulls too - Fix #17983
* Fix links on feeds pages due to another regression from #17551 but also fix issue with syncing tags - Fix #17943
* Add missing locale entries for oauth group claims
* Prevent NPEs if ColorFormat is called on nil users, repos or teams.

2 years agoPrevent double decoding of % in url params (#17997)
zeripath [Thu, 16 Dec 2021 17:40:18 +0000 (17:40 +0000)]
Prevent double decoding of % in url params  (#17997)

There was an unfortunate regression in #14293 which has led to the double decoding
of url parameter elements if they contain a '%'. This is due to an issue
with the way chi decodes its RoutePath. In detail the problem lies in
mux.go where the routeHTTP path uses the URL.RawPath or even the
URL.Path instead of the escaped path to do routing.

This PR simply forcibly sets the routePath to that of the EscapedPath.

Fix #17938

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoAdd Reindex buttons to repository settings page (#17494)
zeripath [Thu, 16 Dec 2021 15:55:12 +0000 (15:55 +0000)]
Add Reindex buttons to repository settings page (#17494)

This PR adds reindexing request buttons to the repository settings page.

Fix #3796

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoSet correct language for Dockerfile variants (#17999)
silverwind [Thu, 16 Dec 2021 09:52:01 +0000 (01:52 -0800)]
Set correct language for Dockerfile variants (#17999)

2 years agoFix TemplateRepo no longer in models.repo (#17993)
Caellion [Thu, 16 Dec 2021 07:12:50 +0000 (08:12 +0100)]
Fix TemplateRepo no longer in models.repo (#17993)

* Fixes error 500 that appears when trying to browse code of a repository generated from template

* forgot to update comment

* Update models/repo/repo.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Update repo.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoMake AvatarRenderedSizeFactor configurable and set it to 3 (#17951)
silverwind [Thu, 16 Dec 2021 02:18:38 +0000 (18:18 -0800)]
Make AvatarRenderedSizeFactor configurable and set it to 3 (#17951)

Save a bit of bandwidth by only requesting 3-times the rendered avatar
size. Factor 4 is only really beneficial on a handful of mobile phones
and I don't think they are the primary device we design for.

Configurability contributed by zeripath.

Fixes: https://github.com/go-gitea/gitea/pull/17422
Fixes: https://github.com/go-gitea/gitea/issues/16287
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 16 Dec 2021 00:28:34 +0000 (00:28 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoFixed emoji alias not parsed in links (#16221)
KN4CK3R [Wed, 15 Dec 2021 23:49:12 +0000 (00:49 +0100)]
Fixed emoji alias not parsed in links (#16221)

* Do not skip links.

* Restrict text in links to emojis.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2 years agoShorten page title in file view (#17987)
silverwind [Wed, 15 Dec 2021 07:50:11 +0000 (23:50 -0800)]
Shorten page title in file view (#17987)

Move the more relevant sections of the page title earlier which make it
possible to distinguish multiple tabs from each other when tab width is
limited.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years agoRefactor HTTP request context (#17979)
wxiaoguang [Wed, 15 Dec 2021 06:59:57 +0000 (14:59 +0800)]
Refactor HTTP request context (#17979)

2 years agoAdd missing `X-Total-Count` and fix some related bugs (#17968)
qwerty287 [Wed, 15 Dec 2021 05:39:34 +0000 (06:39 +0100)]
Add missing `X-Total-Count` and fix some related bugs (#17968)

* Add missing `X-Total-Count` and fix some related bugs

Adds `X-Total-Count` header to APIs that return a list but doesn't have it yet.
Fixed bugs:
* not returned after reporting error (https://github.com/qwerty287/gitea/blob/39eb82446c6fe5da3d79124e1f701f3795625b69/routers/api/v1/user/star.go#L70)
* crash with index out of bounds, API issue/issueSubscriptions

I also found various endpoints that return lists but do not apply/support pagination yet:
```
/repos/{owner}/{repo}/issues/{index}/labels
/repos/{owner}/{repo}/issues/comments/{id}/reactions
/repos/{owner}/{repo}/branch_protections
/repos/{owner}/{repo}/contents
/repos/{owner}/{repo}/hooks/git
/repos/{owner}/{repo}/issue_templates
/repos/{owner}/{repo}/releases/{id}/assets
/repos/{owner}/{repo}/reviewers
/repos/{owner}/{repo}/teams
/user/emails
/users/{username}/heatmap
```
If this is not expected, an new issue should be opened.

Closes #13043

* fmt

* Update routers/api/v1/repo/issue_subscription.go

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Use FindAndCount

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 15 Dec 2021 00:25:11 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoUse non-expiring key. (#17984)
KN4CK3R [Tue, 14 Dec 2021 20:02:20 +0000 (21:02 +0100)]
Use non-expiring key. (#17984)

2 years agoAdd Option to synchronize Admin & Restricted states from OIDC/OAuth2 along with Setti...
zeripath [Tue, 14 Dec 2021 08:37:11 +0000 (08:37 +0000)]
Add Option to synchronize Admin & Restricted states from OIDC/OAuth2 along with Setting Scopes (#16766)

* Add setting to OAuth handlers to override local 2FA settings

This PR adds a setting to OAuth and OpenID login sources to allow the source to
override local 2FA requirements.

Fix #13939

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix regression from #16544

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add scopes settings

Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix trace logging in auth_openid

Signed-off-by: Andrew Thornton <art27@cantab.net>
* add required claim options

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Move UpdateExternalUser to externalaccount

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Allow OAuth2/OIDC to set Admin/Restricted status

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Allow use of the same group claim name for the prohibit login value

Signed-off-by: Andrew Thornton <art27@cantab.net>
* fixup! Move UpdateExternalUser to externalaccount

* as per wxiaoguang

Signed-off-by: Andrew Thornton <art27@cantab.net>
* add label back in

Signed-off-by: Andrew Thornton <art27@cantab.net>
* adjust localisation

Signed-off-by: Andrew Thornton <art27@cantab.net>
* placate lint

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years agoReturn nicer error for ForcePrivate (#17971)
zeripath [Tue, 14 Dec 2021 05:08:09 +0000 (05:08 +0000)]
Return nicer error for ForcePrivate (#17971)

2 years agoFixed wording. (#17973)
KN4CK3R [Tue, 14 Dec 2021 01:45:39 +0000 (02:45 +0100)]
Fixed wording. (#17973)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Tue, 14 Dec 2021 00:25:09 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoPrevent deadlock in create issue (#17970)
zeripath [Mon, 13 Dec 2021 22:59:39 +0000 (22:59 +0000)]
Prevent deadlock in create issue (#17970)

2 years agoBump swagger-ui-dist from 4.1.2 to 4.1.3 (#17965)
dependabot[bot] [Mon, 13 Dec 2021 03:57:35 +0000 (22:57 -0500)]
Bump swagger-ui-dist from 4.1.2 to 4.1.3 (#17965)

2 years agoImprove behavior of "Fork" button (#17288)
qwerty287 [Mon, 13 Dec 2021 01:59:09 +0000 (02:59 +0100)]
Improve behavior of "Fork" button (#17288)

* Improbe behaviour of fork button

* Apply suggestions from code review

* Remove old lines

* Apply suggestions

* Fix test

* Remove unnecessary or

* Update templates/repo/header.tmpl

Co-authored-by: silverwind <me@silverwind.io>
* Add comment

* Fix situation if you can't fork but don't have forks

* Fix lint

* Apply changes from #17783

* fmt

* fmt

* Apply tweaks

Co-authored by: silverwind <me@silverwind.io>

* Rm dupl css

* Fix build

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoPrefer "Hiragino Kaku Gothic ProN" in system-ui-ja (#17954)
rinsuki [Sun, 12 Dec 2021 23:04:18 +0000 (08:04 +0900)]
Prefer "Hiragino Kaku Gothic ProN" in system-ui-ja (#17954)

2 years agoSome repository refactors (#17950)
Lunny Xiao [Sun, 12 Dec 2021 15:48:20 +0000 (23:48 +0800)]
Some repository refactors (#17950)

* some repository refactors

* remove unnecessary code

* Fix test

* Remove unnecessary banner

2 years ago[skip ci] Updated licenses and gitignores
GiteaBot [Sun, 12 Dec 2021 00:25:18 +0000 (00:25 +0000)]
[skip ci] Updated licenses and gitignores

2 years agoFix markdown URL parsing (#17924)
wxiaoguang [Sat, 11 Dec 2021 17:21:36 +0000 (01:21 +0800)]
Fix markdown URL parsing (#17924)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2 years agoFix overflow in commit graph (#17947)
silverwind [Sat, 11 Dec 2021 14:12:18 +0000 (06:12 -0800)]
Fix overflow in commit graph (#17947)

* Fix overflow in commit graph

Limit commit message to 50% width. This is rather crude but should work
for common use cases with not too-long author names.

Fixes: https://github.com/go-gitea/gitea/issues/17944
* Make it work with dynamic width

* use span

* use explicit none

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoPrevent services/mailer/mailer_test.go tests from deleteing data directory (#17941)
zeripath [Fri, 10 Dec 2021 19:43:28 +0000 (19:43 +0000)]
Prevent services/mailer/mailer_test.go tests from deleteing data directory (#17941)

Running `make test-backend` will delete `data/` due to reloading the configuration and resetting the appdatapath.

This PR removes this unnecessary config reload but also adds extra code in to the unittest main to prevent its cleanup from deleting the wrong directory.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoMove keys to models/asymkey (#17917)
Lunny Xiao [Fri, 10 Dec 2021 08:14:24 +0000 (16:14 +0800)]
Move keys to models/asymkey (#17917)

* Move keys to models/keys

* Rename models/keys -> models/asymkey

* change the missed package name

* Fix package alias

* Fix test

* Fix docs

* Fix test

* Fix test

* merge

2 years agoClean legacy SimpleMDE code (#17926)
wxiaoguang [Fri, 10 Dec 2021 02:51:27 +0000 (10:51 +0800)]
Clean legacy SimpleMDE code (#17926)

Since we are using EasyMDE now, we do not need to keep the SimpleMDE code anymore.

This PR removes all legacy SimpleMDE code, and makes some related changes:
* `createCommentEasyMDE` can accept native DOM element, and it doesn't need `jQuery.data` to store EasyMDE editor object (as discussed about the frontend guideline).
* introduce `getAttachedEasyMDE` to get the attached EasyMDE editor object, it's easier to find all the usage of EasyMDE.
* rename variable names from `$simplemde` to `easyMDE`, the `$` was incorrect because it is a EasyMDE editor, not a jQuery object.

With this PR, it will be easier to do more refactoring or replacing EasyMDE with other editors.