1
1
mirror of https://github.com/go-gitea/gitea synced 2024-06-01 00:45:46 +00:00
Commit Graph

2593 Commits

Author SHA1 Message Date
John Olheiser
a516a7ba0f Load milestone in API PR list (#9671) (#9700) 2020-01-10 22:58:03 -05:00
John Olheiser
a2b7cc1bb1 Fix nil reference in repo generation (#9660) (#9666)
* Fix nil reference

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

* Tighten

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-09 16:50:21 +00:00
John Olheiser
04a77b1f42 Add HTML URL to API Issues (#9654) (#9661)
* Add HTML URL to API Issues

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

* Swagger

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

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-09 08:07:21 +02:00
Lunny Xiao
b9309e52f0 Move wiki related funtions from models to services/wiki (#9355)
* Move wiki related funtions from models to services/wiki
2020-01-07 18:27:36 +00:00
zeripath
e5d8e2d10c
Branches not at ref commit ID should not be listed as Merged (#9614)
Once a branch has been merged if the commit ID no longer equals that of
the pulls ref commit id don't offer to delete the branch on the pull screen
and don't list it as merged on branches.

Fix #9201

When looking at the pull page we should also get the commits from the refs/pulls/x/head

Fix #9158
2020-01-07 17:06:14 +00:00
6543
9406368633 Fix Issue Unsubscription (#9634) 2020-01-07 15:41:35 +00:00
6543
133ae18b61 [BugFix] Hide public repos owned by private orgs (#9609)
* Restrict AllPublic to actually public repos.
* Add new parameter to add in AllLimited Repos
2020-01-05 18:48:47 +00:00
David Svantesson
03d59bcd1d Fix access issues on milestone and issue overview pages. (#9603)
* Fix access issues on milestone and issue overview pages.

* Fix filter algorithm
2020-01-04 20:23:29 -05:00
Antoine GIRARD
8b24073713 Only serve attachments when linked to issue/release and if accessible by user (#9340)
* test: add current attachement responses

* refactor: check if attachement is linked and accessible by user

* chore: clean TODO

* fix: typo attachement -> attachment

* revert un-needed go.sum change

* refactor: move models logic to models

* fix TestCreateIssueAttachment which was wrongly successful

* fix unit tests with unittype added

* fix unit tests with changes

* use a valid uuid format for pgsql int. test

* test: add unit test TestLinkedRepository

* refactor: allow uploader to access unlinked attachement

* add missing blank line

* refactor: move to a separate function repo.GetAttachment

* typo

* test: remove err test return

* refactor: use repo perm for access checking generally + 404 for all reject
2020-01-05 01:20:08 +02:00
David Svantesson
ea707f5a77 Add branch protection option to block merge on requested changes. (#9592)
* Add branch protection option to block merge on requested changes.

* Add migration step

* Fix check to correct negation

* Apply suggestions from code review

Language improvement.

Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com>

* Copyright year.

Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-03 19:47:09 +02:00
6543
5b9283ddfe make sure Poster is loaded (#9583) 2020-01-02 07:54:22 +00:00
6543
c620eb5b2d Fix #9189 - API Allow only specific Colums to be updated on Issue (#9539)
* dont insert "-1" in any case to issue.poster_id

* Make sure API cant override importand fields

* code format

* fix lint

* WIP test

* add missing poster_id

* fix test

* user.IsGhost handle nil

* CI.restart()

* make sure no -1 is realy added

* CI.restart()

* @lunny suggestion remove some not allowed fields

* seperate issue.LoadMilestone

* load milestone and return it on IssueEdit via API

* extend Test for TestAPIEditIssue

* fix fixtures

* declare allowedColumnsUpdateIssueByAPI only once

* Update Year

* no var just write id drecty into func cal

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-01 17:51:10 -05:00
6543
9600c27085 [API] Fix 9544 | return 200 when reaction already exist (#9550)
* add ErrReactionAlreadyExist

* extend CreateReaction

* reaction already exist = 200

* extend FindReactionsOptions

* refactor swagger options/definitions

* fix swagger-validate

* Update models/error.go

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

* fix test PART1

* extend FindReactionsOptions with UserID option

* catch error on test

* fix test PART2

* format ...

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
2019-12-31 03:21:21 -05:00
zeripath
0c07f1de5b Provide Default messages for merges (#9393)
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
2019-12-30 18:34:11 -05:00
zeripath
e64880ef07 Ignore empty avatars in v115.go (#9520)
* Ignore empty avatars

* fixup! Ignore empty avatars
2019-12-28 00:57:37 +02:00
zeripath
4acca9d2e8
Properly enforce gitea environment for pushes (#9501)
#8982 attempted to enforce the gitea environment for pushes - unfortunately it tested the settings before they were actually read in - and therefore does not do that!
2019-12-27 21:15:04 +00:00
6543
f2d03cda96 [API] Extend times API (#9200)
Extensively extend the times API.

close #8833; close #8513; close #8559
2019-12-27 20:30:58 +00:00
Lunny Xiao
0bcf644da4 Fix deleted branch isn't removed when push the branch again (#9516) 2019-12-27 19:17:37 +00:00
Masudur Rahman
e3a5b83212 Fix user avatar name (#8547)
Migrate avatar names to include user ID and the md5 hash.
2019-12-27 18:27:59 +00:00
zeripath
145c1ea0b6
Remove and recreate the hooks to set them executable with the umask (#9502)
Fix #9091
2019-12-27 16:41:49 +00:00
Lunny Xiao
3d5f31f77d Fix SetExpr failed (#9506) 2019-12-27 14:18:07 +00:00
zeripath
7bfb83e064 Batch hook pre- and post-receive calls (#8602)
* make notifyWatchers work on multiple actions

* more efficient multiple notifyWatchers

* Make CommitRepoAction take advantage of multiple actions

* Batch post and pre-receive results

* Set batch to 30

* Auto adjust timeout & add logging

* adjust processing message

* Add some messages to pre-receive

* Make any non-200 status code from pre-receive an error

* Add missing hookPrintResults

* Remove shortcut for single action

* mistaken merge fix

* oops

* Move master branch to the front

* If repo was empty and the master branch is pushed ensure that that is set as the default branch

* fixup

* fixup

* Missed HookOptions in setdefaultbranch

* Batch PushUpdateAddTag and PushUpdateDelTag

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2019-12-26 13:29:45 +02:00
mrsdizzie
1df701fd1a Add ActionCommentPull action (#9456)
* Add ActionCommentPull action

Adds ActionCommentPull action to distinguish between a comment on an
issue and on a pull request

* Update modules/notification/action/action.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2019-12-22 08:29:26 +00:00
Marge Bouvier
8149ed7040 Issue with Migration rule v111 (#9449)
* Issue with Migration rule v111

I was facing some issues with migration rule v111

* Update v111.go

Fix pgsql test cases

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2019-12-21 11:12:39 +01:00
mrsdizzie
e57f763937 Add migration to sanitize repository original_url (#9423)
* Add migration to sanitize repository original_url

During a large code move in #6200 the OriginalURL field was
accidentially changed to be populated with the CloneAddr field which
will contain the username and/or password provided during a migration.

This behavior was fixed in previous PR #9097 and this migration will
remove any authentication details that were stored in the database
between those two.

* use net/url to rebuild URL instead of strings.Replace

* Update models/migrations/migrations.go

* changes per lunny

* make fmt
2019-12-19 17:49:48 +08:00
6543
6d811bcb14 Hide not allowed Reactions (#9387)
* Hide not allowed Reactions

* filter in query :D

* use `

Co-Authored-By: Alexey 〒erentyev <axifnx@gmail.com>

* update xorm v0.8.0 -> v0.8.1
2019-12-18 21:07:36 +08:00
Lunny Xiao
59fc29db38
fix wrong migration (#9381) 2019-12-17 14:58:30 +08:00
Mario Lubenka
61db834904 Change target branch for pull request (#6488)
* Adds functionality to change target branch of created pull requests

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

* Use const instead of var in JavaScript additions

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

* Check if branches are equal and if PR already exists before changing target branch

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

* Make sure to check all commits

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

* Print error messages for user as error flash message

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

* Disallow changing target branch of closed or merged pull requests

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

* Resolve conflicts after merge of upstream/master

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

* Change order of branch select fields

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

* Removes duplicate check

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

* Use ctx.Tr for translations

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

* Recompile JS

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

* Use correct translation namespace

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

* Remove redundant if condition

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

* Moves most change branch logic into pull service

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

* Completes comment

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

* Add Ref to ChangesPayload for logging changed target branches
instead of creating a new struct

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

* Revert changes to go.mod

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

* Directly use createComment method

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

* Return 404 if pull request is not found. Move written check up

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

* Remove variable declaration

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

* Return client errors on change pull request target errors

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

* Return error in commit.HasPreviousCommit

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

* Adds blank line

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

* Test patch before persisting new target branch

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

* Update patch before testing (not working)

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

* Removes patch calls when changeing pull request target

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

* Removes unneeded check for base name

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

* Moves ChangeTargetBranch completely to pull service. Update patch status.

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

* Set webhook mode after errors were validated

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

* Update PR in one transaction

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

* Move logic for check if head is equal with branch to pull model

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

* Adds missing comment and simplify return

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

* Adjust CreateComment method call

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
2019-12-16 14:20:25 +08:00
Lunny Xiao
59d6401486
Use ioutil.TmpDir for new created temp directory (#9368)
* Use os.TmpDir for new created temp directory

* fix error message
2019-12-16 13:17:55 +08:00
Lunny Xiao
43ada65571
remove unused method and rename createcommentWithNoAction (#9367) 2019-12-16 11:54:24 +08:00
Lunny Xiao
67b316a954 Refactor comment (#9330)
* Refactor comment

* fix test

* improve code
2019-12-15 16:57:34 -05:00
Brad Albright
f6b29012e0 Add /milestones endpoint (#8733)
Create a /milestones endpoint which basically serves as a dashboard view for milestones, very similar to the /issues or /pulls page.

Closes #8232
2019-12-15 14:20:08 +00:00
zeripath
3abe17f9e0
Sign protected branches (#8993)
* Move SignMerge to PullRequest

* Add approved signing mode

* As per @guillep2k comment
2019-12-15 11:06:31 +00:00
zeripath
e3c3b33ea7
Graceful: Xorm, RepoIndexer, Cron and Others (#9282)
* Change graceful to use a singleton obtained through GetManager instead of a global.
* Graceful: Make TestPullRequests shutdownable
* Graceful: Make the cron tasks graceful
* Graceful: AddTestPullRequest run in graceful ctx
* Graceful: SyncMirrors shutdown
* Graceful: SetDefaultContext for Xorm to be HammerContext
* Avoid starting graceful for migrate commands and checkout
* Graceful: DeliverHooks now can be shutdown
* Fix multiple syncing errors in modules/sync/UniqueQueue &  Make UniqueQueue closable
* Begin the process of making the repo indexer shutdown gracefully
2019-12-15 09:51:28 +00:00
Antoine GIRARD
8bea92c3dc test: command keys (#9357) 2019-12-15 08:11:31 +00:00
Lunny Xiao
ce2d488c94 Move PushToBaseRepo from models to services/pull (#9352) 2019-12-15 04:28:51 +01:00
Lunny Xiao
7b2ff82d20 Move some repository methods from models to modules/repository (#9353)
* Move some repository methods from models to modules/repository

* fix test
2019-12-14 18:30:01 +01:00
Lunny Xiao
bfcce5f86c Remove release attachments which repository has been deleted (#9334) 2019-12-13 22:30:39 -05:00
zeripath
74179d1b5e Remove SavePatch and generate patches on the fly (#9302)
* Save patches to temporary files

* Remove SavePatch and generate patches on the fly

* Use ioutil.TempDir

* fixup! Use ioutil.TempDir

* fixup! fixup! Use ioutil.TempDir

* RemoveAll LocalCopyPath() in initIntergrationTest

* Default to status checking on PR creation

* Remove unnecessary set to StatusChecking

* Protect against unable to load repo

* Handle conflicts

* Restore original conflict setting

* In TestPullRequests update status to StatusChecking before running TestPatch
2019-12-13 23:21:06 +01:00
John Olheiser
f09cdb239c Fix protected branch using IssueID (#9348)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-12-13 10:37:10 -05:00
jaqra
27f68bc96f Fix notification page panic (#9337) 2019-12-13 03:08:34 +01:00
zeripath
dc2fe9801f Make repository management section handle lfs locks (#8726)
* Make repository maangement section handle lfs locks

* Add check attribute handling and handle locking paths better

* More cleanly check-attributes

* handle error

* Check if file exists in default branch before linking to it.

* fixup

* Properly cleanPath

* Use cleanPath

* Sigh
2019-12-12 21:18:07 +08:00
Lunny Xiao
751cfb805d
Fix bug that release attachment files not deleted when deleting repository (#9322)
* Fix bug that release attachment files not deleted when deleting repository

* improve code

* add quote

* improve code
2019-12-12 13:31:05 +08:00
6543
aceb1085c7 [API] extend StopWatch (#9196)
* squash api-stopwatch

* fix prepair logic! + add Tests

* fix lint

* more robust time compare

* delete responce 202 -> 204

* change http responce in test too
2019-12-11 23:23:05 -05:00
Antoine GIRARD
c3d31e5534 refactor(models/attachement): use getAttachmentsByUUIDs (#9317) 2019-12-11 00:01:52 +00:00
Antoine GIRARD
4dc3993b22 tests: add attachement tests integration (#9309)
* tests: add attachements integration

* Update integrations/attachement_test.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
2019-12-10 19:06:48 +08:00
zeripath
d3a9c4ceec
Testing: Update postgres sequences (#9304) 2019-12-10 07:49:05 +00:00
Lunny Xiao
be06dee04c Move code indexer related code to a new package (#9191)
* move code indexer related code to a new package

* fix lint

* fix tests

* fix fmt

* GetMaxID support interface parameter
2019-12-08 14:15:35 -05:00
6543
37e10d4543 [API] Add Reactions (#9220)
* reject reactions wich ar not allowed

* dont duble check CreateReaction now throw ErrForbiddenIssueReaction

* add /repos/{owner}/{repo}/issues/comments/{id}/reactions endpoint

* add Find Functions

* fix some swagger stuff + add issue reaction endpoints + GET ReactionList now use FindReactions...

* explicite Issue Only Reaction for FindReactionsOptions with "-1" commentID

* load issue; load user ...

* return error again

* swagger def canged after LINT

* check if user has ben loaded

* add Tests

* better way of comparing results

* add suggestion

* use different issue for test
(dont interfear with integration test)

* test dont compare Location on timeCompare

* TEST: add forbidden dubble add

* add comments in code to explain

* add settings.UI.ReactionsMap
so if !setting.UI.ReactionsMap[opts.Type] works
2019-12-07 17:04:19 -05:00
Lunny Xiao
ef98b168f7
Move UpdateIssuesCommit from models to repofiles (#9276) 2019-12-07 23:52:36 +08:00
David Svantesson
9cb418e623 Redirect issue if repo has configured external tracker. (#9247)
* Redirect issue if repo has configured external tracker.

* Handle error

* Add tests for redirect

* Fix test consistency
2019-12-06 23:21:18 -05:00
Lunny Xiao
82e0383d21 Move some pull request functions from models to services (#9266)
* Move some pull request functions from models to services

* Fix test
2019-12-06 21:44:10 -05:00
Oscar Costa
1583c48e3a Show label list on label set (#9251)
* Showing the list of labels of template files #7812

* Returning and logging errors when loading labels

* Commenting public method

* Change log level in case of error loading labels.
2019-12-06 21:13:19 -05:00
Lunny Xiao
e3081c667a
Only show part of members on orgnization dashboard and add paging for orgnization members page (#9092)
* Only show part of members on orgnization dashboard and add paging for orgnization members page

* fix test

* fix typo
2019-12-06 13:34:54 +08:00
Lunny Xiao
77730db257
Move repoWorkPool outside rename/transfer repository (#9086)
* Move repoWorkPool outside rename/transfer repository

* fix import

* Fix test
2019-12-06 12:00:50 +08:00
David Svantesson
bac4b78e09 Branch protection: Possibility to not use whitelist but allow anyone with write access (#9055)
* Possibility to not use whitelist but allow anyone with write access

* fix existing test

* rename migration function

* Try to give a better name for migration step

* Clear settings if higher level setting is not set

* Move official reviews to db instead of counting approvals each time

* migration

* fix

* fix migration

* fix migration

* Remove NOT NULL from EnableWhitelist as migration isn't possible

* Fix migration, reviews are connected to issues.

* Fix SQL query issues in GetReviewersByPullID.

* Simplify function GetReviewersByIssueID

* Handle reviewers that has been deleted

* Ensure reviews for test is in a well defined order

* Only clear and set official reviews when it is an approve or reject.
2019-12-03 20:08:56 -05:00
David Svantesson
1aa7e27dd0 Change review content column to type text in db (#9229) 2019-12-02 13:32:40 -05:00
Lunny Xiao
6e81eafdd6 Remove unused comment actions (#9222)
* Remove unused comment actions

* improve code
2019-12-02 16:43:39 +02:00
6543
66028d58f9 [UI] IssuePage multi repo select (#8741)
* Make repository list @ issues/PR page persist

Will partially fix #6355

* Enable multiple selections in repo list @ issues/PR page

Part of issue #6355

* Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos.
* Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list.
*

* Remove redundant code

* Add 'All' button 

Improves functionality of the page, so that backtracking is not necessary to reset the page

* Remove redundant variable

Completely replace 'RepoID' with 'RepoIDs' and remove redundant code

* Add RepoIDs to label link

* Revert part of code to previous version to troubleshoot build failure

* Implement old and new pieces of code whilst adhering to multi select

* Attempt to join the two versions

Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests.

* Update tests to desired state

* Fix pagination implementation and tests

* Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..`
* Update tests file to reflect new functionality
* Update template with new `repos` format
* Implement new solution to show constant "total issues" count for "All" button

* Correct behavior when passing zero to array

* Comment out test url returning 404

This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out

* Comment out another test url returning 404

Last attempt, if more tests crash I will uncomment the urls and request assistance.

* Reenable tests and test fix

* Re-enable tests
* Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage
* Remove unnecessary (with multi-selection enable) code

* Drop repo from repo map and total count if permission denied

* Remove extra parenthesis

* make template work again

* find bug!

* forgot the '#' at bugfixing

* delete unused RepoID

* compile regex only one time

* make fmt

* local variable = capital letter lower

* check if repos query pattern is correct

* pagination remove last , - make regex work again

* use Replace instead of ReplaceAll; del delete

* fix test

* how did this test binary got in?!?
dont forgot the "-p" at git add * !

* dont replace -> cut fisrt & last string

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

* jet another regex

dont mind as long as it has the same result and is performatn ...

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

* dont use nonexisting repo for test

* exclude /issues?type=created_by from test

* add table to querys
use same syntax in each query (table.colum)

* add new issue for test

* dont make a workaround or something else
this need a refactor itself and is out of scope for this PR

* fix misspell

* CI.redo()

* englisch txt update

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

* add sugestions

* Tweak & Fix

* CI.restart()
2019-12-01 22:50:36 -05:00
Lunny Xiao
2011a5b818 Extract createComment (#9125)
* Extract createComment

* fix lint

* fix lint
2019-11-30 21:44:39 -05:00
6543
7c6f2e27be Add release_counter to Repo API (#9214) 2019-11-30 14:28:47 -05:00
zeripath
60c5339042 Graceful: Cancel Process on monitor pages & HammerTime (#9213)
* Graceful: Create callbacks to with contexts

* Graceful: Say when Gitea is completely finished

* Graceful: Git and Process within HammerTime

Force all git commands to terminate at HammerTime
Force all process commands to terminate at HammerTime
Move almost all git processes to run as git Commands

* Graceful: Always Hammer after Shutdown

* ProcessManager: Add cancel functionality

* Fix tests

* Make sure that process.Manager.Kill() cancels

* Make threadsafe access to Processes and remove own unused Kill

* Remove cmd from the process manager as it is no longer used

* the default context is the correct context

* get rid of double till
2019-11-30 16:40:22 +02:00
John Olheiser
15a5c10d33 Variable expansion in repository templates (#9163)
* Start expansion

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

* _template rather than .template

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

* Use ioutil

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

* Add descriptions to mapping

* Start globbing

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

* Tune globbing

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

* Re-arrange imports

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

* Don't expand git hooks

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

* Add glob tests for .giteatemplate

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

* Parse globs separately so they can be tested more easily

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

* Change template location and add docs

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

* nit

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

* Update docs/content/doc/features/gitea-directory.md

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

* Update docs/content/doc/features/gitea-directory.md

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

* Add upper-lower case match

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

* Nits

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

* Update models/repo_generate.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
2019-11-30 01:54:47 -05:00
6543
d7c1310353 expose PR counter on Repo API (#9202) 2019-11-29 23:14:24 +08:00
Lunny Xiao
e151674cfa
Move PushUpdateOptions from models to repofiles (#9124) 2019-11-29 10:21:05 +08:00
John Olheiser
62bcb2b7f1 Add avatar and issue labels to template repositories (#9149)
* Add avatar and issue labels

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

* Fix redundant if-err

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-11-25 13:17:51 +08:00
John Olheiser
e84326aaec Add git hooks and webhooks to template repositories; move to services (#8926)
* Add git hooks and webhooks to template options

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

* Update models/repo.go

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

* Add tooltip if the user can't edit git hooks

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

* Close repositories after copying git hooks

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

* Wording

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

* Restructure for services

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

* Return errors

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

* Move GenerateRepository to using a DBContext

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

* Wrap with models.WithTx

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

* Remove debug print

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

* Move if-error-delete-repo outside WithTx

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

* Return nil if no repo generated

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-11-24 12:57:52 -05:00
guillep2k
f25fd5c8eb Fix team links in HTML rendering (#9127)
* Fix team links in HTML rendering

* Fix check and lint
2019-11-24 11:34:44 -05:00
guillep2k
d779deef6e Fix show single review comments in the PR page (#9143) 2019-11-24 00:46:16 -05:00
Lunny Xiao
9856ac5818
fix race on indexer (#9136) 2019-11-23 23:03:35 +08:00
QuaSoft
7b4d2f7a2a Add single sign-on support via SSPI on Windows (#8463)
* Add single sign-on support via SSPI on Windows

* Ensure plugins implement interface

* Ensure plugins implement interface

* Move functions used only by the SSPI auth method to sspi_windows.go

* Field SSPISeparatorReplacement of AuthenticationForm should not be required via binding, as binding will insist the field is non-empty even if another login type is selected

* Fix breaking of oauth authentication on download links. Do not create new session with SSPI authentication on download links.

* Update documentation for the new 'SPNEGO with SSPI' login source

* Mention in documentation that ROOT_URL should contain the FQDN of the server

* Make sure that Contexter is not checking for active login sources when the ORM engine is not initialized (eg. when installing)

* Always initialize and free SSO methods, even if they are not enabled, as a method can be activated while the app is running (from Authentication sources)

* Add option in SSPIConfig for removing of domains from logon names

* Update helper text for StripDomainNames option

* Make sure handleSignIn() is called after a new user object is created by SSPI auth method

* Remove default value from text of form field helper

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

* Remove default value from text of form field helper

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

* Remove default value from text of form field helper

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

* Only make a query to the DB to check if SSPI is enabled on handlers that need that information for templates

* Remove code duplication

* Log errors in ActiveLoginSources

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

* Revert suffix of randomly generated E-mails for Reverse proxy authentication

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

* Revert unneeded white-space change in template

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

* Add copyright comments at the top of new files

* Use loopback name for randomly generated emails

* Add locale tag for the SSPISeparatorReplacement field with proper casing

* Revert casing of SSPISeparatorReplacement field in locale file, moving it up, next to other form fields

* Update docs/content/doc/features/authentication.en-us.md

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

* Remove Priority() method and define the order in which SSO auth methods should be executed in one place

* Log authenticated username only if it's not empty

* Rephrase helper text for automatic creation of users

* Return error if more than one active SSPI auth source is found

* Change newUser() function to return error, letting caller log/handle the error

* Move isPublicResource, isPublicPage and handleSignIn functions outside SSPI auth method to allow other SSO methods to reuse them if needed

* Refactor initialization of the list containing SSO auth methods

* Validate SSPI settings on POST

* Change SSPI to only perform authentication on its own login page, API paths and download links. Leave Toggle middleware to redirect non authenticated users to login page

* Make 'Default language' in SSPI config empty, unless changed by admin

* Show error if admin tries to add a second authentication source of type SSPI

* Simplify declaration of global variable

* Rebuild gitgraph.js on Linux

* Make sure config values containing only whitespace are not accepted
2019-11-23 01:33:31 +02:00
zeripath
cbaa1de9ec Add Graceful shutdown for Windows and hooks for shutdown of goroutines (#8964)
* Graceful Shutdown for windows and others

Restructures modules/graceful, adding shutdown for windows, removing and
replacing the old minwinsvc code.

Creates a new waitGroup - terminate which allows for goroutines to
finish up after the shutdown of the servers.

Shutdown and terminate hooks are added for goroutines.

* Remove unused functions - these can be added in a different PR

* Add startup timeout functionality

* Document STARTUP_TIMEOUT
2019-11-21 13:32:02 -05:00
Lunny Xiao
d7ac9727bb Move merge actions to notification (#9024)
* Move merge actions to notification

* Add missing mail notification
2019-11-21 12:08:42 -05:00
Jordan
1615b3c187 Hide given credentials for migrated repos. (#9097)
CloneAddr was being saved as OriginalURL.

Now passing OriginalURL through from the form and
saving it in it's place
2019-11-20 13:01:09 -05:00
6543
2ab8c78c30 Refactor Issues Subscription (#8738)
* FIX: getIssueWatchers() get only aktive suscriber

* save query to work later with it or not ...

* fix test + add new case

* corect tests + GetIssueWatch

* API issue_subscripton: Put/Delete require tocken

* remove redundant code

* swagger specify return value

* remove unused binding

* remove note
because I'll implement this in a different way and in another PR

* ID should be unique!

* use xorm session

* Revert "use xorm session"

This reverts commit c1de540147.

* better test code
* more acurate comments
* use assert.False/True instead of Equal

* use more assert methodes
2019-11-20 22:50:54 +08:00
David Svantesson
69a255defb Team permission to create repository in organization (#8312)
* Add team permission setting to allow creating repo in organization.

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

* Add test case for creating repo when have team creation access.

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

* build error: should omit comparison to bool constant

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

* Add comment on exported functions

* Fix fixture consistency, fix existing unit tests

* Fix boolean comparison in xorm query.

* addCollaborator and changeCollaborationAccessMode separate steps

More clear to use different if-cases.

* Create and commit xorm session

* fix

* Add information of create repo permission in team sidebar

* Add migration step

* Clarify that repository creator will be administrator.

* Fix some things after merge

* Fix language text that use html

* migrations file

* Create repository permission -> Create repositories

* fix merge

* fix review comments
2019-11-20 19:27:49 +08:00
guillep2k
2c2b9718e6 Avoid re-issuing redundant cross-references. (#8734)
* Avoid re-issuing redundant cross-references.

* Remove unused func; fix lint

* Simplify code as suggested by @laftriks

* Update test
2019-11-19 01:43:03 +02:00
Antoine GIRARD
f128e06ea6 fix: add search to reserved usernames (#9063)
* fix: add search to reserved usernames

* Update integrations/user_test.go

Co-Authored-By: 6543 <24977596+6543@users.noreply.github.com>
2019-11-18 15:03:25 -05:00
guillep2k
64769c8a6b Allow authors to use act keywords in PR content (#9059) 2019-11-18 19:03:49 +02:00
guillep2k
b15f26b1cf Close/reopen issues by keywords in titles and comments (#8866)
* Add close/reopen from comment functionality

* Fix comment

* Rewrite closing/reopening template

* Check xref permissions, move action to services/pull

* Fix RefIsPull field

* Add xref tests

* Fix xref unique filter

* Only highlight keywords for actionable xrefs

* Fix xref neuter filter

* Fix check return status

* Restart CI
2019-11-18 15:13:07 +02:00
guillep2k
08ae6bb7ed Rewrite delivery of issue and comment mails (#9009)
* Mail issue subscribers, rework the function

* Simplify a little more

* Fix unused variable

* Refactor mail delivery to avoid heavy load on server

* Avoid splitting into too many goroutines

* Fix comments and optimize GetMaileableUsersByIDs()

* Fix return on errors
2019-11-18 08:08:20 +00:00
David Svantesson
86cff86b46 Update branch API endpoint to show effective branch protection. (#9031)
* Add API endpoint for displaying effective branch protection.

* Add status checks.
2019-11-16 19:39:18 +00:00
Lunny Xiao
11208f3381
Move git graph from models to modules/graph (#9027) 2019-11-16 08:47:57 +08:00
Lunny Xiao
e0e4473172 extract some inline functions related with create comment (#8931) 2019-11-15 18:18:09 +00:00
guillep2k
c58fba944d Fix permission checks for close/reopen from commit (#8875)
* Fix checks for close/reopen from commit

* Fix permission order
2019-11-15 15:20:47 +00:00
guillep2k
9930d47be2 Add review comments to mail notifications (#8996) 2019-11-15 12:59:21 +00:00
Lunny Xiao
21ae9838e0
Move transfer repository and rename repository on a service package and start action notification (#8573)
* move transfer repository and rename repository on a service package and start action notification

* remove unused codes

* fix lint

* fix bugs

* fix test

* fix test

* fix test

* fix lint

* update go mod and sum
2019-11-15 16:06:11 +08:00
John Olheiser
06a8504c78 Update dashboard context for PR reviews (#8995)
* Update dashboard context for PR reviews

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

* Update options/locale/locale_en-US.ini

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

* Only append head action if it has content or is approval/rejection

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

* Update options/locale/locale_en-US.ini

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
2019-11-15 00:52:18 +01:00
John Olheiser
4b5ebb93e4 New review approvals shouldn't require a message (#8991)
* New approvals don't require content

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

* Fix edge-bug

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-11-14 20:58:01 +00:00
6543
665ce1dcb3 Drop Admin attribute based on LDAP when login (continue #1743) (#8849)
* Update User information in Gitea based on LDAP when login

* Update Admin Flag only if exist in settings

* Fix affectation

* Update models/login_source.go

Co-Authored-By: JustKiddingCode <JustKiddingCode@users.noreply.github.com>

* Better ident

* Apply suggestions from code review

Update user information

Co-Authored-By: 6543 <24977596+6543@users.noreply.github.com>

* Make fmt

* add err handling

* if user exist but login is Prohibit return return nil, and Prohibit err

* keep login speed

* User sync is implemented at #1478 - so only make sure that admin acces is drpoed if changed

* handle error and still use async task

* no async

* only update admin if Sync is enabled

* update two comments

* add lafriks suggestions

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

* if adminFilter is set - use it

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

* Update models/login_source.go

well - I should look more detaild at suggestions :D

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

* make it work again

* set is_admin value to user

* look nicer
2019-11-14 19:10:23 +00:00
Lunny Xiao
dad67cae54
Refactor pull request review (#8954)
* refactor submit review

* remove unnecessary code

* remove unused comment

* fix lint

* remove duplicated actions

* remove duplicated actions

* fix typo

* fix comment content
2019-11-14 10:57:36 +08:00
zeripath
722a7c902d
Add Close() method to gogitRepository (#8901)
In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.

This PR adds this Close function and adds the Close functions as necessary.

In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.

Fixes #7947
2019-11-13 07:01:19 +00:00
Lunny Xiao
bb6879d339
Improve notification (#8835)
* Improve notifications

* batch load user

* Update notification only when read

* Fix reorder

* fix lint

* fix test

* fix lint

* make function meaningful

* fix comment
2019-11-12 16:33:34 +08:00
John Olheiser
74a6add4d9 Template Repositories (#8768)
* Start work on templates

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

* Continue work

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

* Fix IsTemplate vs IsGenerated

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

* Fix tabs vs spaces

* Tabs vs Spaces

* Add templates to API & start adding tests

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

* Fix integration tests

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

* Remove unused User

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

* Move template tests to existing repos

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

* Minor re-check updates and cleanup

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

* make fmt

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

* Test cleanup

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

* Fix optionalbool

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

* make fmt

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

* Test fixes and icon change

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

* Add new user and repo for tests

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

* Fix tests (finally)

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

* Update meta repo with env variables

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

* Move generation to create page

Combine with repo create template
Modify API search to prioritize owner for repo

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

* Fix tests and coverage

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

* Fix swagger and JS lint

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

* Fix API searching for own private repos

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

* Change wording

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

* Fix repo search test. User had a private repo that didn't show up

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

* Another search test fix

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

* Clarify git content

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

* Feedback updates

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

* Add topics WIP

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

* Finish adding topics

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

* Update locale

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2019-11-11 23:15:29 +08:00
Lunny Xiao
273a24f226
Move notifywatchers from models to notification (#8907) 2019-11-11 11:39:41 +08:00
zeripath
ee1d64ddd1
Stop using git count-objects and use raw directory size for repository (#8848)
* Migrate from git count-objects to a raw directory size
* As per @guillep2k ignore unusual files
2019-11-10 21:33:47 +00:00
guillep2k
01a4a7cb14 Auto-subscribe user to repository when they commit/tag to it (#7657)
* Add support for AUTO_WATCH_ON_CHANGES and AUTO_WATCH_ON_CLONE

* Update models/repo_watch.go

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

* Round up changes suggested by lafriks

* Added changes suggested from automated tests

* Updated deleteUser to take RepoWatchModeDont into account, corrected inverted DefaultWatchOnClone and DefaultWatchOnChanges behaviour, updated and added tests.

* Reinsert import "github.com/Unknwon/com" on http.go

* Add migration for new column `watch`.`mode`

* Remove serv code

* Remove WATCH_ON_CLONE; use hooks, add integrations

* Renamed watch_test.go to repo_watch_test.go

* Correct fmt

* Add missing EOL

* Correct name of test function

* Reword cheat and ini descriptions

* Add update to migration to ensure column value

* Clarify comment

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

* Simplify if condition
2019-11-10 09:22:19 +00:00
zeripath
8eeb2877d5
Adjust error reporting from merge failures and use LC_ALL=C for git (#8548)
There are two major components to this PR:

* This PR handles merge and rebase failures from merging a little more nicely with Flash errors rather a 500.
* All git commands are run in the LC_ALL="C" environment to ensure that error messages are in English. This DefaultLocale is defined in a way that if necessary (due to platform weirdness) it can be overridden at build time using LDFLAGS="-X "code.gitea.io/gitea/modules/git.DefaultLocale=C"" with C changed for the locale as necessary.
2019-11-10 08:42:51 +00:00
6543
31416a5f4e Fix API Bug (fail on empty assignees) (#8873)
* keep sure if assigneeIDs == nil -> do nothing

* fix #8872

* Revert "keep sure if assigneeIDs == nil -> do nothing"

-> go handle it itself preaty well

This reverts commit e72d94129c.

* clarity comparson

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

* simplify

* Update models/issue_assignees.go

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

* Update issue_assignees.go

* simplify more

* add --if oneAssignee != ""-- again

* Update models/issue_assignees.go

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

* CI.restart()

* Update issue_assignees.go

* add Test for GetUserIDsByNames

* add Test for MakeIDsFromAPIAssigneesToAdd

* fix test
2019-11-10 16:07:21 +08:00
guillep2k
a647a54a08 Leave non-dated issues for last (#8871) 2019-11-09 13:09:01 +00:00