Commit Graph

2181 Commits

Author SHA1 Message Date
Lunny Xiao d151503d34 Upgrade xorm to v0.8.0 (#8536) 2019-10-17 11:26:49 +02:00
Antoine GIRARD c748deef33 don't ignore error message (#8550) 2019-10-17 08:15:02 +08:00
zeripath fcb535c5c3
Sign merges, CRUD, Wiki and Repository initialisation with gpg key (#7631)
This PR fixes #7598 by providing a configurable way of signing commits across the Gitea instance. Per repository configurability and import/generation of trusted secure keys is not provided by this PR - from a security PoV that's probably impossible to do properly. Similarly web-signing, that is asking the user to sign something, is not implemented - this could be done at a later stage however.

## Features
- [x] If commit.gpgsign is set in .gitconfig sign commits and files created through repofiles. (merges should already have been signed.)
- [x] Verify commits signed with the default gpg as valid
- [x] Signer, Committer and Author can all be different
    - [x] Allow signer to be arbitrarily different - We still require the key to have an activated email on Gitea. A more complete implementation would be to use a keyserver and mark external-or-unactivated with an "unknown" trust level icon.
- [x] Add a signing-key.gpg endpoint to get the default gpg pub key if available
    - Rather than add a fake web-flow user I've added this as an endpoint on /api/v1/signing-key.gpg
    - [x] Try to match the default key with a user on gitea - this is done at verification time
- [x] Make things configurable?
    - app.ini configuration done
    - [x] when checking commits are signed need to check if they're actually verifiable too
- [x] Add documentation

I have decided that adjusting the docker to create a default gpg key is not the correct thing to do and therefore have not implemented this.
2019-10-16 14:42:42 +01:00
zeripath e1505d6250
Add missed close in ServeBlobLFS (#8527) 2019-10-16 06:55:31 +01:00
guillep2k 31655aabfc Fix password complexity regex for special characters (on master) (#8525)
* Fix extra space

* Fix regular expression

* Fix error template name

* Simplify check code, fix default values, add test

* Fix router tests

* Fix fmt

* Fix setting and lint

* Move cleaning up code to test, improve comments

* Tidy up variable declaration
2019-10-16 11:09:58 +08:00
Colin Arnott 66e99d722a upgrade gopkg.in/editorconfig/editorconfig-core-go.v1 (#8501)
editorconfig-core-go made breaking api changes and has recently released
v2.1.1. This change consumes the new api and fixes up any breaking
references.
2019-10-15 22:24:16 +01:00
zeripath 167e8f18da
Restore Graceful Restarting & Socket Activation (#7274)
* Prevent deadlock in indexer initialisation during graceful restart

* Move from gracehttp to our own service to add graceful ssh

* Add timeout for start of indexers and make hammer time configurable

* Fix issue with re-initialization in indexer during tests

* move the code to detect use of closed to graceful

* Handle logs gracefully - add a pid suffix just before restart

* Move to using a cond and a holder for indexers

* use time.Since

* Add some comments and attribution

* update modules.txt

* Use zero to disable timeout

* Move RestartProcess to its own file

* Add cleanup routine
2019-10-15 14:39:51 +01:00
blueworrybear 8c909820a9 Enable Uploading/Removing Attachments When Editing an Issue/Comment (#8426) 2019-10-15 13:19:32 +01:00
Lunny Xiao 20477a69ea
Move clearlabels from models to issue service (#8326)
* move clearlabels from models to issue service

* improve code

* Apply suggestions from code review

Co-Authored-By: zeripath <art27@cantab.net>
2019-10-15 13:03:05 +08:00
Lunny Xiao 34fb9d68a5 Move AddTestPullRequestTask to pull service package from models (#8324)
* move AddTestPullRequestTask to pull service package from models

* fix fmt
2019-10-15 04:28:40 +01:00
6543 733c898a90 [Branch View] Add Included TAG (#8449)
* included message

* add property IsIncluded

* Add Orange Lable
2019-10-14 23:40:17 +01:00
Lunny Xiao 0be992a1e2 Make static resouces web browser cache time customized on app.ini (#8442)
* make static resouces web browser cache time customized on app.ini

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-Authored-By: zeripath <art27@cantab.net>

* Update custom/conf/app.ini.sample

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>

* fix docs
2019-10-14 23:05:57 +01:00
jaqra 086bfb8b4b Add pagination to commit graph page (#8360)
Fixes #8308
2019-10-14 22:38:35 +01:00
David Svantesson 366806db32 Fix errors in create org UI regarding team access permission. (#8506) 2019-10-14 19:20:42 +01:00
Maxim Tkachenko db657192d0 Password Complexity Checks (#6230)
Add password complexity checks. The default settings require a lowercase, uppercase, number and a special character within passwords.

Co-Authored-By: T-M-A <maxim.tkachenko@gmail.com>
Co-Authored-By: Lanre Adelowo <adelowomailbox@gmail.com>
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-Authored-By: Lauris BH <lauris@nix.lv>
2019-10-14 16:24:26 +01:00
Lunny Xiao e3e44a59d0 Update migrated repositories' issues/comments/prs poster id if user has a github external user saved (#7751)
* update migrated issues/comments when login as github

* add get userid when migrating or login with github oauth2

* fix lint

* add migrations for repository service type

* fix build

* remove unnecessary dependencies on migrations

* add cron task to update migrations poster ids and fix posterid when migrating

* fix lint

* fix lint

* improve code

* fix lint

* improve code

* replace releases publish id to actual author id

* fix import

* fix bug

* fix lint

* fix rawdata definition

* fix some bugs

* fix error message
2019-10-14 09:10:42 +03:00
Lunny Xiao f2a3abc683
Move migrating repository from frontend to backend (#6200)
* move migrating to backend

* add loading image when migrating and fix tests

* fix format

* fix lint

* add redis task queue support and improve docs

* add redis vendor

* fix vet

* add database migrations and fix app.ini sample

* add comments for task section on app.ini.sample

* Update models/migrations/v84.go

Co-Authored-By: lunny <xiaolunwen@gmail.com>

* Update models/repo.go

Co-Authored-By: lunny <xiaolunwen@gmail.com>

* move migrating to backend

* add loading image when migrating and fix tests

* fix fmt

* add redis task queue support and improve docs

* fix fixtures

* fix fixtures

* fix duplicate function on index.js

* fix tests

* rename repository statuses

* check if repository is being create when SSH request

* fix lint

* fix template

* some improvements

* fix template

* unified migrate options

* fix lint

* fix loading page

* refactor

* When gitea restart, don't restart the running tasks because we may have servel gitea instances, that may break the migration

* fix js

* Update models/repo.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* fix tests

* rename ErrTaskIsNotExist to ErrTaskDoesNotExist

* delete release after add one on tests to make it run happy

* fix tests

* fix tests

* improve codes

* fix lint

* fix lint

* fix migrations
2019-10-13 21:23:14 +08:00
Lunny Xiao 46a12f196b
Move change issue title from models to issue service package (#8456)
* move change issue title from models to issue service package

* make the change less

* fix typo
2019-10-11 14:44:43 +08:00
Tekaoh b6616591d1 Check for either escaped or unescaped wiki filenames (#8408)
* Check for either escaped or unescaped wiki filenames

+ Gitea currently saves wiki pages with escaped filenames.
+ Wikis mirrored from other places like Github use unescaped filenames.
+ We need to be checking for filenames in either format to increase compatibility.

* Better logic for escaped and unescaped wiki filenames

Co-Authored-By: null <guillep2k@users.noreply.github.com>
2019-10-09 21:49:37 +03:00
guillep2k 4843723d00 Allow users with explicit read access to give approvals (#8382) 2019-10-08 15:18:17 -04:00
Lunny Xiao 170743c8a0 Revert "Fix issues/pr list broken when there are many repositories (#8409)" (#8427)
This reverts commit 78438d310b.
2019-10-08 20:55:16 +03:00
Lunny Xiao 78438d310b
Fix issues/pr list broken when there are many repositories (#8409)
* fix issues/pr list broken when there are many repositories

* remove unused codes

* fix counting error on issues/prs

* keep the old logic

* fix panic

* fix tests
2019-10-08 10:57:41 +08:00
silverwind 08896cd9f6 add file line count info on UI (#8396)
Also reworked the header to remove the filename (which is redundant with
the file path above) and made the header a flexbox with a monospace
font.

Fixes: https://github.com/go-gitea/gitea/issues/8170
2019-10-07 00:59:17 -04:00
guillep2k fb7c23f911 Fix editor commit to new branch if PR disabled (#8375) 2019-10-05 10:09:19 +08:00
Mario Lubenka f92a0b68fe Bugfix for image compare and minor improvements to image compare (#8289)
* Resolve error when comparing images

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Check blob existence instead of git-ls when checking if file exists

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Show file metadata also when a file was newly added

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Fixes error in commit view

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Excludes assigning path and image infos for compare routers to service package

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Removes nil default and fixes import order

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Adds missing comments

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Moves methods for assigning compare data to context into repo router package

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Show image compare for deleted images as well. Simplify check if image should be displayed

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
2019-10-04 15:58:54 -04:00
Tekaoh e3eb9fa33d Fix a comment typo (#8358) 2019-10-02 16:02:04 -04:00
Aam Surganda bcd4af483d Change general form binding to gogs form (#8334) 2019-10-02 20:58:40 +08:00
David Svantesson 90ab3056eb Api: advanced settings for repository (external wiki, issue tracker etc.) (#7756)
* Add API for Repo Advanced Settings of wiki and issue tracker

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Add some integration tests for tracker and wiki settings through API

* Should return StatusUnprocessableEntity in case of invalid API values.

* Add tests for invalid URLs for external tracker and wiki.

* Do not set inital values if they are default of type

* Make issue tracker and wiki units separate structures in Repository API structure.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Fix comment of structures

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Rewrite API to use struct for setting tracker and wiki settings.

* LetOnlyContributorsTrackTime -> AllowOnlyContributorsToTrackTime
2019-10-02 17:30:41 +08:00
Lunny Xiao 7ff783b732
Move mirror to a standalone package from models (#7486)
* move mirror to a standalone package

* fix mirror address in template

* fix tests

* fix lint

* fix comment

* fix tests

* fix tests

* fix vendor

* fix fmt

* fix lint

* remove wrong file submitted

* fix conflict

* remove unrelated changes

* fix go mod

* fix tests

* clean go mod

* make vendor work

* make vendor work

* fix tests

* remove duplicated test
2019-10-01 21:40:17 +08:00
David Svantesson 36bcd4cd6b API endpoint for searching teams. (#8108)
* Api endpoint for searching teams.

Signed-off-by: dasv <david.svantesson@qrtech.se>

* Move API to /orgs/:org/teams/search

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Regenerate swagger

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Fix search is Get

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Add test for search team API.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Update routers/api/v1/org/team.go

grammar

Co-Authored-By: Richard Mahn <richmahn@users.noreply.github.com>

* Fix review comments

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Fix some issues in repo collaboration team search, after changes in this PR.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Remove teamUser which is not used and replace with actual user id.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Remove unused search variable UserIsAdmin.

* Add paging to team search.

* Re-genereate swagger

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Fix review comments

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* fix

* Regenerate swagger
2019-10-01 13:32:28 +08:00
Lunny Xiao 3249c0ccba
Extract actions on deletereleasebyid from models to release service (#8219)
* extract actions on deletereleasebyid from models to release service

* fix tests
2019-10-01 00:10:00 +08:00
Lunny Xiao e6113000c5
Extract actions on new issue from models to services (#8217)
* extract actions on new issue from models to services

* improve code

* rename services/issues to services/issue
2019-09-30 21:50:44 +08:00
David Svantesson 9c2a58456a Fix repo_admin_change_team_access always checked in org settings (#8319)
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
2019-09-30 02:20:27 +03:00
David Svantesson c6fb7fe27c Fix API for edit and delete release attachment (#8285)
* Add logging for when user requested attachment doesn't belong to the specified release.

* Fix API to use correct variable for release asset (attachment)
2019-09-27 10:24:06 +08:00
Lunny Xiao eb11ca6847
Extract actions on new pull request from models to pulls service and move code.gitea.io/gitea/modules/pull to code.gitea.io/gitea/services/pull (#8218)
* extract actions on new pull request from models to pulls service

* improve code

* move code.gitea.io/gitea/modules/pull to code.gitea.io/gitea/services/pull

* fix fmt

* Rename pulls.go to pull.go
2019-09-27 08:22:36 +08:00
Sandro Santilli d958b9db4f Alwaywas return local url for users avatar (#8245)
* Always return local url for users avatar

Avoids having to wait for DNS lookups when libravatar is activated
fixing #6046

* Avoid double slash in avatar link

* Move avatar route to the correct place
2019-09-26 12:21:23 -04:00
Lunny Xiao 061388379a Move create issue comment to comments package (#8212)
* move create issue comment to comments package

* extract actions on update/delete comment from models to comment service

* fix lint

* fix lint
2019-09-24 13:39:50 -04:00
Lunny Xiao 5a438ee3c0
Move all mail related codes from models to services/mailer (#7200)
* move all mail related codes from models to modules/mailer

* fix lint

* use DBContext instead Engine

* use WithContext not WithEngine

* Use DBContext instead of Engine

* don't use defer when sess.Close()

* move DBContext to context.go and add some methods

* move mailer from modules/ to services

* fix lint

* fix tests

* fix fmt

* add gitea copyright

* fix tests

* don't expose db functions

* make code clear

* add DefaultDBContext

* fix build

* fix bug
2019-09-24 13:02:49 +08:00
David Svantesson a0e88dfc2e Add teams to repo on collaboration page. (#8045)
* Add teams to repo on collaboration page.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Add option for repository admins to change teams access to repo.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Add comment for functions

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Make RepoAdminChangeTeamAccess default false in xorm and make it default checked in template instead.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Make proper language strings and fix error redirection.

* Add unit tests for adding and deleting team from repository.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Add database migration

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Fix redirect

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Fix locale string mismatch.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>

* Move team access mode text logic to template.

* Move collaborator access mode text logic to template.
2019-09-23 23:08:03 +03:00
guillep2k 2a2b46c62e Reference issues from pull requests and other issues (#8137)
* Update ref comment

* Generate comment on simple ref

* Make fmt + remove unneeded repo load

* Add TODO comments

* Add ref-check in issue creation; re-arrange template

* Make unit tests pass; rearrange code

* Make fmt

* Filter out xref comment if user can't see the referencing issue

* Add TODOs

* Add cross reference

* Rearrange code; add cross-repository references

* Striketrhough obsolete references

* Remove unnecesary TODO

* Add "not supported" note

* Support for edits and deletes, and issue title

* Revert changes to go.mod

* Fix fmt

* Add support for xref from API

* Add first integration test

* Add integration tests

* Correct formatting

* Fix add comment test

* Add migration

* Remove outdated comments; fix typo

* Some code refactoring and rearranging

* Rename findCrossReferences to createCrossReferences

* Delete xrefs when repository is deleted

* Corrections as suggested by @lafriks

* Prepare for merge

* Fix log for errors
2019-09-20 01:45:38 -04:00
guillep2k 8a0379d68a Allow registration when button is hidden (#8237) 2019-09-19 22:40:33 +08:00
jaqra 28362195a0 Add 'Mentioning you' group to /issues page (#8201) 2019-09-18 10:24:44 +03:00
Lunny Xiao 04ca7f0047 Refuse merge until all required status checks success (#7481)
* refuse merge until ci successfully

* deny merge request when required status checkes not succeed on merge Post and API

* add database migration for added columns on protected_branch

* fix migration

* fix protected branch check bug

* fix protected branch settings

* remove duplicated code on check pull request's required commit statuses pass

* remove unused codes

* fix migration

* add newline for template file

* fix go mod

* rename function name and some other fixes

* fix template

* fix bug pull view

* remove go1.12 wrong dependencies

* add administrator bypass when protected branch status check enabled

* fix bug

* improve the codes
2019-09-18 08:39:45 +03:00
Lunny Xiao 29454733b4
move some milestone functions to a standalone package (#8213) 2019-09-18 08:17:12 +08:00
techknowlogick a60d3cbea2 Remove legacy handling of drone token (#8191)
Now Drone has removed Gitea user/pass handling we can remove legacy handling
2019-09-17 15:13:24 +03:00
Mario Lubenka a37236314c Adds side-by-side diff for images (#6784)
* Adds side-by-side diff for images

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Explain blank imports

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Use complete word for width and height labels on image compare

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Update index.css from master

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Moves ImageInfo to git commit file

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Assign ImageInfo function for template and sets correct target for BeforeSourcePath

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Adds missing comment

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Return error if ImageInfo failed

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Avoid template panic when ImageInfo failed for some reason

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Show file size on image diff

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Removes unused helper function

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Reverts copyright year change

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Close file reader

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Update commit.go

Sets correct data key

* Moves reader.Close() up a few lines

* Updates index.css

* Updates CSS file

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Transfers adjustments for image compare to compare.go file

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Adjusts variable name

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Apply lesshint recommendations

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Do not show old image on image compare if it is not in index of base commit

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Change file size text

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
2019-09-16 17:03:22 +08:00
Lunny Xiao 4959bf1c09
Move create release from models to a standalone package (#7539)
* move create release from models to a standalone package

* fix lint

* fix comment year

* fix lint

* fix lint

* fix package import name

* fix vendor

* fix go mod

* some refactors

* fix vendor

* use go1.12 make vendor

* fix vendor
2019-09-15 23:28:25 +08:00
Lunny Xiao be0f7ff9bf
Fix team user api (#8172)
* fix team user api

* fix tests

* fix api

* fix team user api

* change user convert

* fix tests

* fix tests
2019-09-15 20:22:02 +08:00
WGH 6ddd3b0b47 Implement webhook branch filter (#7791)
* Fix validate() function to handle errors in embedded anon structs

* Implement webhook branch filter

See #2025, #3998.
2019-09-09 08:48:21 +03:00
John Olheiser 0118b6aaf8 Add option to initialize repository with labels (#6061)
* Add optional label sets on repo creation

* Fix CRLF

* Instead of hardcoding default, make it the helper

* Move label set init out of repo init

Add a new error for the router
Combine router label init with repo creation label init

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add issue labels to Swagger for repo creation

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update models/issue_label.go

Co-Authored-By: Lauris BH <lauris@nix.lv>

* Update models/issue_label.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
2019-09-08 11:28:40 +03:00