Commit Graph
2379 Commits
Author SHA1 Message Date
guillep2kandAntoine GIRARD cd13f273d1 Transaction-aware retry create issue to cope with duplicate keys (#8307)
* Revert #7898

* Transaction-aware retry create issue to cope with duplicate keys

* Restore INSERT ... WHERE usage

* Rearrange code for clarity

* Fix error return in newIssue()

* Fix error message
2019-10-03 00:28:30 +02:00
David SvantessonandLunny Xiao 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 <[email protected]>

* 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 <[email protected]>

* Fix comment of structures

Signed-off-by: David Svantesson <[email protected]>

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

* LetOnlyContributorsTrackTime -> AllowOnlyContributorsToTrackTime
2019-10-02 17:30:41 +08:00
Lunny XiaoandGitHub 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 SvantessonandLunny Xiao 36bcd4cd6b API endpoint for searching teams. (#8108)
* Api endpoint for searching teams.

Signed-off-by: dasv <[email protected]>

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

Signed-off-by: David Svantesson <[email protected]>

* Regenerate swagger

Signed-off-by: David Svantesson <[email protected]>

* Fix search is Get

Signed-off-by: David Svantesson <[email protected]>

* Add test for search team API.

Signed-off-by: David Svantesson <[email protected]>

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

grammar

Co-Authored-By: Richard Mahn <[email protected]>

* Fix review comments

Signed-off-by: David Svantesson <[email protected]>

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

Signed-off-by: David Svantesson <[email protected]>

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

Signed-off-by: David Svantesson <[email protected]>

* Remove unused search variable UserIsAdmin.

* Add paging to team search.

* Re-genereate swagger

Signed-off-by: David Svantesson <[email protected]>

* Fix review comments

Signed-off-by: David Svantesson <[email protected]>

* fix

* Regenerate swagger
2019-10-01 13:32:28 +08:00
Lunny XiaoandGitHub 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 XiaoandGitHub 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
Elias NorbergandLunny Xiao 49547ea158 Show correct commit status in PR list (#8316)
* Use correct index when fetching commit status

Signed-off-by: Elias Norberg <[email protected]>

* Compare against base repo to avoid mismatch when merging from fork

Signed-off-by: Elias Norberg <[email protected]>
2019-09-30 09:07:43 +08:00
Lunny XiaoandGitHub aa9a99cf5f Upgrade xorm to latest to fix insert issue bug (#8309)
* upgrade xorm to latest to fix insert issue bug

* add newissue unit tests

* update xorm version

* fix tests
2019-09-29 20:52:39 +08:00
Lunny XiaoandGitHub 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 Santilliandtechknowlogick 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
guillep2kandLauris BH c05b89a5aa Fix nil ref (#8281) 2019-09-25 06:57:06 +03:00
Lunny Xiaoandtechknowlogick 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
Sandro Santilliandtechknowlogick 3dd1cee331 Test more reserved usernames (#8263)
* Test more reserved usernames

* Add more reserved usernames, sort them

* Reserve "attachments" username (is a used route)

* It's "avatars" being reserved, not "avatar"
2019-09-24 13:12:56 -04:00
Lunny XiaoandGitHub 29dda47cbb Fix label count (#8267)
* fix label count

* fix vendor

* fix import order

* update xorm to fix bug

* fix tests

* fix mssql bug
2019-09-24 21:22:39 +08:00
Lunny XiaoandGitHub 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 SvantessonandLauris BH a0e88dfc2e Add teams to repo on collaboration page. (#8045)
* Add teams to repo on collaboration page.

Signed-off-by: David Svantesson <[email protected]>

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

Signed-off-by: David Svantesson <[email protected]>

* Add comment for functions

Signed-off-by: David Svantesson <[email protected]>

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

Signed-off-by: David Svantesson <[email protected]>

* Make proper language strings and fix error redirection.

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

Signed-off-by: David Svantesson <[email protected]>

* Add database migration

Signed-off-by: David Svantesson <[email protected]>

* Fix redirect

Signed-off-by: David Svantesson <[email protected]>

* Fix locale string mismatch.

Signed-off-by: David Svantesson <[email protected]>

* Move team access mode text logic to template.

* Move collaborator access mode text logic to template.
2019-09-23 23:08:03 +03:00
Lanre AdelowoandLauris BH 63ff61615e Delete releases attachments if release is deleted (#6068)
* delete attachments from the database and file system

* add migration

* fix import statements

* fix package name

* remove conditional should in case the confi has been changed and the server restarted

* simplify deletion of attachments in DB

* fix CI build

* fix review

* add copyright in the proper place

* fix review
2019-09-22 12:05:48 +03:00
guillep2kandtechknowlogick 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
Daniel Fonseca de Liraandtechknowlogick 09e452f84a Fix release API URL generation (#8234) 2019-09-18 20:23:45 -04:00
jaqraandLauris BH 28362195a0 Add 'Mentioning you' group to /issues page (#8201) 2019-09-18 10:24:44 +03:00
Lunny XiaoandLauris BH 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 XiaoandGitHub 29454733b4 move some milestone functions to a standalone package (#8213) 2019-09-18 08:17:12 +08:00
Bjoern Petriandtechknowlogick 99f3ee3bf3 MS Teams webhook misses commit messages (#8209)
The current webhook just shows the amount of commits, but misses the actual commit description. While the code is actually there to include the description, it is just not included.

Signed-off-by: Bjoern Petri <[email protected]>
2019-09-17 15:56:29 -04:00
Jakob Ackermannandtechknowlogick 89648746a5 [ssh] fix the config specification in the authorized_keys template (#8031)
The gitea flags must appear in front of the gitea command. Otherwise
 they are ignored.

Signed-off-by: Jakob Ackermann <[email protected]>
2019-09-15 18:51:40 -04:00
Lunny XiaoandGitHub 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
techknowlogickandAntoine GIRARD 7a8e299c7c migrate gplus to google oauth2 provider (#7885)
* migrate gplus to google oauth2 provider. this still provides support for old gplus connections.

* Update models/oauth2.go

Co-Authored-By: Antoine GIRARD <[email protected]>

* make vendor
2019-09-14 12:02:39 +02:00
techknowlogickandGitHub 2837563147 oauth2 with remote Gitea - Fix #8093 (#8149) 2019-09-12 22:15:36 -04:00
guillep2kandLauris BH 72f6d5c882 Restrict repository indexing by glob match (#7767)
* Restrict repository indexing by file extension

* Use REPO_EXTENSIONS_LIST_INCLUDE instead of REPO_EXTENSIONS_LIST_EXCLUDE and have a more flexible extension pattern

* Corrected to pass lint gosimple

* Add wildcard support to REPO_INDEXER_EXTENSIONS

* This reverts commit 72a650c8e4.

* Add wildcard support to REPO_INDEXER_EXTENSIONS (no make vendor)

* Simplify isIndexable() for better clarity

* Add gobwas/glob to vendors

* manually set appengine new release

* Implement better REPO_INDEXER_INCLUDE and REPO_INDEXER_EXCLUDE

* Add unit and integration tests

* Update app.ini.sample and reword config-cheat-sheet

* Add doc page and correct app.ini.sample

* Some polish on the doc

* Simplify code as suggested by @lafriks
2019-09-11 20:26:28 +03:00
Lauris BHandLunny Xiao 7eacdcf39a Fix webhooks to use proxy from environment (#8116) 2019-09-10 00:21:07 +08:00
WGHandLauris BH 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
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 <[email protected]>

* Add issue labels to Swagger for repo creation

Signed-off-by: jolheiser <[email protected]>

* Update models/issue_label.go

Co-Authored-By: Lauris BH <[email protected]>

* Update models/issue_label.go

Co-Authored-By: guillep2k <[email protected]>
2019-09-08 11:28:40 +03:00
guillep2kandLunny Xiao 09badd55dd Add reviewrs as participants (#8121) 2019-09-07 22:53:35 +08:00
Lunny Xiaoandtechknowlogick c03d75fbd5 Move git diff codes from models to services/gitdiff (#7889)
* move git diff codes from models to services/gitdiff

* fix template

* fix test

* fix template
2019-09-05 22:20:09 -04:00
Rinatandtechknowlogick b660a732ae feat: highlight issue references with : (#8101)
* feat: highlight issue references with :

e.g. #1287: my commit msg
e.g. ABC-1234: my commit msg

* ref: update model regex to consistent with issueNumericPattern

* test: check highlight issue with : in commits messages
2019-09-05 20:39:54 -04:00
David SvantessonandLunny Xiao 1f951cdeba Add API endpoint for accessing repo topics (#7963)
* Create API endpoints for repo topics.

Signed-off-by: David Svantesson <[email protected]>

* Generate swagger

Signed-off-by: David Svantesson <[email protected]>

* Add documentation to functions

Signed-off-by: David Svantesson <[email protected]>

* Grammar fix

Signed-off-by: David Svantesson <[email protected]>

* Fix function comment

Signed-off-by: David Svantesson <[email protected]>

* Can't use FindTopics when looking for a single repo topic, as it doesnt use exact match

Signed-off-by: David Svantesson <[email protected]>

* Add PUT ​/repos​/{owner}​/{repo}​/topics and remove GET ​/repos​/{owner}​/{repo}​/topics

* Ignore if topic is sent twice in same request, refactoring.

Signed-off-by: David Svantesson <[email protected]>

* Fix topic dropdown with api changes.

Signed-off-by: David Svantesson <[email protected]>

* Style fix

Signed-off-by: David Svantesson <[email protected]>

* Update API documentation

Signed-off-by: David Svantesson <[email protected]>

* Better way to handle duplicate topics in slice

Signed-off-by: David Svantesson <[email protected]>

* Make response element TopicName an array of strings, instead of using an array of TopicName

Signed-off-by: David Svantesson <[email protected]>

* Add test cases for API Repo Topics.

Signed-off-by: David Svantesson <[email protected]>

* Fix format of tests

Signed-off-by: David Svantesson <[email protected]>

* Fix comments

Signed-off-by: David Svantesson <[email protected]>

* Fix unit tests after adding some more topics to the test fixture.

Signed-off-by: David Svantesson <[email protected]>

* Update models/topic.go

Limit multiple if else if ...

Co-Authored-By: Antoine GIRARD <[email protected]>

* Engine as first parameter in function

Co-Authored-By: Antoine GIRARD <[email protected]>

* Replace magic numbers with http status code constants.

Signed-off-by: David Svantesson <[email protected]>

* Fix variable scope

Signed-off-by: David Svantesson <[email protected]>

* Test one read with login and one with token

Signed-off-by: David Svantesson <[email protected]>

* Add some more tests

Signed-off-by: David Svantesson <[email protected]>

* Apply suggestions from code review

Use empty struct for efficiency

Co-Authored-By: Lauris BH <[email protected]>

* Add test case to check access for user with write access

Signed-off-by: David Svantesson <[email protected]>

* Fix access, repo admin required to change topics

Signed-off-by: David Svantesson <[email protected]>

* Correct first test to be without token

Signed-off-by: David Svantesson <[email protected]>

* Any repo reader should be able to access topics.

* No need for string pointer

Signed-off-by: David Svantesson <[email protected]>
2019-09-03 23:46:24 +08:00
Gary KimandLauris BH f1c414882c Add Ability for User to Customize Email Notification Frequency (#7813)
* Add Backend Logic for Toggling Email Notification

This commit adds the backend logic for
allowing users to enable or disable email
notifications. The implementation ensures
that only issue notification emails get disabled
and important emails are still sent regardless
of the setting.

The UI to toggle this setting has not yet been
implemented.

* Add UI and complete user email notification enable

This commit completes the functionality to allow
users to disable their own email notifications.

Signed-off-by: Gary Kim <[email protected]>

* Add Third Option for Only Email on Mention

Signed-off-by: Gary Kim <[email protected]>

* Readd NOT NULL to new preference string

Signed-off-by: Gary Kim <[email protected]>

* Add Tests and Rewrite Comment

Signed-off-by: Gary Kim <[email protected]>

* Allow admin to set default email frequency

Signed-off-by: Gary Kim <[email protected]>

* Add new config option to docs

Signed-off-by: Gary Kim <[email protected]>

* Fix a few mistakes

Signed-off-by: Gary Kim <[email protected]>

* Only update required columns

Signed-off-by: Gary Kim <[email protected]>

* Simplify an error check

Signed-off-by: Gary Kim <[email protected]>

* Make email_notification_preference column in DB be VARCHAR(20)

Signed-off-by: Gary Kim <[email protected]>

* Handle errors

Signed-off-by: Gary Kim <[email protected]>

* Update models/migrations/v93.go

Co-Authored-By: Lauris BH <[email protected]>
2019-08-29 17:05:42 +03:00
guillep2kandtechknowlogick 5fe2ec264f Retry create issue to cope with duplicate keys (#7898)
* Retry create issue to cope with duplicate keys

* Use  .SetExpr().Where().Insert()
2019-08-26 22:17:23 -04:00
David SvantessonandLauris BH c9546d4cdd Include description in repository search. (#7942)
* Add description in repository search.

Signed-off-by: David Svantesson <[email protected]>

* Refactor SearchRepositoryByName with a general function SearchRepository

Signed-off-by: David Svantesson <[email protected]>

* Allow to specify if description shall be included in API repo search.

Signed-off-by: David Svantesson <[email protected]>

* Add new app.ini setting for whether to search within repo description.

Signed-off-by: David Svantesson <[email protected]>

* Search keyword in description (if setting enabled) on:
 - Explore page
 - Organization profile page
 - User profile page
 - Admin repo page

Do not search keyword in description on:
 - Any non-keyword search (not relevant)
 - Incremental search (uses API)

Signed-off-by: David Svantesson <[email protected]>

* Put parameters related to keyword directly after it

Signed-off-by: David Svantesson <[email protected]>

* Add test cases for including (and not including) repository description in search.

Signed-off-by: David Svantesson <[email protected]>

* Rename test function from TestSearchRepositoryByName to TestSearchRepository.

Signed-off-by: David Svantesson <[email protected]>

* Make setting SEARCH_REPO_DESCRIPTION default to true

Signed-off-by: David Svantesson <[email protected]>
2019-08-25 20:06:36 +03:00
David SvantessonandLauris BH 8c24bb9e43 Abort syncrhonization from LDAP source if there is some error. (#7960)
Signed-off-by: David Svantesson <[email protected]>
2019-08-24 21:53:37 +03:00
guillep2kandLauris BH e3115cc019 Add support for DEFAULT_ORG_MEMBER_VISIBLE (#7669)
* Add support for DEFAULT_ORG_MEMBER_VISIBLE

* Correct formatting

* Improved description in cheat sheet.

* Add test for DefaultOrgMemberVisible

* Remove dead code
2019-08-24 15:28:59 +03:00
Lunny XiaoandAntoine GIRARD f83db078f0 Move database settings from models to setting (#7806)
* move database settings from models to setting

* update docs

* fix checkout pr

* fix tests

* fix lint

* remove unsupported tidb options

* correct wrong variable name

* remove tidb totally
2019-08-24 11:24:45 +02:00
Tamal Sahaandtechknowlogick 171b359877 Use gitea forked macaron (#7933)
Signed-off-by: Tamal Saha <[email protected]>
2019-08-23 12:40:29 -04:00
David Svantessonandtechknowlogick ca6fb004ac Change repo search to use exact match for topic search. (#7941)
Signed-off-by: David Svantesson <[email protected]>
2019-08-22 22:37:35 -04:00
Lunny XiaoandGitHub 111d31d681 don't convert buffer to string (#7115) 2019-08-22 12:52:40 +08:00
Lunny XiaoandGitHub 09ca391230 Add file status on API (#7671)
* add file status on API

* fix tests

* fix tests

* fix tests
2019-08-21 13:16:22 +08:00
Mura Liandtechknowlogick 3ac45e3cb5 Fix pull creation with empty changes (#7920)
* Logs the stderr of git-apply
* Add an integration test
* Skip testPatch when patch is empty
2019-08-20 13:43:00 -04:00
Lunny XiaoandAntoine GIRARD 9b9d162194 fix wrong sender when send slack webhook (#7918) 2019-08-20 17:05:30 +02:00
zeripathandGitHub bee1227b2f Extract the username and password from the mirror url (#7651)
* Explode out mirror username and password

* Update models/repo_mirror.go

* Just roundtrip the password

* remove unused declaration

* Update templates/repo/settings/options.tmpl
2019-08-16 22:56:57 +01:00
Lunny XiaoandGitHub 85202d4784 Display ui time with customize time location (#7792)
* display ui time with customize time location

* fix lint

* rename UILocation to DefaultUILocation

* move time related functions to modules/timeutil

* fix tests

* fix tests

* fix build

* fix swagger
2019-08-15 22:46:21 +08:00
guillep2kandLunny Xiao 5a44be627c Convert files to utf-8 for indexing (#7814)
* Convert files to utf-8 for indexing

* Move utf8 functions to modules/base

* Bump repoIndexerLatestVersion to 3

* Add tests for base/encoding.go

* Changes to pass gosimple

* Move UTF8 funcs into new modules/charset package
2019-08-15 20:07:28 +08:00