Commit Graph

2253 Commits

Author SHA1 Message Date
Benno 7bb817e6d1 Respect LFS File Lock on UI (#8719)
* update #8687 respect file locking

* upate #8687 Add LFS locker information

* update #8719 enhance coding style and return error
2019-10-29 23:32:21 +02:00
Lukas 559803025d Show zero lines on the line counter if the file empty (#8700)
* Show zero lines on the line counter if the file empty

Signed-off-by: LukBukkit <luk.bukkit@gmail.com>

* A single variable to check whether NumLines is set

Signed-off-by: LukBukkit <luk.bukkit@gmail.com>
2019-10-29 16:05:26 +00:00
zeripath 5e6a008fba
Add basic repository lfs management (#7199)
This PR adds basic repository LFS management UI including the ability to find all possible pointers within the repository. Locks are not managed at present but would be addable through some simple additions.

* Add basic repository lfs management
* add auto-associate function
* Add functionality to find commits with this lfs file
* Add link to find commits on the lfs file view
* Adjust commit view to state the likely branch causing the commit
* Only read Oid from database
2019-10-28 18:31:55 +00:00
Lunny Xiao af8957bc4c
Move issue notifications (#8713) 2019-10-29 00:45:43 +08:00
Lunny Xiao c66c9dabc7
Move issue change status from models to service (#8691) 2019-10-28 13:26:46 +08:00
Lunny Xiao 495d5e4329
Move more issue assignee code from models to issue service (#8690)
* Move more issue assignee code from models to issue service

* fix test
2019-10-28 10:11:50 +08:00
David Svantesson 018b0e8180 Fix deadline on update issue or PR via API (#8696)
* Fix deadline on update issue or PR via API

* variable initialized directly (review comment)
2019-10-28 01:35:20 +02:00
Lunny Xiao 9e85358777
Move some repositories' operations to a standalone service package (#8557)
* Move some repositories' operations to a standalone service package

* improve code

* remove unused codes

* add rollback when fork failed

* add repo when return
2019-10-26 14:54:11 +08:00
David Svantesson 6aa3f8bc29 Mail assignee when issue/pull request is assigned (#8546)
* Send email to assigned user

* Only send mail if enabled

* Mail also when assigned through API

* Need to refactor functions from models to issue service

* Refer to issue index rather than ID

* Disable email notifications completly at initalization if global disable

* Check of user enbled mail shall be in mail notification function only

* Initialize notifications from routers init function.

* Use the assigned comment when sending assigned mail

* Refactor so that assignees always added as separate step when new issue/pr.

* Check error from AddAssignees

* Check if user can be assiged to issue or pull request

* Missing return

* Refactor of CanBeAssigned check.

CanBeAssigned shall have same check as UI.

* Clarify function names (toggle rather than update/change), and clean up.

* Fix review comments.

* Flash error if assignees was not added when creating issue/pr

* Generate error if assignee users doesn't exist
2019-10-25 22:46:37 +08:00
Lunny Xiao 0a80164bec Revert "API should follow RequireSignInView (#8654)" (#8675)
This reverts commit 3c63c3ace4.
2019-10-24 22:10:48 +01:00
Lunny Xiao 3c63c3ace4
API should follow RequireSignInView (#8654) 2019-10-24 13:32:40 +08:00
Lunny Xiao bd7709a602
Hide some user information via API if user have no enough permission (#8655)
* Hide some user information via API if user have no enough permission

* fix test
2019-10-24 10:52:17 +08:00
Monty Taylor ee7b153dd9 Fix 500 when getting user as unauthenticated user (#8653)
When doing GET /api/v1/users/{user} as an unauthenticated user,
gitea throws a 500 because it's trying to dereference elements
from the context user. It wants to do this to see whether to
show the primary email and will do that if the logged in user
is admin or the user in question. However, if ctx.User is nil,
go gets really unhappy.
2019-10-24 09:18:41 +08:00
zeripath c84174b764
Use AppSubUrl for more redirections (#8647)
Fix #8461 - fix misspelling of {{AppSubUrl}} and other misspelling in template
Fixes /explore and organisation redirection
2019-10-23 22:04:22 +01:00
7FM 22272fe1e4 Make /users/{username}/repos list private repos the current user has access to (#8621) 2019-10-23 19:46:32 +01:00
John Olheiser 3e61a9628c Improve OGP (#8637)
* Improve OGP
* Ensure Repo is loaded when checking Pull info

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-10-23 18:54:13 +01:00
zeripath 0bfe5eb10b
Allow Protected Branches to Whitelist Deploy Keys (#8483)
Add an option to protected branches to add writing deploy keys to the whitelist for pushing.

Please note this is technically a breaking change: previously if the owner of a repository was on the whitelist then any writing deploy key was effectively on the whitelist. This option will now need to be set if that is desired.

Closes #8472 

Details:
* Allow Protected Branches to Whitelist Deploy Keys
* Add migration
* Ensure that IsDeployKey is set to false on the http pushes
* add not null default false
2019-10-21 09:21:45 +01:00
George Harvey 481c66a91f Allows external rendering of other filetypes 2 (#8300)
* allow external rendering of other filetypes

fixes #4996 and #7614 
allows rendering of non-tex files, or otherwise accounted for filetypes

* Moves flie-size check before read()

And performs gofmt -s

* Only reads if markType is detected
2019-10-21 07:54:18 +01:00
Lunny Xiao 280f4bebbf Move issue label operations to issue service package (#8553)
* Move issue label operations to issue service package

* fix test

* fix fmt
2019-10-19 12:48:29 +03:00
John Olheiser 240f46a422 Fix template error on account page (#8562) 2019-10-19 10:01:33 +01:00
Lunny Xiao 945f121262
Fix bug on pull requests when transfer head repository (#8564)
* fix bug on pull requests when transfer head repository

* add migration and fix lint

* fix tests and add a cache check on LoadBaseRepo
2019-10-18 19:13:31 +08:00
John Olheiser 7c4c01c0fd Fix review webhooks (#8570)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-10-18 16:33:19 +08:00
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
guillep2k 09badd55dd Add reviewrs as participants (#8121) 2019-09-07 22:53:35 +08:00
Lunny Xiao 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
David Svantesson 1f951cdeba Add API endpoint for accessing repo topics (#7963)
* Create API endpoints for repo topics.

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

* Generate swagger

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

* Add documentation to functions

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

* Grammar fix

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

* Fix function comment

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

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

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

* 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 <davidsvantesson@gmail.com>

* Fix topic dropdown with api changes.

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

* Style fix

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

* Update API documentation

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

* Better way to handle duplicate topics in slice

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

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

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

* Add test cases for API Repo Topics.

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

* Fix format of tests

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

* Fix comments

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

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

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

* Update models/topic.go

Limit multiple if else if ...

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

* Engine as first parameter in function

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

* Replace magic numbers with http status code constants.

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

* Fix variable scope

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

* Test one read with login and one with token

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

* Add some more tests

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

* Apply suggestions from code review

Use empty struct for efficiency

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

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

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

* Fix access, repo admin required to change topics

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

* Correct first test to be without token

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

* Any repo reader should be able to access topics.

* No need for string pointer

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
2019-09-03 23:46:24 +08:00
guillep2k 8ae96a37ce Add change title notification for issues (#8061) 2019-09-02 22:35:31 -04:00
Gary Kim 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 <gary@garykim.dev>

* Add Third Option for Only Email on Mention

Signed-off-by: Gary Kim <gary@garykim.dev>

* Readd NOT NULL to new preference string

Signed-off-by: Gary Kim <gary@garykim.dev>

* Add Tests and Rewrite Comment

Signed-off-by: Gary Kim <gary@garykim.dev>

* Allow admin to set default email frequency

Signed-off-by: Gary Kim <gary@garykim.dev>

* Add new config option to docs

Signed-off-by: Gary Kim <gary@garykim.dev>

* Fix a few mistakes

Signed-off-by: Gary Kim <gary@garykim.dev>

* Only update required columns

Signed-off-by: Gary Kim <gary@garykim.dev>

* Simplify an error check

Signed-off-by: Gary Kim <gary@garykim.dev>

* Make email_notification_preference column in DB be VARCHAR(20)

Signed-off-by: Gary Kim <gary@garykim.dev>

* Handle errors

Signed-off-by: Gary Kim <gary@garykim.dev>

* Update models/migrations/v93.go

Co-Authored-By: Lauris BH <lauris@nix.lv>
2019-08-29 17:05:42 +03:00
jaqra 245457d4d3 Move line number to :before attr to hide from search on browser (#8002)
* Move line number to :before attr to hide from search on browser

* Use same variable in WriteString

Co-Authored-By: Lauris BH <lauris@nix.lv>
2019-08-28 00:59:05 +02:00
guillep2k 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
Gary Kim 541fab196f Fix adding default Telegram webhook (#7972)
* Fix adding default Telegram webhook

Fixes #7932

Signed-off-by: Gary Kim <gary@garykim.dev>

* Run goimports

Signed-off-by: Gary Kim <gary@garykim.dev>
2019-08-26 18:59:10 -04:00
Richard Mahn bb5f7cdae6 Adds details about what tags can use the Git tags API (#7989) 2019-08-26 21:52:04 +02:00
Mike Schwörer 042089fbaf API method to list all commits of a repository (#6408)
* Added API endpoint ListAllCommits (/repos/{owner}/{repo}/git/commits)

Signed-off-by: Mike Schwörer <mailport@mikescher.de>

* Fixed failing drone build

Signed-off-by: Mike Schwörer <mailport@mikescher.de>

* Implemented requested changes (PR reviews)

Signed-off-by: Mike Schwörer <mailport@mikescher.de>

* gofmt

Signed-off-by: Mike Schwörer <mailport@mikescher.de>

* Changed api route from "/repos/{owner}/{repo}/git/commits" to "/repos/{owner}/{repo}/commits"

* Removed unnecessary line

* better error message when git repo is empty

* make generate-swagger

* fixed removed return

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

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

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

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

* go fmt

* Refactored common code into ToCommit()

* made toCommit not exported

* added check for userCache == nil
2019-08-26 16:09:10 +02:00
Tamal Saha 6b3f52fe5f Run CORS handler first for /api routes (#7967)
Signed-off-by: Tamal Saha <tamal@appscode.com>
2019-08-26 13:33:06 +02:00
David Svantesson c9546d4cdd Include description in repository search. (#7942)
* Add description in repository search.

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

* Refactor SearchRepositoryByName with a general function SearchRepository

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

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

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

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

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

* 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 <davidsvantesson@gmail.com>

* Put parameters related to keyword directly after it

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

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

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

* Rename test function from TestSearchRepositoryByName to TestSearchRepository.

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

* Make setting SEARCH_REPO_DESCRIPTION default to true

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
2019-08-25 20:06:36 +03:00
Lunny Xiao 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
David Svantesson 26af3401c3 Document possibility to limit API Repo search to topics only. (#7957)
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
2019-08-23 23:17:10 -04:00
Tamal Saha 171b359877 Use gitea forked macaron (#7933)
Signed-off-by: Tamal Saha <tamal@appscode.com>
2019-08-23 12:40:29 -04:00
zeripath 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
Norwin 867f46f78e Detect delimiter in CSV rendering (#7869)
* detect csv delimiter in csv rendering

fixes #7868

* make linter happy

* fix failing testcase & use ints where possible

* expose markup type to template

previously all markup had the .markdown class, which is incorrect,
as it applies markdown CSS & JS logic to CSV rendering

* fix build (missing `make css`)

* ignore quoted csv content for delimiter scoring

also fix html generation
2019-08-16 01:09:50 +03:00
Lunny Xiao 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
guillep2k 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
Lanre Adelowo a315c8d992 fix non existent milestone with 500 error (#7867) 2019-08-14 19:43:50 -04:00
Lunny Xiao c021890930
move CreateReview to moduels/pull (#7841) 2019-08-14 23:32:19 +08:00
zeripath def84840db Attempt to fix hook problem (#7854) 2019-08-14 12:25:05 +03:00
Mario Lubenka 8bfeb85f93 Enable switching to a different source branch when PR already exists (#7819)
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
2019-08-11 23:23:49 +08:00
David Svantesson cde95f9923 Rewrite existing repo units if setting is not included in api body (#7763)
* Rewrite existing repo units if setting is not included in api body

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

* else-if on one row
2019-08-10 12:32:46 +03:00
Antoine GIRARD 2b6f45299d api: fix multiple bugs with statuses endpoints (#7785)
* fix commit statuses api url

* search refs before passing sha

* adjust tests

* directly search tags and branches names + remove un-needed check in NewCommitStatus

* fix comment

* de-duplicate code

* test: use relative setting.AppURL

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

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

* remove return

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

Co-Authored-By: Lauris BH <lauris@nix.lv>
2019-08-09 10:13:03 +08:00
Lunny Xiao b16be15803 Display error as string but not bytes (#7780)
* display error as string but not bytes

* Update routers/repo/http.go

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>
2019-08-07 19:33:29 +03:00
Lunny Xiao 5b902e2368 add pagination for admin api get orgs and fix only list public orgs bug (#7742) 2019-08-04 14:33:36 -04:00
Lunny Xiao 7d9a13035e display as error (#7724) 2019-08-03 10:07:51 +03:00