You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

issue.go 44 kB

11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
Improve listing performance by using go-git (#6478) * Use go-git for tree reading and commit info lookup. Signed-off-by: Filip Navara <navara@emclient.com> * Use TreeEntry.IsRegular() instead of ObjectType that was removed. Signed-off-by: Filip Navara <navara@emclient.com> * Use the treePath to optimize commit info search. Signed-off-by: Filip Navara <navara@emclient.com> * Extract the latest commit at treePath along with the other commits. Signed-off-by: Filip Navara <navara@emclient.com> * Fix listing commit info for a directory that was created in one commit and never modified after. Signed-off-by: Filip Navara <navara@emclient.com> * Avoid nearly all external 'git' invocations when doing directory listing (.editorconfig code path is still hit). Signed-off-by: Filip Navara <navara@emclient.com> * Use go-git for reading blobs. Signed-off-by: Filip Navara <navara@emclient.com> * Make SHA1 type alias for plumbing.Hash in go-git. Signed-off-by: Filip Navara <navara@emclient.com> * Make Signature type alias for object.Signature in go-git. Signed-off-by: Filip Navara <navara@emclient.com> * Fix GetCommitsInfo for repository with only one commit. Signed-off-by: Filip Navara <navara@emclient.com> * Fix PGP signature verification. Signed-off-by: Filip Navara <navara@emclient.com> * Fix issues with walking commit graph across merges. Signed-off-by: Filip Navara <navara@emclient.com> * Fix typo in condition. Signed-off-by: Filip Navara <navara@emclient.com> * Speed up loading branch list by keeping the repository reference (and thus all the loaded packfile indexes). Signed-off-by: Filip Navara <navara@emclient.com> * Fix lising submodules. Signed-off-by: Filip Navara <navara@emclient.com> * Fix build Signed-off-by: Filip Navara <navara@emclient.com> * Add back commit cache because of name-rev Signed-off-by: Filip Navara <navara@emclient.com> * Fix tests Signed-off-by: Filip Navara <navara@emclient.com> * Fix code style * Fix spelling * Address PR feedback Signed-off-by: Filip Navara <navara@emclient.com> * Update vendor module list Signed-off-by: Filip Navara <navara@emclient.com> * Fix getting trees by commit id Signed-off-by: Filip Navara <navara@emclient.com> * Fix remaining unit test failures * Fix GetTreeBySHA * Avoid running `git name-rev` if not necessary Signed-off-by: Filip Navara <navara@emclient.com> * Move Branch code to git module * Clean up GPG signature verification and fix it for tagged commits * Address PR feedback (import formatting, copyright headers) * Make blob lookup by SHA working * Update tests to use public API * Allow getting content from any type of object through the blob interface * Change test to actually expect the object content that is in the GIT repository * Change one more test to actually expect the object content that is in the GIT repository * Add comments
6 years ago
Improve listing performance by using go-git (#6478) * Use go-git for tree reading and commit info lookup. Signed-off-by: Filip Navara <navara@emclient.com> * Use TreeEntry.IsRegular() instead of ObjectType that was removed. Signed-off-by: Filip Navara <navara@emclient.com> * Use the treePath to optimize commit info search. Signed-off-by: Filip Navara <navara@emclient.com> * Extract the latest commit at treePath along with the other commits. Signed-off-by: Filip Navara <navara@emclient.com> * Fix listing commit info for a directory that was created in one commit and never modified after. Signed-off-by: Filip Navara <navara@emclient.com> * Avoid nearly all external 'git' invocations when doing directory listing (.editorconfig code path is still hit). Signed-off-by: Filip Navara <navara@emclient.com> * Use go-git for reading blobs. Signed-off-by: Filip Navara <navara@emclient.com> * Make SHA1 type alias for plumbing.Hash in go-git. Signed-off-by: Filip Navara <navara@emclient.com> * Make Signature type alias for object.Signature in go-git. Signed-off-by: Filip Navara <navara@emclient.com> * Fix GetCommitsInfo for repository with only one commit. Signed-off-by: Filip Navara <navara@emclient.com> * Fix PGP signature verification. Signed-off-by: Filip Navara <navara@emclient.com> * Fix issues with walking commit graph across merges. Signed-off-by: Filip Navara <navara@emclient.com> * Fix typo in condition. Signed-off-by: Filip Navara <navara@emclient.com> * Speed up loading branch list by keeping the repository reference (and thus all the loaded packfile indexes). Signed-off-by: Filip Navara <navara@emclient.com> * Fix lising submodules. Signed-off-by: Filip Navara <navara@emclient.com> * Fix build Signed-off-by: Filip Navara <navara@emclient.com> * Add back commit cache because of name-rev Signed-off-by: Filip Navara <navara@emclient.com> * Fix tests Signed-off-by: Filip Navara <navara@emclient.com> * Fix code style * Fix spelling * Address PR feedback Signed-off-by: Filip Navara <navara@emclient.com> * Update vendor module list Signed-off-by: Filip Navara <navara@emclient.com> * Fix getting trees by commit id Signed-off-by: Filip Navara <navara@emclient.com> * Fix remaining unit test failures * Fix GetTreeBySHA * Avoid running `git name-rev` if not necessary Signed-off-by: Filip Navara <navara@emclient.com> * Move Branch code to git module * Clean up GPG signature verification and fix it for tagged commits * Address PR feedback (import formatting, copyright headers) * Make blob lookup by SHA working * Update tests to use public API * Allow getting content from any type of object through the blob interface * Change test to actually expect the object content that is in the GIT repository * Change one more test to actually expect the object content that is in the GIT repository * Add comments
6 years ago
9 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
9 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
8 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
6 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
6 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
6 years ago
Better logging (#6038) (#6095) * Panic don't fatal on create new logger Fixes #5854 Signed-off-by: Andrew Thornton <art27@cantab.net> * partial broken * Update the logging infrastrcture Signed-off-by: Andrew Thornton <art27@cantab.net> * Reset the skip levels for Fatal and Error Signed-off-by: Andrew Thornton <art27@cantab.net> * broken ncsa * More log.Error fixes Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove nal * set log-levels to lowercase * Make console_test test all levels * switch to lowercased levels * OK now working * Fix vetting issues * Fix lint * Fix tests * change default logging to match current gitea * Improve log testing Signed-off-by: Andrew Thornton <art27@cantab.net> * reset error skip levels to 0 * Update documentation and access logger configuration * Redirect the router log back to gitea if redirect macaron log but also allow setting the log level - i.e. TRACE * Fix broken level caching * Refactor the router log * Add Router logger * Add colorizing options * Adjust router colors * Only create logger if they will be used * update app.ini.sample * rename Attribute ColorAttribute * Change from white to green for function * Set fatal/error levels * Restore initial trace logger * Fix Trace arguments in modules/auth/auth.go * Properly handle XORMLogger * Improve admin/config page * fix fmt * Add auto-compression of old logs * Update error log levels * Remove the unnecessary skip argument from Error, Fatal and Critical * Add stacktrace support * Fix tests * Remove x/sync from vendors? * Add stderr option to console logger * Use filepath.ToSlash to protect against Windows in tests * Remove prefixed underscores from names in colors.go * Remove not implemented database logger This was removed from Gogs on 4 Mar 2016 but left in the configuration since then. * Ensure that log paths are relative to ROOT_PATH * use path.Join * rename jsonConfig to logConfig * Rename "config" to "jsonConfig" to make it clearer * Requested changes * Requested changes: XormLogger * Try to color the windows terminal If successful default to colorizing the console logs * fixup * Colorize initially too * update vendor * Colorize logs on default and remove if this is not a colorizing logger * Fix documentation * fix test * Use go-isatty to detect if on windows we are on msys or cygwin * Fix spelling mistake * Add missing vendors * More changes * Rationalise the ANSI writer protection * Adjust colors on advice from @0x5c * Make Flags a comma separated list * Move to use the windows constant for ENABLE_VIRTUAL_TERMINAL_PROCESSING * Ensure matching is done on the non-colored message - to simpify EXPRESSION
6 years ago
Better logging (#6038) (#6095) * Panic don't fatal on create new logger Fixes #5854 Signed-off-by: Andrew Thornton <art27@cantab.net> * partial broken * Update the logging infrastrcture Signed-off-by: Andrew Thornton <art27@cantab.net> * Reset the skip levels for Fatal and Error Signed-off-by: Andrew Thornton <art27@cantab.net> * broken ncsa * More log.Error fixes Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove nal * set log-levels to lowercase * Make console_test test all levels * switch to lowercased levels * OK now working * Fix vetting issues * Fix lint * Fix tests * change default logging to match current gitea * Improve log testing Signed-off-by: Andrew Thornton <art27@cantab.net> * reset error skip levels to 0 * Update documentation and access logger configuration * Redirect the router log back to gitea if redirect macaron log but also allow setting the log level - i.e. TRACE * Fix broken level caching * Refactor the router log * Add Router logger * Add colorizing options * Adjust router colors * Only create logger if they will be used * update app.ini.sample * rename Attribute ColorAttribute * Change from white to green for function * Set fatal/error levels * Restore initial trace logger * Fix Trace arguments in modules/auth/auth.go * Properly handle XORMLogger * Improve admin/config page * fix fmt * Add auto-compression of old logs * Update error log levels * Remove the unnecessary skip argument from Error, Fatal and Critical * Add stacktrace support * Fix tests * Remove x/sync from vendors? * Add stderr option to console logger * Use filepath.ToSlash to protect against Windows in tests * Remove prefixed underscores from names in colors.go * Remove not implemented database logger This was removed from Gogs on 4 Mar 2016 but left in the configuration since then. * Ensure that log paths are relative to ROOT_PATH * use path.Join * rename jsonConfig to logConfig * Rename "config" to "jsonConfig" to make it clearer * Requested changes * Requested changes: XormLogger * Try to color the windows terminal If successful default to colorizing the console logs * fixup * Colorize initially too * update vendor * Colorize logs on default and remove if this is not a colorizing logger * Fix documentation * fix test * Use go-isatty to detect if on windows we are on msys or cygwin * Fix spelling mistake * Add missing vendors * More changes * Rationalise the ANSI writer protection * Adjust colors on advice from @0x5c * Make Flags a comma separated list * Move to use the windows constant for ENABLE_VIRTUAL_TERMINAL_PROCESSING * Ensure matching is done on the non-colored message - to simpify EXPRESSION
6 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
9 years ago
9 years ago
Better logging (#6038) (#6095) * Panic don't fatal on create new logger Fixes #5854 Signed-off-by: Andrew Thornton <art27@cantab.net> * partial broken * Update the logging infrastrcture Signed-off-by: Andrew Thornton <art27@cantab.net> * Reset the skip levels for Fatal and Error Signed-off-by: Andrew Thornton <art27@cantab.net> * broken ncsa * More log.Error fixes Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove nal * set log-levels to lowercase * Make console_test test all levels * switch to lowercased levels * OK now working * Fix vetting issues * Fix lint * Fix tests * change default logging to match current gitea * Improve log testing Signed-off-by: Andrew Thornton <art27@cantab.net> * reset error skip levels to 0 * Update documentation and access logger configuration * Redirect the router log back to gitea if redirect macaron log but also allow setting the log level - i.e. TRACE * Fix broken level caching * Refactor the router log * Add Router logger * Add colorizing options * Adjust router colors * Only create logger if they will be used * update app.ini.sample * rename Attribute ColorAttribute * Change from white to green for function * Set fatal/error levels * Restore initial trace logger * Fix Trace arguments in modules/auth/auth.go * Properly handle XORMLogger * Improve admin/config page * fix fmt * Add auto-compression of old logs * Update error log levels * Remove the unnecessary skip argument from Error, Fatal and Critical * Add stacktrace support * Fix tests * Remove x/sync from vendors? * Add stderr option to console logger * Use filepath.ToSlash to protect against Windows in tests * Remove prefixed underscores from names in colors.go * Remove not implemented database logger This was removed from Gogs on 4 Mar 2016 but left in the configuration since then. * Ensure that log paths are relative to ROOT_PATH * use path.Join * rename jsonConfig to logConfig * Rename "config" to "jsonConfig" to make it clearer * Requested changes * Requested changes: XormLogger * Try to color the windows terminal If successful default to colorizing the console logs * fixup * Colorize initially too * update vendor * Colorize logs on default and remove if this is not a colorizing logger * Fix documentation * fix test * Use go-isatty to detect if on windows we are on msys or cygwin * Fix spelling mistake * Add missing vendors * More changes * Rationalise the ANSI writer protection * Adjust colors on advice from @0x5c * Make Flags a comma separated list * Move to use the windows constant for ENABLE_VIRTUAL_TERMINAL_PROCESSING * Ensure matching is done on the non-colored message - to simpify EXPRESSION
6 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
6 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package repo
  6. import (
  7. "bytes"
  8. "errors"
  9. "fmt"
  10. "io/ioutil"
  11. "net/http"
  12. "strconv"
  13. "strings"
  14. "code.gitea.io/gitea/models"
  15. "code.gitea.io/gitea/modules/auth"
  16. "code.gitea.io/gitea/modules/base"
  17. "code.gitea.io/gitea/modules/context"
  18. "code.gitea.io/gitea/modules/git"
  19. issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
  20. "code.gitea.io/gitea/modules/log"
  21. "code.gitea.io/gitea/modules/markup/markdown"
  22. "code.gitea.io/gitea/modules/notification"
  23. "code.gitea.io/gitea/modules/setting"
  24. api "code.gitea.io/gitea/modules/structs"
  25. "code.gitea.io/gitea/modules/util"
  26. "github.com/unknwon/com"
  27. )
  28. const (
  29. tplIssues base.TplName = "repo/issue/list"
  30. tplIssueNew base.TplName = "repo/issue/new"
  31. tplIssueView base.TplName = "repo/issue/view"
  32. tplReactions base.TplName = "repo/issue/view_content/reactions"
  33. issueTemplateKey = "IssueTemplate"
  34. )
  35. var (
  36. // ErrTooManyFiles upload too many files
  37. ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
  38. // IssueTemplateCandidates issue templates
  39. IssueTemplateCandidates = []string{
  40. "ISSUE_TEMPLATE.md",
  41. "issue_template.md",
  42. ".gitea/ISSUE_TEMPLATE.md",
  43. ".gitea/issue_template.md",
  44. ".github/ISSUE_TEMPLATE.md",
  45. ".github/issue_template.md",
  46. }
  47. )
  48. // MustAllowUserComment checks to make sure if an issue is locked.
  49. // If locked and user has permissions to write to the repository,
  50. // then the comment is allowed, else it is blocked
  51. func MustAllowUserComment(ctx *context.Context) {
  52. issue := GetActionIssue(ctx)
  53. if ctx.Written() {
  54. return
  55. }
  56. if issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) && !ctx.User.IsAdmin {
  57. ctx.Flash.Error(ctx.Tr("repo.issues.comment_on_locked"))
  58. ctx.Redirect(issue.HTMLURL())
  59. return
  60. }
  61. }
  62. // MustEnableIssues check if repository enable internal issues
  63. func MustEnableIssues(ctx *context.Context) {
  64. if !ctx.Repo.CanRead(models.UnitTypeIssues) &&
  65. !ctx.Repo.CanRead(models.UnitTypeExternalTracker) {
  66. ctx.NotFound("MustEnableIssues", nil)
  67. return
  68. }
  69. unit, err := ctx.Repo.Repository.GetUnit(models.UnitTypeExternalTracker)
  70. if err == nil {
  71. ctx.Redirect(unit.ExternalTrackerConfig().ExternalTrackerURL)
  72. return
  73. }
  74. }
  75. // MustAllowPulls check if repository enable pull requests and user have right to do that
  76. func MustAllowPulls(ctx *context.Context) {
  77. if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(models.UnitTypePullRequests) {
  78. ctx.NotFound("MustAllowPulls", nil)
  79. return
  80. }
  81. // User can send pull request if owns a forked repository.
  82. if ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID) {
  83. ctx.Repo.PullRequest.Allowed = true
  84. ctx.Repo.PullRequest.HeadInfo = ctx.User.Name + ":" + ctx.Repo.BranchName
  85. }
  86. }
  87. func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalBool) {
  88. var err error
  89. viewType := ctx.Query("type")
  90. sortType := ctx.Query("sort")
  91. types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned"}
  92. if !com.IsSliceContainsStr(types, viewType) {
  93. viewType = "all"
  94. }
  95. var (
  96. assigneeID = ctx.QueryInt64("assignee")
  97. posterID int64
  98. mentionedID int64
  99. forceEmpty bool
  100. )
  101. if ctx.IsSigned {
  102. switch viewType {
  103. case "created_by":
  104. posterID = ctx.User.ID
  105. case "mentioned":
  106. mentionedID = ctx.User.ID
  107. }
  108. }
  109. repo := ctx.Repo.Repository
  110. var labelIDs []int64
  111. selectLabels := ctx.Query("labels")
  112. if len(selectLabels) > 0 && selectLabels != "0" {
  113. labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
  114. if err != nil {
  115. ctx.ServerError("StringsToInt64s", err)
  116. return
  117. }
  118. }
  119. isShowClosed := ctx.Query("state") == "closed"
  120. keyword := strings.Trim(ctx.Query("q"), " ")
  121. if bytes.Contains([]byte(keyword), []byte{0x00}) {
  122. keyword = ""
  123. }
  124. var issueIDs []int64
  125. if len(keyword) > 0 {
  126. issueIDs, err = issue_indexer.SearchIssuesByKeyword(repo.ID, keyword)
  127. if err != nil {
  128. ctx.ServerError("issueIndexer.Search", err)
  129. return
  130. }
  131. if len(issueIDs) == 0 {
  132. forceEmpty = true
  133. }
  134. }
  135. var issueStats *models.IssueStats
  136. if forceEmpty {
  137. issueStats = &models.IssueStats{}
  138. } else {
  139. issueStats, err = models.GetIssueStats(&models.IssueStatsOptions{
  140. RepoID: repo.ID,
  141. Labels: selectLabels,
  142. MilestoneID: milestoneID,
  143. AssigneeID: assigneeID,
  144. MentionedID: mentionedID,
  145. PosterID: posterID,
  146. IsPull: isPullOption,
  147. IssueIDs: issueIDs,
  148. })
  149. if err != nil {
  150. ctx.ServerError("GetIssueStats", err)
  151. return
  152. }
  153. }
  154. page := ctx.QueryInt("page")
  155. if page <= 1 {
  156. page = 1
  157. }
  158. var total int
  159. if !isShowClosed {
  160. total = int(issueStats.OpenCount)
  161. } else {
  162. total = int(issueStats.ClosedCount)
  163. }
  164. pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, 5)
  165. var issues []*models.Issue
  166. if forceEmpty {
  167. issues = []*models.Issue{}
  168. } else {
  169. issues, err = models.Issues(&models.IssuesOptions{
  170. RepoIDs: []int64{repo.ID},
  171. AssigneeID: assigneeID,
  172. PosterID: posterID,
  173. MentionedID: mentionedID,
  174. MilestoneID: milestoneID,
  175. Page: pager.Paginater.Current(),
  176. PageSize: setting.UI.IssuePagingNum,
  177. IsClosed: util.OptionalBoolOf(isShowClosed),
  178. IsPull: isPullOption,
  179. LabelIDs: labelIDs,
  180. SortType: sortType,
  181. IssueIDs: issueIDs,
  182. })
  183. if err != nil {
  184. ctx.ServerError("Issues", err)
  185. return
  186. }
  187. }
  188. var commitStatus = make(map[int64]*models.CommitStatus, len(issues))
  189. // Get posters.
  190. for i := range issues {
  191. // Check read status
  192. if !ctx.IsSigned {
  193. issues[i].IsRead = true
  194. } else if err = issues[i].GetIsRead(ctx.User.ID); err != nil {
  195. ctx.ServerError("GetIsRead", err)
  196. return
  197. }
  198. if issues[i].IsPull {
  199. if err := issues[i].LoadPullRequest(); err != nil {
  200. ctx.ServerError("LoadPullRequest", err)
  201. return
  202. }
  203. commitStatus[issues[i].PullRequest.ID], _ = issues[i].PullRequest.GetLastCommitStatus()
  204. }
  205. }
  206. ctx.Data["Issues"] = issues
  207. ctx.Data["CommitStatus"] = commitStatus
  208. // Get assignees.
  209. ctx.Data["Assignees"], err = repo.GetAssignees()
  210. if err != nil {
  211. ctx.ServerError("GetAssignees", err)
  212. return
  213. }
  214. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  215. if err != nil {
  216. ctx.ServerError("GetLabelsByRepoID", err)
  217. return
  218. }
  219. for _, l := range labels {
  220. l.LoadSelectedLabelsAfterClick(labelIDs)
  221. }
  222. ctx.Data["Labels"] = labels
  223. ctx.Data["NumLabels"] = len(labels)
  224. if ctx.QueryInt64("assignee") == 0 {
  225. assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
  226. }
  227. ctx.Data["IssueStats"] = issueStats
  228. ctx.Data["SelectLabels"] = com.StrTo(selectLabels).MustInt64()
  229. ctx.Data["ViewType"] = viewType
  230. ctx.Data["SortType"] = sortType
  231. ctx.Data["MilestoneID"] = milestoneID
  232. ctx.Data["AssigneeID"] = assigneeID
  233. ctx.Data["IsShowClosed"] = isShowClosed
  234. ctx.Data["Keyword"] = keyword
  235. if isShowClosed {
  236. ctx.Data["State"] = "closed"
  237. } else {
  238. ctx.Data["State"] = "open"
  239. }
  240. pager.AddParam(ctx, "q", "Keyword")
  241. pager.AddParam(ctx, "type", "ViewType")
  242. pager.AddParam(ctx, "sort", "SortType")
  243. pager.AddParam(ctx, "state", "State")
  244. pager.AddParam(ctx, "labels", "SelectLabels")
  245. pager.AddParam(ctx, "milestone", "MilestoneID")
  246. pager.AddParam(ctx, "assignee", "AssigneeID")
  247. ctx.Data["Page"] = pager
  248. }
  249. // Issues render issues page
  250. func Issues(ctx *context.Context) {
  251. isPullList := ctx.Params(":type") == "pulls"
  252. if isPullList {
  253. MustAllowPulls(ctx)
  254. if ctx.Written() {
  255. return
  256. }
  257. ctx.Data["Title"] = ctx.Tr("repo.pulls")
  258. ctx.Data["PageIsPullList"] = true
  259. } else {
  260. MustEnableIssues(ctx)
  261. if ctx.Written() {
  262. return
  263. }
  264. ctx.Data["Title"] = ctx.Tr("repo.issues")
  265. ctx.Data["PageIsIssueList"] = true
  266. }
  267. issues(ctx, ctx.QueryInt64("milestone"), util.OptionalBoolOf(isPullList))
  268. var err error
  269. // Get milestones.
  270. ctx.Data["Milestones"], err = models.GetMilestonesByRepoID(ctx.Repo.Repository.ID, api.StateType(ctx.Query("state")))
  271. if err != nil {
  272. ctx.ServerError("GetAllRepoMilestones", err)
  273. return
  274. }
  275. perm, err := models.GetUserRepoPermission(ctx.Repo.Repository, ctx.User)
  276. if err != nil {
  277. ctx.ServerError("GetUserRepoPermission", err)
  278. return
  279. }
  280. ctx.Data["CanWriteIssuesOrPulls"] = perm.CanWriteIssuesOrPulls(isPullList)
  281. ctx.HTML(200, tplIssues)
  282. }
  283. // RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
  284. func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repository) {
  285. var err error
  286. ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false, "")
  287. if err != nil {
  288. ctx.ServerError("GetMilestones", err)
  289. return
  290. }
  291. ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true, "")
  292. if err != nil {
  293. ctx.ServerError("GetMilestones", err)
  294. return
  295. }
  296. ctx.Data["Assignees"], err = repo.GetAssignees()
  297. if err != nil {
  298. ctx.ServerError("GetAssignees", err)
  299. return
  300. }
  301. }
  302. // RetrieveRepoMetas find all the meta information of a repository
  303. func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.Label {
  304. if !ctx.Repo.CanWrite(models.UnitTypeIssues) {
  305. return nil
  306. }
  307. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  308. if err != nil {
  309. ctx.ServerError("GetLabelsByRepoID", err)
  310. return nil
  311. }
  312. ctx.Data["Labels"] = labels
  313. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  314. if ctx.Written() {
  315. return nil
  316. }
  317. brs, err := ctx.Repo.GitRepo.GetBranches()
  318. if err != nil {
  319. ctx.ServerError("GetBranches", err)
  320. return nil
  321. }
  322. ctx.Data["Branches"] = brs
  323. // Contains true if the user can create issue dependencies
  324. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  325. return labels
  326. }
  327. func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (string, bool) {
  328. var bytes []byte
  329. if ctx.Repo.Commit == nil {
  330. var err error
  331. ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
  332. if err != nil {
  333. return "", false
  334. }
  335. }
  336. entry, err := ctx.Repo.Commit.GetTreeEntryByPath(filename)
  337. if err != nil {
  338. return "", false
  339. }
  340. if entry.Blob().Size() >= setting.UI.MaxDisplayFileSize {
  341. return "", false
  342. }
  343. r, err := entry.Blob().DataAsync()
  344. if err != nil {
  345. return "", false
  346. }
  347. defer r.Close()
  348. bytes, err = ioutil.ReadAll(r)
  349. if err != nil {
  350. return "", false
  351. }
  352. return string(bytes), true
  353. }
  354. func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles []string) {
  355. for _, filename := range possibleFiles {
  356. content, found := getFileContentFromDefaultBranch(ctx, filename)
  357. if found {
  358. ctx.Data[ctxDataKey] = content
  359. return
  360. }
  361. }
  362. }
  363. // NewIssue render creating issue page
  364. func NewIssue(ctx *context.Context) {
  365. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  366. ctx.Data["PageIsIssueList"] = true
  367. ctx.Data["RequireHighlightJS"] = true
  368. ctx.Data["RequireSimpleMDE"] = true
  369. ctx.Data["RequireTribute"] = true
  370. ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
  371. body := ctx.Query("body")
  372. ctx.Data["BodyQuery"] = body
  373. milestoneID := ctx.QueryInt64("milestone")
  374. if milestoneID > 0 {
  375. milestone, err := models.GetMilestoneByID(milestoneID)
  376. if err != nil {
  377. log.Error("GetMilestoneByID: %d: %v", milestoneID, err)
  378. } else {
  379. ctx.Data["milestone_id"] = milestoneID
  380. ctx.Data["Milestone"] = milestone
  381. }
  382. }
  383. setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
  384. renderAttachmentSettings(ctx)
  385. RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  386. if ctx.Written() {
  387. return
  388. }
  389. ctx.HTML(200, tplIssueNew)
  390. }
  391. // ValidateRepoMetas check and returns repository's meta informations
  392. func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm, isPull bool) ([]int64, []int64, int64) {
  393. var (
  394. repo = ctx.Repo.Repository
  395. err error
  396. )
  397. labels := RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  398. if ctx.Written() {
  399. return nil, nil, 0
  400. }
  401. var labelIDs []int64
  402. hasSelected := false
  403. // Check labels.
  404. if len(form.LabelIDs) > 0 {
  405. labelIDs, err = base.StringsToInt64s(strings.Split(form.LabelIDs, ","))
  406. if err != nil {
  407. return nil, nil, 0
  408. }
  409. labelIDMark := base.Int64sToMap(labelIDs)
  410. for i := range labels {
  411. if labelIDMark[labels[i].ID] {
  412. labels[i].IsChecked = true
  413. hasSelected = true
  414. }
  415. }
  416. }
  417. ctx.Data["Labels"] = labels
  418. ctx.Data["HasSelectedLabel"] = hasSelected
  419. ctx.Data["label_ids"] = form.LabelIDs
  420. // Check milestone.
  421. milestoneID := form.MilestoneID
  422. if milestoneID > 0 {
  423. ctx.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID)
  424. if err != nil {
  425. ctx.ServerError("GetMilestoneByID", err)
  426. return nil, nil, 0
  427. }
  428. ctx.Data["milestone_id"] = milestoneID
  429. }
  430. // Check assignees
  431. var assigneeIDs []int64
  432. if len(form.AssigneeIDs) > 0 {
  433. assigneeIDs, err = base.StringsToInt64s(strings.Split(form.AssigneeIDs, ","))
  434. if err != nil {
  435. return nil, nil, 0
  436. }
  437. // Check if the passed assignees actually exists and has write access to the repo
  438. for _, aID := range assigneeIDs {
  439. user, err := models.GetUserByID(aID)
  440. if err != nil {
  441. ctx.ServerError("GetUserByID", err)
  442. return nil, nil, 0
  443. }
  444. perm, err := models.GetUserRepoPermission(repo, user)
  445. if err != nil {
  446. ctx.ServerError("GetUserRepoPermission", err)
  447. return nil, nil, 0
  448. }
  449. if !perm.CanWriteIssuesOrPulls(isPull) {
  450. ctx.ServerError("CanWriteIssuesOrPulls", fmt.Errorf("No permission for %s", user.Name))
  451. return nil, nil, 0
  452. }
  453. }
  454. }
  455. // Keep the old assignee id thingy for compatibility reasons
  456. if form.AssigneeID > 0 {
  457. assigneeIDs = append(assigneeIDs, form.AssigneeID)
  458. }
  459. return labelIDs, assigneeIDs, milestoneID
  460. }
  461. // NewIssuePost response for creating new issue
  462. func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
  463. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  464. ctx.Data["PageIsIssueList"] = true
  465. ctx.Data["RequireHighlightJS"] = true
  466. ctx.Data["RequireSimpleMDE"] = true
  467. ctx.Data["ReadOnly"] = false
  468. ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
  469. renderAttachmentSettings(ctx)
  470. var (
  471. repo = ctx.Repo.Repository
  472. attachments []string
  473. )
  474. labelIDs, assigneeIDs, milestoneID := ValidateRepoMetas(ctx, form, false)
  475. if ctx.Written() {
  476. return
  477. }
  478. if setting.AttachmentEnabled {
  479. attachments = form.Files
  480. }
  481. if ctx.HasError() {
  482. ctx.HTML(200, tplIssueNew)
  483. return
  484. }
  485. if util.IsEmptyString(form.Title) {
  486. ctx.RenderWithErr(ctx.Tr("repo.issues.new.title_empty"), tplIssueNew, form)
  487. return
  488. }
  489. issue := &models.Issue{
  490. RepoID: repo.ID,
  491. Title: form.Title,
  492. PosterID: ctx.User.ID,
  493. Poster: ctx.User,
  494. MilestoneID: milestoneID,
  495. Content: form.Content,
  496. Ref: form.Ref,
  497. }
  498. if err := models.NewIssue(repo, issue, labelIDs, assigneeIDs, attachments); err != nil {
  499. if models.IsErrUserDoesNotHaveAccessToRepo(err) {
  500. ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error())
  501. return
  502. }
  503. ctx.ServerError("NewIssue", err)
  504. return
  505. }
  506. notification.NotifyNewIssue(issue)
  507. log.Trace("Issue created: %d/%d", repo.ID, issue.ID)
  508. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  509. }
  510. // commentTag returns the CommentTag for a comment in/with the given repo, poster and issue
  511. func commentTag(repo *models.Repository, poster *models.User, issue *models.Issue) (models.CommentTag, error) {
  512. perm, err := models.GetUserRepoPermission(repo, poster)
  513. if err != nil {
  514. return models.CommentTagNone, err
  515. }
  516. if perm.IsOwner() {
  517. return models.CommentTagOwner, nil
  518. } else if poster.ID == issue.PosterID {
  519. return models.CommentTagPoster, nil
  520. } else if perm.CanWrite(models.UnitTypeCode) {
  521. return models.CommentTagWriter, nil
  522. }
  523. return models.CommentTagNone, nil
  524. }
  525. // ViewIssue render issue view page
  526. func ViewIssue(ctx *context.Context) {
  527. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  528. if err != nil {
  529. if models.IsErrIssueNotExist(err) {
  530. ctx.NotFound("GetIssueByIndex", err)
  531. } else {
  532. ctx.ServerError("GetIssueByIndex", err)
  533. }
  534. return
  535. }
  536. // Make sure type and URL matches.
  537. if ctx.Params(":type") == "issues" && issue.IsPull {
  538. ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
  539. return
  540. } else if ctx.Params(":type") == "pulls" && !issue.IsPull {
  541. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  542. return
  543. }
  544. if issue.IsPull {
  545. MustAllowPulls(ctx)
  546. if ctx.Written() {
  547. return
  548. }
  549. ctx.Data["PageIsPullList"] = true
  550. ctx.Data["PageIsPullConversation"] = true
  551. } else {
  552. MustEnableIssues(ctx)
  553. if ctx.Written() {
  554. return
  555. }
  556. ctx.Data["PageIsIssueList"] = true
  557. }
  558. ctx.Data["RequireHighlightJS"] = true
  559. ctx.Data["RequireDropzone"] = true
  560. ctx.Data["RequireTribute"] = true
  561. renderAttachmentSettings(ctx)
  562. err = issue.LoadAttributes()
  563. if err != nil {
  564. ctx.ServerError("GetIssueByIndex", err)
  565. return
  566. }
  567. ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
  568. var iw *models.IssueWatch
  569. var exists bool
  570. if ctx.User != nil {
  571. iw, exists, err = models.GetIssueWatch(ctx.User.ID, issue.ID)
  572. if err != nil {
  573. ctx.ServerError("GetIssueWatch", err)
  574. return
  575. }
  576. if !exists {
  577. iw = &models.IssueWatch{
  578. UserID: ctx.User.ID,
  579. IssueID: issue.ID,
  580. IsWatching: models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID),
  581. }
  582. }
  583. }
  584. ctx.Data["IssueWatch"] = iw
  585. issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink,
  586. ctx.Repo.Repository.ComposeMetas()))
  587. repo := ctx.Repo.Repository
  588. // Get more information if it's a pull request.
  589. if issue.IsPull {
  590. if issue.PullRequest.HasMerged {
  591. ctx.Data["DisableStatusChange"] = issue.PullRequest.HasMerged
  592. PrepareMergedViewPullInfo(ctx, issue)
  593. } else {
  594. PrepareViewPullInfo(ctx, issue)
  595. ctx.Data["DisableStatusChange"] = ctx.Data["IsPullRequestBroken"] == true && issue.IsClosed
  596. }
  597. if ctx.Written() {
  598. return
  599. }
  600. }
  601. // Metas.
  602. // Check labels.
  603. labelIDMark := make(map[int64]bool)
  604. for i := range issue.Labels {
  605. labelIDMark[issue.Labels[i].ID] = true
  606. }
  607. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  608. if err != nil {
  609. ctx.ServerError("GetLabelsByRepoID", err)
  610. return
  611. }
  612. hasSelected := false
  613. for i := range labels {
  614. if labelIDMark[labels[i].ID] {
  615. labels[i].IsChecked = true
  616. hasSelected = true
  617. }
  618. }
  619. ctx.Data["HasSelectedLabel"] = hasSelected
  620. ctx.Data["Labels"] = labels
  621. // Check milestone and assignee.
  622. if ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
  623. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  624. if ctx.Written() {
  625. return
  626. }
  627. }
  628. if ctx.IsSigned {
  629. // Update issue-user.
  630. if err = issue.ReadBy(ctx.User.ID); err != nil {
  631. ctx.ServerError("ReadBy", err)
  632. return
  633. }
  634. }
  635. var (
  636. tag models.CommentTag
  637. ok bool
  638. marked = make(map[int64]models.CommentTag)
  639. comment *models.Comment
  640. participants = make([]*models.User, 1, 10)
  641. )
  642. if ctx.Repo.Repository.IsTimetrackerEnabled() {
  643. if ctx.IsSigned {
  644. // Deal with the stopwatch
  645. ctx.Data["IsStopwatchRunning"] = models.StopwatchExists(ctx.User.ID, issue.ID)
  646. if !ctx.Data["IsStopwatchRunning"].(bool) {
  647. var exists bool
  648. var sw *models.Stopwatch
  649. if exists, sw, err = models.HasUserStopwatch(ctx.User.ID); err != nil {
  650. ctx.ServerError("HasUserStopwatch", err)
  651. return
  652. }
  653. ctx.Data["HasUserStopwatch"] = exists
  654. if exists {
  655. // Add warning if the user has already a stopwatch
  656. var otherIssue *models.Issue
  657. if otherIssue, err = models.GetIssueByID(sw.IssueID); err != nil {
  658. ctx.ServerError("GetIssueByID", err)
  659. return
  660. }
  661. if err = otherIssue.LoadRepo(); err != nil {
  662. ctx.ServerError("LoadRepo", err)
  663. return
  664. }
  665. // Add link to the issue of the already running stopwatch
  666. ctx.Data["OtherStopwatchURL"] = otherIssue.HTMLURL()
  667. }
  668. }
  669. ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.User)
  670. } else {
  671. ctx.Data["CanUseTimetracker"] = false
  672. }
  673. if ctx.Data["WorkingUsers"], err = models.TotalTimes(models.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil {
  674. ctx.ServerError("TotalTimes", err)
  675. return
  676. }
  677. }
  678. // Check if the user can use the dependencies
  679. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  680. // Render comments and and fetch participants.
  681. participants[0] = issue.Poster
  682. for _, comment = range issue.Comments {
  683. comment.Issue = issue
  684. if err := comment.LoadPoster(); err != nil {
  685. ctx.ServerError("LoadPoster", err)
  686. return
  687. }
  688. if comment.Type == models.CommentTypeComment {
  689. if err := comment.LoadAttachments(); err != nil {
  690. ctx.ServerError("LoadAttachments", err)
  691. return
  692. }
  693. comment.RenderedContent = string(markdown.Render([]byte(comment.Content), ctx.Repo.RepoLink,
  694. ctx.Repo.Repository.ComposeMetas()))
  695. // Check tag.
  696. tag, ok = marked[comment.PosterID]
  697. if ok {
  698. comment.ShowTag = tag
  699. continue
  700. }
  701. comment.ShowTag, err = commentTag(repo, comment.Poster, issue)
  702. if err != nil {
  703. ctx.ServerError("commentTag", err)
  704. return
  705. }
  706. marked[comment.PosterID] = comment.ShowTag
  707. participants = addParticipant(comment.Poster, participants)
  708. } else if comment.Type == models.CommentTypeLabel {
  709. if err = comment.LoadLabel(); err != nil {
  710. ctx.ServerError("LoadLabel", err)
  711. return
  712. }
  713. } else if comment.Type == models.CommentTypeMilestone {
  714. if err = comment.LoadMilestone(); err != nil {
  715. ctx.ServerError("LoadMilestone", err)
  716. return
  717. }
  718. ghostMilestone := &models.Milestone{
  719. ID: -1,
  720. Name: ctx.Tr("repo.issues.deleted_milestone"),
  721. }
  722. if comment.OldMilestoneID > 0 && comment.OldMilestone == nil {
  723. comment.OldMilestone = ghostMilestone
  724. }
  725. if comment.MilestoneID > 0 && comment.Milestone == nil {
  726. comment.Milestone = ghostMilestone
  727. }
  728. } else if comment.Type == models.CommentTypeAssignees {
  729. if err = comment.LoadAssigneeUser(); err != nil {
  730. ctx.ServerError("LoadAssigneeUser", err)
  731. return
  732. }
  733. } else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency {
  734. if err = comment.LoadDepIssueDetails(); err != nil {
  735. ctx.ServerError("LoadDepIssueDetails", err)
  736. return
  737. }
  738. } else if comment.Type == models.CommentTypeCode || comment.Type == models.CommentTypeReview {
  739. if err = comment.LoadReview(); err != nil && !models.IsErrReviewNotExist(err) {
  740. ctx.ServerError("LoadReview", err)
  741. return
  742. }
  743. participants = addParticipant(comment.Poster, participants)
  744. if comment.Review == nil {
  745. continue
  746. }
  747. if err = comment.Review.LoadAttributes(); err != nil {
  748. if !models.IsErrUserNotExist(err) {
  749. ctx.ServerError("Review.LoadAttributes", err)
  750. return
  751. }
  752. comment.Review.Reviewer = models.NewGhostUser()
  753. }
  754. if err = comment.Review.LoadCodeComments(); err != nil {
  755. ctx.ServerError("Review.LoadCodeComments", err)
  756. return
  757. }
  758. }
  759. }
  760. if issue.IsPull {
  761. pull := issue.PullRequest
  762. pull.Issue = issue
  763. canDelete := false
  764. if ctx.IsSigned {
  765. if err := pull.GetHeadRepo(); err != nil {
  766. log.Error("GetHeadRepo: %v", err)
  767. } else if pull.HeadRepo != nil && pull.HeadBranch != pull.HeadRepo.DefaultBranch {
  768. perm, err := models.GetUserRepoPermission(pull.HeadRepo, ctx.User)
  769. if err != nil {
  770. ctx.ServerError("GetUserRepoPermission", err)
  771. return
  772. }
  773. if perm.CanWrite(models.UnitTypeCode) {
  774. // Check if branch is not protected
  775. if protected, err := pull.HeadRepo.IsProtectedBranch(pull.HeadBranch, ctx.User); err != nil {
  776. log.Error("IsProtectedBranch: %v", err)
  777. } else if !protected {
  778. canDelete = true
  779. ctx.Data["DeleteBranchLink"] = ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index) + "/cleanup"
  780. }
  781. }
  782. }
  783. }
  784. prUnit, err := repo.GetUnit(models.UnitTypePullRequests)
  785. if err != nil {
  786. ctx.ServerError("GetUnit", err)
  787. return
  788. }
  789. prConfig := prUnit.PullRequestsConfig()
  790. ctx.Data["AllowMerge"] = ctx.Repo.CanWrite(models.UnitTypeCode)
  791. if err := pull.CheckUserAllowedToMerge(ctx.User); err != nil {
  792. if !models.IsErrNotAllowedToMerge(err) {
  793. ctx.ServerError("CheckUserAllowedToMerge", err)
  794. return
  795. }
  796. ctx.Data["AllowMerge"] = false
  797. }
  798. // Check correct values and select default
  799. if ms, ok := ctx.Data["MergeStyle"].(models.MergeStyle); !ok ||
  800. !prConfig.IsMergeStyleAllowed(ms) {
  801. if prConfig.AllowMerge {
  802. ctx.Data["MergeStyle"] = models.MergeStyleMerge
  803. } else if prConfig.AllowRebase {
  804. ctx.Data["MergeStyle"] = models.MergeStyleRebase
  805. } else if prConfig.AllowRebaseMerge {
  806. ctx.Data["MergeStyle"] = models.MergeStyleRebaseMerge
  807. } else if prConfig.AllowSquash {
  808. ctx.Data["MergeStyle"] = models.MergeStyleSquash
  809. } else {
  810. ctx.Data["MergeStyle"] = ""
  811. }
  812. }
  813. if err = pull.LoadProtectedBranch(); err != nil {
  814. ctx.ServerError("LoadProtectedBranch", err)
  815. return
  816. }
  817. if pull.ProtectedBranch != nil {
  818. cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull)
  819. ctx.Data["IsBlockedByApprovals"] = pull.ProtectedBranch.RequiredApprovals > 0 && cnt < pull.ProtectedBranch.RequiredApprovals
  820. ctx.Data["GrantedApprovals"] = cnt
  821. }
  822. ctx.Data["IsPullBranchDeletable"] = canDelete && pull.HeadRepo != nil && git.IsBranchExist(pull.HeadRepo.RepoPath(), pull.HeadBranch)
  823. ctx.Data["PullReviewersWithType"], err = models.GetReviewersByPullID(issue.ID)
  824. if err != nil {
  825. ctx.ServerError("GetReviewersByPullID", err)
  826. return
  827. }
  828. }
  829. // Get Dependencies
  830. ctx.Data["BlockedByDependencies"], err = issue.BlockedByDependencies()
  831. if err != nil {
  832. ctx.ServerError("BlockedByDependencies", err)
  833. return
  834. }
  835. ctx.Data["BlockingDependencies"], err = issue.BlockingDependencies()
  836. if err != nil {
  837. ctx.ServerError("BlockingDependencies", err)
  838. return
  839. }
  840. ctx.Data["Participants"] = participants
  841. ctx.Data["NumParticipants"] = len(participants)
  842. ctx.Data["Issue"] = issue
  843. ctx.Data["ReadOnly"] = true
  844. ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string)
  845. ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID)
  846. ctx.Data["IsIssueWriter"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
  847. ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.User.IsAdmin)
  848. ctx.Data["IsRepoIssuesWriter"] = ctx.IsSigned && (ctx.Repo.CanWrite(models.UnitTypeIssues) || ctx.User.IsAdmin)
  849. ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons
  850. ctx.HTML(200, tplIssueView)
  851. }
  852. // GetActionIssue will return the issue which is used in the context.
  853. func GetActionIssue(ctx *context.Context) *models.Issue {
  854. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  855. if err != nil {
  856. ctx.NotFoundOrServerError("GetIssueByIndex", models.IsErrIssueNotExist, err)
  857. return nil
  858. }
  859. issue.Repo = ctx.Repo.Repository
  860. checkIssueRights(ctx, issue)
  861. if ctx.Written() {
  862. return nil
  863. }
  864. if err = issue.LoadAttributes(); err != nil {
  865. ctx.ServerError("LoadAttributes", nil)
  866. return nil
  867. }
  868. return issue
  869. }
  870. func checkIssueRights(ctx *context.Context, issue *models.Issue) {
  871. if issue.IsPull && !ctx.Repo.CanRead(models.UnitTypePullRequests) ||
  872. !issue.IsPull && !ctx.Repo.CanRead(models.UnitTypeIssues) {
  873. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  874. }
  875. }
  876. func getActionIssues(ctx *context.Context) []*models.Issue {
  877. commaSeparatedIssueIDs := ctx.Query("issue_ids")
  878. if len(commaSeparatedIssueIDs) == 0 {
  879. return nil
  880. }
  881. issueIDs := make([]int64, 0, 10)
  882. for _, stringIssueID := range strings.Split(commaSeparatedIssueIDs, ",") {
  883. issueID, err := strconv.ParseInt(stringIssueID, 10, 64)
  884. if err != nil {
  885. ctx.ServerError("ParseInt", err)
  886. return nil
  887. }
  888. issueIDs = append(issueIDs, issueID)
  889. }
  890. issues, err := models.GetIssuesByIDs(issueIDs)
  891. if err != nil {
  892. ctx.ServerError("GetIssuesByIDs", err)
  893. return nil
  894. }
  895. // Check access rights for all issues
  896. issueUnitEnabled := ctx.Repo.CanRead(models.UnitTypeIssues)
  897. prUnitEnabled := ctx.Repo.CanRead(models.UnitTypePullRequests)
  898. for _, issue := range issues {
  899. if issue.IsPull && !prUnitEnabled || !issue.IsPull && !issueUnitEnabled {
  900. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  901. return nil
  902. }
  903. if err = issue.LoadAttributes(); err != nil {
  904. ctx.ServerError("LoadAttributes", err)
  905. return nil
  906. }
  907. }
  908. return issues
  909. }
  910. // UpdateIssueTitle change issue's title
  911. func UpdateIssueTitle(ctx *context.Context) {
  912. issue := GetActionIssue(ctx)
  913. if ctx.Written() {
  914. return
  915. }
  916. if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
  917. ctx.Error(403)
  918. return
  919. }
  920. title := ctx.QueryTrim("title")
  921. if len(title) == 0 {
  922. ctx.Error(204)
  923. return
  924. }
  925. oldTitle := issue.Title
  926. if err := issue.ChangeTitle(ctx.User, title); err != nil {
  927. ctx.ServerError("ChangeTitle", err)
  928. return
  929. }
  930. notification.NotifyIssueChangeTitle(ctx.User, issue, oldTitle)
  931. ctx.JSON(200, map[string]interface{}{
  932. "title": issue.Title,
  933. })
  934. }
  935. // UpdateIssueContent change issue's content
  936. func UpdateIssueContent(ctx *context.Context) {
  937. issue := GetActionIssue(ctx)
  938. if ctx.Written() {
  939. return
  940. }
  941. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
  942. ctx.Error(403)
  943. return
  944. }
  945. content := ctx.Query("content")
  946. if err := issue.ChangeContent(ctx.User, content); err != nil {
  947. ctx.ServerError("ChangeContent", err)
  948. return
  949. }
  950. ctx.JSON(200, map[string]interface{}{
  951. "content": string(markdown.Render([]byte(issue.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  952. })
  953. }
  954. // UpdateIssueMilestone change issue's milestone
  955. func UpdateIssueMilestone(ctx *context.Context) {
  956. issues := getActionIssues(ctx)
  957. if ctx.Written() {
  958. return
  959. }
  960. milestoneID := ctx.QueryInt64("id")
  961. for _, issue := range issues {
  962. oldMilestoneID := issue.MilestoneID
  963. if oldMilestoneID == milestoneID {
  964. continue
  965. }
  966. issue.MilestoneID = milestoneID
  967. if err := models.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
  968. ctx.ServerError("ChangeMilestoneAssign", err)
  969. return
  970. }
  971. }
  972. ctx.JSON(200, map[string]interface{}{
  973. "ok": true,
  974. })
  975. }
  976. // UpdateIssueAssignee change issue's assignee
  977. func UpdateIssueAssignee(ctx *context.Context) {
  978. issues := getActionIssues(ctx)
  979. if ctx.Written() {
  980. return
  981. }
  982. assigneeID := ctx.QueryInt64("id")
  983. action := ctx.Query("action")
  984. for _, issue := range issues {
  985. switch action {
  986. case "clear":
  987. if err := models.DeleteNotPassedAssignee(issue, ctx.User, []*models.User{}); err != nil {
  988. ctx.ServerError("ClearAssignees", err)
  989. return
  990. }
  991. default:
  992. if err := issue.ChangeAssignee(ctx.User, assigneeID); err != nil {
  993. ctx.ServerError("ChangeAssignee", err)
  994. return
  995. }
  996. }
  997. }
  998. ctx.JSON(200, map[string]interface{}{
  999. "ok": true,
  1000. })
  1001. }
  1002. // UpdateIssueStatus change issue's status
  1003. func UpdateIssueStatus(ctx *context.Context) {
  1004. issues := getActionIssues(ctx)
  1005. if ctx.Written() {
  1006. return
  1007. }
  1008. var isClosed bool
  1009. switch action := ctx.Query("action"); action {
  1010. case "open":
  1011. isClosed = false
  1012. case "close":
  1013. isClosed = true
  1014. default:
  1015. log.Warn("Unrecognized action: %s", action)
  1016. }
  1017. if _, err := models.IssueList(issues).LoadRepositories(); err != nil {
  1018. ctx.ServerError("LoadRepositories", err)
  1019. return
  1020. }
  1021. for _, issue := range issues {
  1022. if issue.IsClosed != isClosed {
  1023. if err := issue.ChangeStatus(ctx.User, isClosed); err != nil {
  1024. if models.IsErrDependenciesLeft(err) {
  1025. ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{
  1026. "error": "cannot close this issue because it still has open dependencies",
  1027. })
  1028. return
  1029. }
  1030. ctx.ServerError("ChangeStatus", err)
  1031. return
  1032. }
  1033. notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed)
  1034. }
  1035. }
  1036. ctx.JSON(200, map[string]interface{}{
  1037. "ok": true,
  1038. })
  1039. }
  1040. // NewComment create a comment for issue
  1041. func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
  1042. issue := GetActionIssue(ctx)
  1043. if ctx.Written() {
  1044. return
  1045. }
  1046. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
  1047. if log.IsTrace() {
  1048. if ctx.IsSigned {
  1049. issueType := "issues"
  1050. if issue.IsPull {
  1051. issueType = "pulls"
  1052. }
  1053. log.Trace("Permission Denied: User %-v not the Poster (ID: %d) and cannot read %s in Repo %-v.\n"+
  1054. "User in Repo has Permissions: %-+v",
  1055. ctx.User,
  1056. log.NewColoredIDValue(issue.PosterID),
  1057. issueType,
  1058. ctx.Repo.Repository,
  1059. ctx.Repo.Permission)
  1060. } else {
  1061. log.Trace("Permission Denied: Not logged in")
  1062. }
  1063. }
  1064. ctx.Error(403)
  1065. }
  1066. if issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) && !ctx.User.IsAdmin {
  1067. ctx.Flash.Error(ctx.Tr("repo.issues.comment_on_locked"))
  1068. ctx.Redirect(issue.HTMLURL(), http.StatusSeeOther)
  1069. return
  1070. }
  1071. var attachments []string
  1072. if setting.AttachmentEnabled {
  1073. attachments = form.Files
  1074. }
  1075. if ctx.HasError() {
  1076. ctx.Flash.Error(ctx.Data["ErrorMsg"].(string))
  1077. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index))
  1078. return
  1079. }
  1080. var comment *models.Comment
  1081. defer func() {
  1082. // Check if issue admin/poster changes the status of issue.
  1083. if (ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))) &&
  1084. (form.Status == "reopen" || form.Status == "close") &&
  1085. !(issue.IsPull && issue.PullRequest.HasMerged) {
  1086. // Duplication and conflict check should apply to reopen pull request.
  1087. var pr *models.PullRequest
  1088. if form.Status == "reopen" && issue.IsPull {
  1089. pull := issue.PullRequest
  1090. var err error
  1091. pr, err = models.GetUnmergedPullRequest(pull.HeadRepoID, pull.BaseRepoID, pull.HeadBranch, pull.BaseBranch)
  1092. if err != nil {
  1093. if !models.IsErrPullRequestNotExist(err) {
  1094. ctx.ServerError("GetUnmergedPullRequest", err)
  1095. return
  1096. }
  1097. }
  1098. // Regenerate patch and test conflict.
  1099. if pr == nil {
  1100. if err = issue.PullRequest.UpdatePatch(); err != nil {
  1101. ctx.ServerError("UpdatePatch", err)
  1102. return
  1103. }
  1104. issue.PullRequest.AddToTaskQueue()
  1105. }
  1106. }
  1107. if pr != nil {
  1108. ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
  1109. } else {
  1110. isClosed := form.Status == "close"
  1111. if err := issue.ChangeStatus(ctx.User, isClosed); err != nil {
  1112. log.Error("ChangeStatus: %v", err)
  1113. if models.IsErrDependenciesLeft(err) {
  1114. if issue.IsPull {
  1115. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.pr_close_blocked"))
  1116. ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  1117. } else {
  1118. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.issue_close_blocked"))
  1119. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  1120. }
  1121. return
  1122. }
  1123. } else {
  1124. if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
  1125. ctx.ServerError("CreateOrStopIssueStopwatch", err)
  1126. return
  1127. }
  1128. log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
  1129. notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed)
  1130. }
  1131. }
  1132. }
  1133. // Redirect to comment hashtag if there is any actual content.
  1134. typeName := "issues"
  1135. if issue.IsPull {
  1136. typeName = "pulls"
  1137. }
  1138. if comment != nil {
  1139. ctx.Redirect(fmt.Sprintf("%s/%s/%d#%s", ctx.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
  1140. } else {
  1141. ctx.Redirect(fmt.Sprintf("%s/%s/%d", ctx.Repo.RepoLink, typeName, issue.Index))
  1142. }
  1143. }()
  1144. // Fix #321: Allow empty comments, as long as we have attachments.
  1145. if len(form.Content) == 0 && len(attachments) == 0 {
  1146. return
  1147. }
  1148. comment, err := models.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Content, attachments)
  1149. if err != nil {
  1150. ctx.ServerError("CreateIssueComment", err)
  1151. return
  1152. }
  1153. notification.NotifyCreateIssueComment(ctx.User, ctx.Repo.Repository, issue, comment)
  1154. log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
  1155. }
  1156. // UpdateCommentContent change comment of issue's content
  1157. func UpdateCommentContent(ctx *context.Context) {
  1158. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1159. if err != nil {
  1160. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1161. return
  1162. }
  1163. if err := comment.LoadIssue(); err != nil {
  1164. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1165. return
  1166. }
  1167. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
  1168. ctx.Error(403)
  1169. return
  1170. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1171. ctx.Error(204)
  1172. return
  1173. }
  1174. oldContent := comment.Content
  1175. comment.Content = ctx.Query("content")
  1176. if len(comment.Content) == 0 {
  1177. ctx.JSON(200, map[string]interface{}{
  1178. "content": "",
  1179. })
  1180. return
  1181. }
  1182. if err = models.UpdateComment(ctx.User, comment, oldContent); err != nil {
  1183. ctx.ServerError("UpdateComment", err)
  1184. return
  1185. }
  1186. notification.NotifyUpdateComment(ctx.User, comment, oldContent)
  1187. ctx.JSON(200, map[string]interface{}{
  1188. "content": string(markdown.Render([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  1189. })
  1190. }
  1191. // DeleteComment delete comment of issue
  1192. func DeleteComment(ctx *context.Context) {
  1193. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1194. if err != nil {
  1195. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1196. return
  1197. }
  1198. if err := comment.LoadIssue(); err != nil {
  1199. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1200. return
  1201. }
  1202. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
  1203. ctx.Error(403)
  1204. return
  1205. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1206. ctx.Error(204)
  1207. return
  1208. }
  1209. if err = models.DeleteComment(ctx.User, comment); err != nil {
  1210. ctx.ServerError("DeleteCommentByID", err)
  1211. return
  1212. }
  1213. notification.NotifyDeleteComment(ctx.User, comment)
  1214. ctx.Status(200)
  1215. }
  1216. // ChangeIssueReaction create a reaction for issue
  1217. func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
  1218. issue := GetActionIssue(ctx)
  1219. if ctx.Written() {
  1220. return
  1221. }
  1222. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
  1223. if log.IsTrace() {
  1224. if ctx.IsSigned {
  1225. issueType := "issues"
  1226. if issue.IsPull {
  1227. issueType = "pulls"
  1228. }
  1229. log.Trace("Permission Denied: User %-v not the Poster (ID: %d) and cannot read %s in Repo %-v.\n"+
  1230. "User in Repo has Permissions: %-+v",
  1231. ctx.User,
  1232. log.NewColoredIDValue(issue.PosterID),
  1233. issueType,
  1234. ctx.Repo.Repository,
  1235. ctx.Repo.Permission)
  1236. } else {
  1237. log.Trace("Permission Denied: Not logged in")
  1238. }
  1239. }
  1240. ctx.Error(403)
  1241. return
  1242. }
  1243. if ctx.HasError() {
  1244. ctx.ServerError("ChangeIssueReaction", errors.New(ctx.GetErrMsg()))
  1245. return
  1246. }
  1247. switch ctx.Params(":action") {
  1248. case "react":
  1249. reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
  1250. if err != nil {
  1251. log.Info("CreateIssueReaction: %s", err)
  1252. break
  1253. }
  1254. // Reload new reactions
  1255. issue.Reactions = nil
  1256. if err = issue.LoadAttributes(); err != nil {
  1257. log.Info("issue.LoadAttributes: %s", err)
  1258. break
  1259. }
  1260. log.Trace("Reaction for issue created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, reaction.ID)
  1261. case "unreact":
  1262. if err := models.DeleteIssueReaction(ctx.User, issue, form.Content); err != nil {
  1263. ctx.ServerError("DeleteIssueReaction", err)
  1264. return
  1265. }
  1266. // Reload new reactions
  1267. issue.Reactions = nil
  1268. if err := issue.LoadAttributes(); err != nil {
  1269. log.Info("issue.LoadAttributes: %s", err)
  1270. break
  1271. }
  1272. log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID)
  1273. default:
  1274. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1275. return
  1276. }
  1277. if len(issue.Reactions) == 0 {
  1278. ctx.JSON(200, map[string]interface{}{
  1279. "empty": true,
  1280. "html": "",
  1281. })
  1282. return
  1283. }
  1284. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1285. "ctx": ctx.Data,
  1286. "ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index),
  1287. "Reactions": issue.Reactions.GroupByType(),
  1288. })
  1289. if err != nil {
  1290. ctx.ServerError("ChangeIssueReaction.HTMLString", err)
  1291. return
  1292. }
  1293. ctx.JSON(200, map[string]interface{}{
  1294. "html": html,
  1295. })
  1296. }
  1297. // ChangeCommentReaction create a reaction for comment
  1298. func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
  1299. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1300. if err != nil {
  1301. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1302. return
  1303. }
  1304. if err := comment.LoadIssue(); err != nil {
  1305. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1306. return
  1307. }
  1308. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull)) {
  1309. if log.IsTrace() {
  1310. if ctx.IsSigned {
  1311. issueType := "issues"
  1312. if comment.Issue.IsPull {
  1313. issueType = "pulls"
  1314. }
  1315. log.Trace("Permission Denied: User %-v not the Poster (ID: %d) and cannot read %s in Repo %-v.\n"+
  1316. "User in Repo has Permissions: %-+v",
  1317. ctx.User,
  1318. log.NewColoredIDValue(comment.Issue.PosterID),
  1319. issueType,
  1320. ctx.Repo.Repository,
  1321. ctx.Repo.Permission)
  1322. } else {
  1323. log.Trace("Permission Denied: Not logged in")
  1324. }
  1325. }
  1326. ctx.Error(403)
  1327. return
  1328. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1329. ctx.Error(204)
  1330. return
  1331. }
  1332. switch ctx.Params(":action") {
  1333. case "react":
  1334. reaction, err := models.CreateCommentReaction(ctx.User, comment.Issue, comment, form.Content)
  1335. if err != nil {
  1336. log.Info("CreateCommentReaction: %s", err)
  1337. break
  1338. }
  1339. // Reload new reactions
  1340. comment.Reactions = nil
  1341. if err = comment.LoadReactions(); err != nil {
  1342. log.Info("comment.LoadReactions: %s", err)
  1343. break
  1344. }
  1345. log.Trace("Reaction for comment created: %d/%d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID, reaction.ID)
  1346. case "unreact":
  1347. if err := models.DeleteCommentReaction(ctx.User, comment.Issue, comment, form.Content); err != nil {
  1348. ctx.ServerError("DeleteCommentReaction", err)
  1349. return
  1350. }
  1351. // Reload new reactions
  1352. comment.Reactions = nil
  1353. if err = comment.LoadReactions(); err != nil {
  1354. log.Info("comment.LoadReactions: %s", err)
  1355. break
  1356. }
  1357. log.Trace("Reaction for comment removed: %d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID)
  1358. default:
  1359. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1360. return
  1361. }
  1362. if len(comment.Reactions) == 0 {
  1363. ctx.JSON(200, map[string]interface{}{
  1364. "empty": true,
  1365. "html": "",
  1366. })
  1367. return
  1368. }
  1369. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1370. "ctx": ctx.Data,
  1371. "ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID),
  1372. "Reactions": comment.Reactions.GroupByType(),
  1373. })
  1374. if err != nil {
  1375. ctx.ServerError("ChangeCommentReaction.HTMLString", err)
  1376. return
  1377. }
  1378. ctx.JSON(200, map[string]interface{}{
  1379. "html": html,
  1380. })
  1381. }
  1382. func addParticipant(poster *models.User, participants []*models.User) []*models.User {
  1383. for _, part := range participants {
  1384. if poster.ID == part.ID {
  1385. return participants
  1386. }
  1387. }
  1388. return append(participants, poster)
  1389. }