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 41 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
10 years ago
10 years ago
10 years ago
10 years ago
10 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
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
10 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
10 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
10 years ago
10 years ago
10 years ago
10 years ago
10 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>
8 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>
8 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>
8 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>
8 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>
8 years ago
9 years ago
9 years ago
9 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>
7 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>
8 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>
8 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>
8 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
10 years ago
10 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>
7 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>
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495
  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. "code.gitea.io/gitea/modules/util"
  25. "github.com/Unknwon/com"
  26. )
  27. const (
  28. tplIssues base.TplName = "repo/issue/list"
  29. tplIssueNew base.TplName = "repo/issue/new"
  30. tplIssueView base.TplName = "repo/issue/view"
  31. tplReactions base.TplName = "repo/issue/view_content/reactions"
  32. issueTemplateKey = "IssueTemplate"
  33. )
  34. var (
  35. // ErrFileTypeForbidden not allowed file type error
  36. ErrFileTypeForbidden = errors.New("File type is not allowed")
  37. // ErrTooManyFiles upload too many files
  38. ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
  39. // IssueTemplateCandidates issue templates
  40. IssueTemplateCandidates = []string{
  41. "ISSUE_TEMPLATE.md",
  42. "issue_template.md",
  43. ".gitea/ISSUE_TEMPLATE.md",
  44. ".gitea/issue_template.md",
  45. ".github/ISSUE_TEMPLATE.md",
  46. ".github/issue_template.md",
  47. }
  48. )
  49. // MustAllowUserComment checks to make sure if an issue is locked.
  50. // If locked and user has permissions to write to the repository,
  51. // then the comment is allowed, else it is blocked
  52. func MustAllowUserComment(ctx *context.Context) {
  53. issue := GetActionIssue(ctx)
  54. if ctx.Written() {
  55. return
  56. }
  57. if issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) && !ctx.User.IsAdmin {
  58. ctx.Flash.Error(ctx.Tr("repo.issues.comment_on_locked"))
  59. ctx.Redirect(issue.HTMLURL())
  60. return
  61. }
  62. }
  63. // MustEnableIssues check if repository enable internal issues
  64. func MustEnableIssues(ctx *context.Context) {
  65. if !ctx.Repo.CanRead(models.UnitTypeIssues) &&
  66. !ctx.Repo.CanRead(models.UnitTypeExternalTracker) {
  67. ctx.NotFound("MustEnableIssues", nil)
  68. return
  69. }
  70. unit, err := ctx.Repo.Repository.GetUnit(models.UnitTypeExternalTracker)
  71. if err == nil {
  72. ctx.Redirect(unit.ExternalTrackerConfig().ExternalTrackerURL)
  73. return
  74. }
  75. }
  76. // MustAllowPulls check if repository enable pull requests and user have right to do that
  77. func MustAllowPulls(ctx *context.Context) {
  78. if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(models.UnitTypePullRequests) {
  79. ctx.NotFound("MustAllowPulls", nil)
  80. return
  81. }
  82. // User can send pull request if owns a forked repository.
  83. if ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID) {
  84. ctx.Repo.PullRequest.Allowed = true
  85. ctx.Repo.PullRequest.HeadInfo = ctx.User.Name + ":" + ctx.Repo.BranchName
  86. }
  87. }
  88. func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalBool) {
  89. var err error
  90. viewType := ctx.Query("type")
  91. sortType := ctx.Query("sort")
  92. types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned"}
  93. if !com.IsSliceContainsStr(types, viewType) {
  94. viewType = "all"
  95. }
  96. var (
  97. assigneeID = ctx.QueryInt64("assignee")
  98. posterID int64
  99. mentionedID int64
  100. forceEmpty bool
  101. )
  102. if ctx.IsSigned {
  103. switch viewType {
  104. case "created_by":
  105. posterID = ctx.User.ID
  106. case "mentioned":
  107. mentionedID = ctx.User.ID
  108. }
  109. }
  110. repo := ctx.Repo.Repository
  111. var labelIDs []int64
  112. selectLabels := ctx.Query("labels")
  113. if len(selectLabels) > 0 && selectLabels != "0" {
  114. labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
  115. if err != nil {
  116. ctx.ServerError("StringsToInt64s", err)
  117. return
  118. }
  119. }
  120. isShowClosed := ctx.Query("state") == "closed"
  121. keyword := strings.Trim(ctx.Query("q"), " ")
  122. if bytes.Contains([]byte(keyword), []byte{0x00}) {
  123. keyword = ""
  124. }
  125. var issueIDs []int64
  126. if len(keyword) > 0 {
  127. issueIDs, err = issue_indexer.SearchIssuesByKeyword(repo.ID, keyword)
  128. if err != nil {
  129. ctx.ServerError("issueIndexer.Search", err)
  130. return
  131. }
  132. if len(issueIDs) == 0 {
  133. forceEmpty = true
  134. }
  135. }
  136. var issueStats *models.IssueStats
  137. if forceEmpty {
  138. issueStats = &models.IssueStats{}
  139. } else {
  140. issueStats, err = models.GetIssueStats(&models.IssueStatsOptions{
  141. RepoID: repo.ID,
  142. Labels: selectLabels,
  143. MilestoneID: milestoneID,
  144. AssigneeID: assigneeID,
  145. MentionedID: mentionedID,
  146. PosterID: posterID,
  147. IsPull: isPullOption,
  148. IssueIDs: issueIDs,
  149. })
  150. if err != nil {
  151. ctx.ServerError("GetIssueStats", err)
  152. return
  153. }
  154. }
  155. page := ctx.QueryInt("page")
  156. if page <= 1 {
  157. page = 1
  158. }
  159. var total int
  160. if !isShowClosed {
  161. total = int(issueStats.OpenCount)
  162. } else {
  163. total = int(issueStats.ClosedCount)
  164. }
  165. pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, 5)
  166. var issues []*models.Issue
  167. if forceEmpty {
  168. issues = []*models.Issue{}
  169. } else {
  170. issues, err = models.Issues(&models.IssuesOptions{
  171. RepoIDs: []int64{repo.ID},
  172. AssigneeID: assigneeID,
  173. PosterID: posterID,
  174. MentionedID: mentionedID,
  175. MilestoneID: milestoneID,
  176. Page: pager.Paginater.Current(),
  177. PageSize: setting.UI.IssuePagingNum,
  178. IsClosed: util.OptionalBoolOf(isShowClosed),
  179. IsPull: isPullOption,
  180. LabelIDs: labelIDs,
  181. SortType: sortType,
  182. IssueIDs: issueIDs,
  183. })
  184. if err != nil {
  185. ctx.ServerError("Issues", err)
  186. return
  187. }
  188. }
  189. var commitStatus = make(map[int64]*models.CommitStatus, len(issues))
  190. // Get posters.
  191. for i := range issues {
  192. // Check read status
  193. if !ctx.IsSigned {
  194. issues[i].IsRead = true
  195. } else if err = issues[i].GetIsRead(ctx.User.ID); err != nil {
  196. ctx.ServerError("GetIsRead", err)
  197. return
  198. }
  199. if isPullOption == util.OptionalBoolTrue {
  200. commitStatus[issues[i].PullRequest.ID], _ = issues[i].PullRequest.GetLastCommitStatus()
  201. }
  202. }
  203. ctx.Data["Issues"] = issues
  204. ctx.Data["CommitStatus"] = commitStatus
  205. // Get assignees.
  206. ctx.Data["Assignees"], err = repo.GetAssignees()
  207. if err != nil {
  208. ctx.ServerError("GetAssignees", err)
  209. return
  210. }
  211. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  212. if err != nil {
  213. ctx.ServerError("GetLabelsByRepoID", err)
  214. return
  215. }
  216. for _, l := range labels {
  217. l.LoadSelectedLabelsAfterClick(labelIDs)
  218. }
  219. ctx.Data["Labels"] = labels
  220. ctx.Data["NumLabels"] = len(labels)
  221. if ctx.QueryInt64("assignee") == 0 {
  222. assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
  223. }
  224. ctx.Data["IssueStats"] = issueStats
  225. ctx.Data["SelectLabels"] = com.StrTo(selectLabels).MustInt64()
  226. ctx.Data["ViewType"] = viewType
  227. ctx.Data["SortType"] = sortType
  228. ctx.Data["MilestoneID"] = milestoneID
  229. ctx.Data["AssigneeID"] = assigneeID
  230. ctx.Data["IsShowClosed"] = isShowClosed
  231. ctx.Data["Keyword"] = keyword
  232. if isShowClosed {
  233. ctx.Data["State"] = "closed"
  234. } else {
  235. ctx.Data["State"] = "open"
  236. }
  237. pager.AddParam(ctx, "q", "Keyword")
  238. pager.AddParam(ctx, "type", "ViewType")
  239. pager.AddParam(ctx, "sort", "SortType")
  240. pager.AddParam(ctx, "state", "State")
  241. pager.AddParam(ctx, "labels", "SelectLabels")
  242. pager.AddParam(ctx, "milestone", "MilestoneID")
  243. pager.AddParam(ctx, "assignee", "AssigneeID")
  244. ctx.Data["Page"] = pager
  245. }
  246. // Issues render issues page
  247. func Issues(ctx *context.Context) {
  248. isPullList := ctx.Params(":type") == "pulls"
  249. if isPullList {
  250. MustAllowPulls(ctx)
  251. if ctx.Written() {
  252. return
  253. }
  254. ctx.Data["Title"] = ctx.Tr("repo.pulls")
  255. ctx.Data["PageIsPullList"] = true
  256. } else {
  257. MustEnableIssues(ctx)
  258. if ctx.Written() {
  259. return
  260. }
  261. ctx.Data["Title"] = ctx.Tr("repo.issues")
  262. ctx.Data["PageIsIssueList"] = true
  263. }
  264. issues(ctx, ctx.QueryInt64("milestone"), util.OptionalBoolOf(isPullList))
  265. var err error
  266. // Get milestones.
  267. ctx.Data["Milestones"], err = models.GetMilestonesByRepoID(ctx.Repo.Repository.ID)
  268. if err != nil {
  269. ctx.ServerError("GetAllRepoMilestones", err)
  270. return
  271. }
  272. perm, err := models.GetUserRepoPermission(ctx.Repo.Repository, ctx.User)
  273. if err != nil {
  274. ctx.ServerError("GetUserRepoPermission", err)
  275. return
  276. }
  277. ctx.Data["CanWriteIssuesOrPulls"] = perm.CanWriteIssuesOrPulls(isPullList)
  278. ctx.HTML(200, tplIssues)
  279. }
  280. // RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
  281. func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repository) {
  282. var err error
  283. ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false, "")
  284. if err != nil {
  285. ctx.ServerError("GetMilestones", err)
  286. return
  287. }
  288. ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true, "")
  289. if err != nil {
  290. ctx.ServerError("GetMilestones", err)
  291. return
  292. }
  293. ctx.Data["Assignees"], err = repo.GetAssignees()
  294. if err != nil {
  295. ctx.ServerError("GetAssignees", err)
  296. return
  297. }
  298. }
  299. // RetrieveRepoMetas find all the meta information of a repository
  300. func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.Label {
  301. if !ctx.Repo.CanWrite(models.UnitTypeIssues) {
  302. return nil
  303. }
  304. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  305. if err != nil {
  306. ctx.ServerError("GetLabelsByRepoID", err)
  307. return nil
  308. }
  309. ctx.Data["Labels"] = labels
  310. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  311. if ctx.Written() {
  312. return nil
  313. }
  314. brs, err := ctx.Repo.GitRepo.GetBranches()
  315. if err != nil {
  316. ctx.ServerError("GetBranches", err)
  317. return nil
  318. }
  319. ctx.Data["Branches"] = brs
  320. // Contains true if the user can create issue dependencies
  321. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  322. return labels
  323. }
  324. func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (string, bool) {
  325. var bytes []byte
  326. if ctx.Repo.Commit == nil {
  327. var err error
  328. ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
  329. if err != nil {
  330. return "", false
  331. }
  332. }
  333. entry, err := ctx.Repo.Commit.GetTreeEntryByPath(filename)
  334. if err != nil {
  335. return "", false
  336. }
  337. if entry.Blob().Size() >= setting.UI.MaxDisplayFileSize {
  338. return "", false
  339. }
  340. r, err := entry.Blob().DataAsync()
  341. if err != nil {
  342. return "", false
  343. }
  344. defer r.Close()
  345. bytes, err = ioutil.ReadAll(r)
  346. if err != nil {
  347. return "", false
  348. }
  349. return string(bytes), true
  350. }
  351. func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles []string) {
  352. for _, filename := range possibleFiles {
  353. content, found := getFileContentFromDefaultBranch(ctx, filename)
  354. if found {
  355. ctx.Data[ctxDataKey] = content
  356. return
  357. }
  358. }
  359. }
  360. // NewIssue render creating issue page
  361. func NewIssue(ctx *context.Context) {
  362. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  363. ctx.Data["PageIsIssueList"] = true
  364. ctx.Data["RequireHighlightJS"] = true
  365. ctx.Data["RequireSimpleMDE"] = true
  366. ctx.Data["RequireTribute"] = true
  367. ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
  368. body := ctx.Query("body")
  369. ctx.Data["BodyQuery"] = body
  370. milestoneID := ctx.QueryInt64("milestone")
  371. milestone, err := models.GetMilestoneByID(milestoneID)
  372. if err != nil {
  373. log.Error("GetMilestoneByID: %d: %v", milestoneID, err)
  374. } else {
  375. ctx.Data["milestone_id"] = milestoneID
  376. ctx.Data["Milestone"] = milestone
  377. }
  378. setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
  379. renderAttachmentSettings(ctx)
  380. RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  381. if ctx.Written() {
  382. return
  383. }
  384. ctx.HTML(200, tplIssueNew)
  385. }
  386. // ValidateRepoMetas check and returns repository's meta informations
  387. func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm, isPull bool) ([]int64, []int64, int64) {
  388. var (
  389. repo = ctx.Repo.Repository
  390. err error
  391. )
  392. labels := RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  393. if ctx.Written() {
  394. return nil, nil, 0
  395. }
  396. var labelIDs []int64
  397. hasSelected := false
  398. // Check labels.
  399. if len(form.LabelIDs) > 0 {
  400. labelIDs, err = base.StringsToInt64s(strings.Split(form.LabelIDs, ","))
  401. if err != nil {
  402. return nil, nil, 0
  403. }
  404. labelIDMark := base.Int64sToMap(labelIDs)
  405. for i := range labels {
  406. if labelIDMark[labels[i].ID] {
  407. labels[i].IsChecked = true
  408. hasSelected = true
  409. }
  410. }
  411. }
  412. ctx.Data["Labels"] = labels
  413. ctx.Data["HasSelectedLabel"] = hasSelected
  414. ctx.Data["label_ids"] = form.LabelIDs
  415. // Check milestone.
  416. milestoneID := form.MilestoneID
  417. if milestoneID > 0 {
  418. ctx.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID)
  419. if err != nil {
  420. ctx.ServerError("GetMilestoneByID", err)
  421. return nil, nil, 0
  422. }
  423. ctx.Data["milestone_id"] = milestoneID
  424. }
  425. // Check assignees
  426. var assigneeIDs []int64
  427. if len(form.AssigneeIDs) > 0 {
  428. assigneeIDs, err = base.StringsToInt64s(strings.Split(form.AssigneeIDs, ","))
  429. if err != nil {
  430. return nil, nil, 0
  431. }
  432. // Check if the passed assignees actually exists and has write access to the repo
  433. for _, aID := range assigneeIDs {
  434. user, err := models.GetUserByID(aID)
  435. if err != nil {
  436. ctx.ServerError("GetUserByID", err)
  437. return nil, nil, 0
  438. }
  439. perm, err := models.GetUserRepoPermission(repo, user)
  440. if err != nil {
  441. ctx.ServerError("GetUserRepoPermission", err)
  442. return nil, nil, 0
  443. }
  444. if !perm.CanWriteIssuesOrPulls(isPull) {
  445. ctx.ServerError("CanWriteIssuesOrPulls", fmt.Errorf("No permission for %s", user.Name))
  446. return nil, nil, 0
  447. }
  448. }
  449. }
  450. // Keep the old assignee id thingy for compatibility reasons
  451. if form.AssigneeID > 0 {
  452. assigneeIDs = append(assigneeIDs, form.AssigneeID)
  453. }
  454. return labelIDs, assigneeIDs, milestoneID
  455. }
  456. // NewIssuePost response for creating new issue
  457. func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
  458. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  459. ctx.Data["PageIsIssueList"] = true
  460. ctx.Data["RequireHighlightJS"] = true
  461. ctx.Data["RequireSimpleMDE"] = true
  462. ctx.Data["ReadOnly"] = false
  463. ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
  464. renderAttachmentSettings(ctx)
  465. var (
  466. repo = ctx.Repo.Repository
  467. attachments []string
  468. )
  469. labelIDs, assigneeIDs, milestoneID := ValidateRepoMetas(ctx, form, false)
  470. if ctx.Written() {
  471. return
  472. }
  473. if setting.AttachmentEnabled {
  474. attachments = form.Files
  475. }
  476. if ctx.HasError() {
  477. ctx.HTML(200, tplIssueNew)
  478. return
  479. }
  480. if util.IsEmptyString(form.Title) {
  481. ctx.RenderWithErr(ctx.Tr("repo.issues.new.title_empty"), tplIssueNew, form)
  482. return
  483. }
  484. issue := &models.Issue{
  485. RepoID: repo.ID,
  486. Title: form.Title,
  487. PosterID: ctx.User.ID,
  488. Poster: ctx.User,
  489. MilestoneID: milestoneID,
  490. Content: form.Content,
  491. Ref: form.Ref,
  492. }
  493. if err := models.NewIssue(repo, issue, labelIDs, assigneeIDs, attachments); err != nil {
  494. if models.IsErrUserDoesNotHaveAccessToRepo(err) {
  495. ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error())
  496. return
  497. }
  498. ctx.ServerError("NewIssue", err)
  499. return
  500. }
  501. notification.NotifyNewIssue(issue)
  502. log.Trace("Issue created: %d/%d", repo.ID, issue.ID)
  503. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  504. }
  505. // commentTag returns the CommentTag for a comment in/with the given repo, poster and issue
  506. func commentTag(repo *models.Repository, poster *models.User, issue *models.Issue) (models.CommentTag, error) {
  507. perm, err := models.GetUserRepoPermission(repo, poster)
  508. if err != nil {
  509. return models.CommentTagNone, err
  510. }
  511. if perm.IsOwner() {
  512. return models.CommentTagOwner, nil
  513. } else if poster.ID == issue.PosterID {
  514. return models.CommentTagPoster, nil
  515. } else if perm.CanWrite(models.UnitTypeCode) {
  516. return models.CommentTagWriter, nil
  517. }
  518. return models.CommentTagNone, nil
  519. }
  520. // ViewIssue render issue view page
  521. func ViewIssue(ctx *context.Context) {
  522. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  523. if err != nil {
  524. if models.IsErrIssueNotExist(err) {
  525. ctx.NotFound("GetIssueByIndex", err)
  526. } else {
  527. ctx.ServerError("GetIssueByIndex", err)
  528. }
  529. return
  530. }
  531. // Make sure type and URL matches.
  532. if ctx.Params(":type") == "issues" && issue.IsPull {
  533. ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
  534. return
  535. } else if ctx.Params(":type") == "pulls" && !issue.IsPull {
  536. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  537. return
  538. }
  539. if issue.IsPull {
  540. MustAllowPulls(ctx)
  541. if ctx.Written() {
  542. return
  543. }
  544. ctx.Data["PageIsPullList"] = true
  545. ctx.Data["PageIsPullConversation"] = true
  546. } else {
  547. MustEnableIssues(ctx)
  548. if ctx.Written() {
  549. return
  550. }
  551. ctx.Data["PageIsIssueList"] = true
  552. }
  553. ctx.Data["RequireHighlightJS"] = true
  554. ctx.Data["RequireDropzone"] = true
  555. ctx.Data["RequireTribute"] = true
  556. renderAttachmentSettings(ctx)
  557. err = issue.LoadAttributes()
  558. if err != nil {
  559. ctx.ServerError("GetIssueByIndex", err)
  560. return
  561. }
  562. ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
  563. var iw *models.IssueWatch
  564. var exists bool
  565. if ctx.User != nil {
  566. iw, exists, err = models.GetIssueWatch(ctx.User.ID, issue.ID)
  567. if err != nil {
  568. ctx.ServerError("GetIssueWatch", err)
  569. return
  570. }
  571. if !exists {
  572. iw = &models.IssueWatch{
  573. UserID: ctx.User.ID,
  574. IssueID: issue.ID,
  575. IsWatching: models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID),
  576. }
  577. }
  578. }
  579. ctx.Data["IssueWatch"] = iw
  580. issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink,
  581. ctx.Repo.Repository.ComposeMetas()))
  582. repo := ctx.Repo.Repository
  583. // Get more information if it's a pull request.
  584. if issue.IsPull {
  585. if issue.PullRequest.HasMerged {
  586. ctx.Data["DisableStatusChange"] = issue.PullRequest.HasMerged
  587. PrepareMergedViewPullInfo(ctx, issue)
  588. } else {
  589. PrepareViewPullInfo(ctx, issue)
  590. }
  591. if ctx.Written() {
  592. return
  593. }
  594. }
  595. // Metas.
  596. // Check labels.
  597. labelIDMark := make(map[int64]bool)
  598. for i := range issue.Labels {
  599. labelIDMark[issue.Labels[i].ID] = true
  600. }
  601. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  602. if err != nil {
  603. ctx.ServerError("GetLabelsByRepoID", err)
  604. return
  605. }
  606. hasSelected := false
  607. for i := range labels {
  608. if labelIDMark[labels[i].ID] {
  609. labels[i].IsChecked = true
  610. hasSelected = true
  611. }
  612. }
  613. ctx.Data["HasSelectedLabel"] = hasSelected
  614. ctx.Data["Labels"] = labels
  615. // Check milestone and assignee.
  616. if ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
  617. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  618. if ctx.Written() {
  619. return
  620. }
  621. }
  622. if ctx.IsSigned {
  623. // Update issue-user.
  624. if err = issue.ReadBy(ctx.User.ID); err != nil {
  625. ctx.ServerError("ReadBy", err)
  626. return
  627. }
  628. }
  629. var (
  630. tag models.CommentTag
  631. ok bool
  632. marked = make(map[int64]models.CommentTag)
  633. comment *models.Comment
  634. participants = make([]*models.User, 1, 10)
  635. )
  636. if ctx.Repo.Repository.IsTimetrackerEnabled() {
  637. if ctx.IsSigned {
  638. // Deal with the stopwatch
  639. ctx.Data["IsStopwatchRunning"] = models.StopwatchExists(ctx.User.ID, issue.ID)
  640. if !ctx.Data["IsStopwatchRunning"].(bool) {
  641. var exists bool
  642. var sw *models.Stopwatch
  643. if exists, sw, err = models.HasUserStopwatch(ctx.User.ID); err != nil {
  644. ctx.ServerError("HasUserStopwatch", err)
  645. return
  646. }
  647. ctx.Data["HasUserStopwatch"] = exists
  648. if exists {
  649. // Add warning if the user has already a stopwatch
  650. var otherIssue *models.Issue
  651. if otherIssue, err = models.GetIssueByID(sw.IssueID); err != nil {
  652. ctx.ServerError("GetIssueByID", err)
  653. return
  654. }
  655. if err = otherIssue.LoadRepo(); err != nil {
  656. ctx.ServerError("LoadRepo", err)
  657. return
  658. }
  659. // Add link to the issue of the already running stopwatch
  660. ctx.Data["OtherStopwatchURL"] = otherIssue.HTMLURL()
  661. }
  662. }
  663. ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.User)
  664. } else {
  665. ctx.Data["CanUseTimetracker"] = false
  666. }
  667. if ctx.Data["WorkingUsers"], err = models.TotalTimes(models.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil {
  668. ctx.ServerError("TotalTimes", err)
  669. return
  670. }
  671. }
  672. // Check if the user can use the dependencies
  673. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  674. // Render comments and and fetch participants.
  675. participants[0] = issue.Poster
  676. for _, comment = range issue.Comments {
  677. if err := comment.LoadPoster(); err != nil {
  678. ctx.ServerError("LoadPoster", err)
  679. return
  680. }
  681. if comment.Type == models.CommentTypeComment {
  682. if err := comment.LoadAttachments(); err != nil {
  683. ctx.ServerError("LoadAttachments", err)
  684. return
  685. }
  686. comment.RenderedContent = string(markdown.Render([]byte(comment.Content), ctx.Repo.RepoLink,
  687. ctx.Repo.Repository.ComposeMetas()))
  688. // Check tag.
  689. tag, ok = marked[comment.PosterID]
  690. if ok {
  691. comment.ShowTag = tag
  692. continue
  693. }
  694. comment.ShowTag, err = commentTag(repo, comment.Poster, issue)
  695. if err != nil {
  696. ctx.ServerError("commentTag", err)
  697. return
  698. }
  699. marked[comment.PosterID] = comment.ShowTag
  700. isAdded := false
  701. for j := range participants {
  702. if comment.Poster == participants[j] {
  703. isAdded = true
  704. break
  705. }
  706. }
  707. if !isAdded && !issue.IsPoster(comment.Poster.ID) {
  708. participants = append(participants, comment.Poster)
  709. }
  710. } else if comment.Type == models.CommentTypeLabel {
  711. if err = comment.LoadLabel(); err != nil {
  712. ctx.ServerError("LoadLabel", err)
  713. return
  714. }
  715. } else if comment.Type == models.CommentTypeMilestone {
  716. if err = comment.LoadMilestone(); err != nil {
  717. ctx.ServerError("LoadMilestone", err)
  718. return
  719. }
  720. ghostMilestone := &models.Milestone{
  721. ID: -1,
  722. Name: ctx.Tr("repo.issues.deleted_milestone"),
  723. }
  724. if comment.OldMilestoneID > 0 && comment.OldMilestone == nil {
  725. comment.OldMilestone = ghostMilestone
  726. }
  727. if comment.MilestoneID > 0 && comment.Milestone == nil {
  728. comment.Milestone = ghostMilestone
  729. }
  730. } else if comment.Type == models.CommentTypeAssignees {
  731. if err = comment.LoadAssigneeUser(); err != nil {
  732. ctx.ServerError("LoadAssigneeUser", err)
  733. return
  734. }
  735. } else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency {
  736. if err = comment.LoadDepIssueDetails(); err != nil {
  737. ctx.ServerError("LoadDepIssueDetails", err)
  738. return
  739. }
  740. } else if comment.Type == models.CommentTypeCode || comment.Type == models.CommentTypeReview {
  741. if err = comment.LoadReview(); err != nil && !models.IsErrReviewNotExist(err) {
  742. ctx.ServerError("LoadReview", err)
  743. return
  744. }
  745. if comment.Review == nil {
  746. continue
  747. }
  748. if err = comment.Review.LoadAttributes(); err != nil {
  749. ctx.ServerError("Review.LoadAttributes", err)
  750. return
  751. }
  752. if err = comment.Review.LoadCodeComments(); err != nil {
  753. ctx.ServerError("Review.LoadCodeComments", err)
  754. return
  755. }
  756. }
  757. }
  758. if issue.IsPull {
  759. pull := issue.PullRequest
  760. pull.Issue = issue
  761. canDelete := false
  762. if ctx.IsSigned {
  763. if err := pull.GetHeadRepo(); err != nil {
  764. log.Error("GetHeadRepo: %v", err)
  765. } else if pull.HeadRepo != nil && pull.HeadBranch != pull.HeadRepo.DefaultBranch {
  766. perm, err := models.GetUserRepoPermission(pull.HeadRepo, ctx.User)
  767. if err != nil {
  768. ctx.ServerError("GetUserRepoPermission", err)
  769. return
  770. }
  771. if perm.CanWrite(models.UnitTypeCode) {
  772. // Check if branch is not protected
  773. if protected, err := pull.HeadRepo.IsProtectedBranch(pull.HeadBranch, ctx.User); err != nil {
  774. log.Error("IsProtectedBranch: %v", err)
  775. } else if !protected {
  776. canDelete = true
  777. ctx.Data["DeleteBranchLink"] = ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index) + "/cleanup"
  778. }
  779. }
  780. }
  781. }
  782. prUnit, err := repo.GetUnit(models.UnitTypePullRequests)
  783. if err != nil {
  784. ctx.ServerError("GetUnit", err)
  785. return
  786. }
  787. prConfig := prUnit.PullRequestsConfig()
  788. ctx.Data["AllowMerge"] = ctx.Repo.CanWrite(models.UnitTypeCode)
  789. if err := pull.CheckUserAllowedToMerge(ctx.User); err != nil {
  790. if !models.IsErrNotAllowedToMerge(err) {
  791. ctx.ServerError("CheckUserAllowedToMerge", err)
  792. return
  793. }
  794. ctx.Data["AllowMerge"] = false
  795. }
  796. // Check correct values and select default
  797. if ms, ok := ctx.Data["MergeStyle"].(models.MergeStyle); !ok ||
  798. !prConfig.IsMergeStyleAllowed(ms) {
  799. if prConfig.AllowMerge {
  800. ctx.Data["MergeStyle"] = models.MergeStyleMerge
  801. } else if prConfig.AllowRebase {
  802. ctx.Data["MergeStyle"] = models.MergeStyleRebase
  803. } else if prConfig.AllowRebaseMerge {
  804. ctx.Data["MergeStyle"] = models.MergeStyleRebaseMerge
  805. } else if prConfig.AllowSquash {
  806. ctx.Data["MergeStyle"] = models.MergeStyleSquash
  807. } else {
  808. ctx.Data["MergeStyle"] = ""
  809. }
  810. }
  811. if err = pull.LoadProtectedBranch(); err != nil {
  812. ctx.ServerError("LoadProtectedBranch", err)
  813. return
  814. }
  815. if pull.ProtectedBranch != nil {
  816. cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull)
  817. ctx.Data["IsBlockedByApprovals"] = pull.ProtectedBranch.RequiredApprovals > 0 && cnt < pull.ProtectedBranch.RequiredApprovals
  818. ctx.Data["GrantedApprovals"] = cnt
  819. }
  820. ctx.Data["IsPullBranchDeletable"] = canDelete && pull.HeadRepo != nil && git.IsBranchExist(pull.HeadRepo.RepoPath(), pull.HeadBranch)
  821. ctx.Data["PullReviewersWithType"], err = models.GetReviewersByPullID(issue.ID)
  822. if err != nil {
  823. ctx.ServerError("GetReviewersByPullID", err)
  824. return
  825. }
  826. }
  827. // Get Dependencies
  828. ctx.Data["BlockedByDependencies"], err = issue.BlockedByDependencies()
  829. ctx.Data["BlockingDependencies"], err = issue.BlockingDependencies()
  830. ctx.Data["Participants"] = participants
  831. ctx.Data["NumParticipants"] = len(participants)
  832. ctx.Data["Issue"] = issue
  833. ctx.Data["ReadOnly"] = true
  834. ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string)
  835. ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID)
  836. ctx.Data["IsIssueWriter"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
  837. ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.User.IsAdmin)
  838. ctx.Data["IsRepoIssuesWriter"] = ctx.IsSigned && (ctx.Repo.CanWrite(models.UnitTypeIssues) || ctx.User.IsAdmin)
  839. ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons
  840. ctx.HTML(200, tplIssueView)
  841. }
  842. // GetActionIssue will return the issue which is used in the context.
  843. func GetActionIssue(ctx *context.Context) *models.Issue {
  844. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  845. if err != nil {
  846. ctx.NotFoundOrServerError("GetIssueByIndex", models.IsErrIssueNotExist, err)
  847. return nil
  848. }
  849. issue.Repo = ctx.Repo.Repository
  850. checkIssueRights(ctx, issue)
  851. if ctx.Written() {
  852. return nil
  853. }
  854. if err = issue.LoadAttributes(); err != nil {
  855. ctx.ServerError("LoadAttributes", nil)
  856. return nil
  857. }
  858. return issue
  859. }
  860. func checkIssueRights(ctx *context.Context, issue *models.Issue) {
  861. if issue.IsPull && !ctx.Repo.CanRead(models.UnitTypePullRequests) ||
  862. !issue.IsPull && !ctx.Repo.CanRead(models.UnitTypeIssues) {
  863. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  864. }
  865. }
  866. func getActionIssues(ctx *context.Context) []*models.Issue {
  867. commaSeparatedIssueIDs := ctx.Query("issue_ids")
  868. if len(commaSeparatedIssueIDs) == 0 {
  869. return nil
  870. }
  871. issueIDs := make([]int64, 0, 10)
  872. for _, stringIssueID := range strings.Split(commaSeparatedIssueIDs, ",") {
  873. issueID, err := strconv.ParseInt(stringIssueID, 10, 64)
  874. if err != nil {
  875. ctx.ServerError("ParseInt", err)
  876. return nil
  877. }
  878. issueIDs = append(issueIDs, issueID)
  879. }
  880. issues, err := models.GetIssuesByIDs(issueIDs)
  881. if err != nil {
  882. ctx.ServerError("GetIssuesByIDs", err)
  883. return nil
  884. }
  885. // Check access rights for all issues
  886. issueUnitEnabled := ctx.Repo.CanRead(models.UnitTypeIssues)
  887. prUnitEnabled := ctx.Repo.CanRead(models.UnitTypePullRequests)
  888. for _, issue := range issues {
  889. if issue.IsPull && !prUnitEnabled || !issue.IsPull && !issueUnitEnabled {
  890. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  891. return nil
  892. }
  893. if err = issue.LoadAttributes(); err != nil {
  894. ctx.ServerError("LoadAttributes", err)
  895. return nil
  896. }
  897. }
  898. return issues
  899. }
  900. // UpdateIssueTitle change issue's title
  901. func UpdateIssueTitle(ctx *context.Context) {
  902. issue := GetActionIssue(ctx)
  903. if ctx.Written() {
  904. return
  905. }
  906. if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
  907. ctx.Error(403)
  908. return
  909. }
  910. title := ctx.QueryTrim("title")
  911. if len(title) == 0 {
  912. ctx.Error(204)
  913. return
  914. }
  915. if err := issue.ChangeTitle(ctx.User, title); err != nil {
  916. ctx.ServerError("ChangeTitle", err)
  917. return
  918. }
  919. ctx.JSON(200, map[string]interface{}{
  920. "title": issue.Title,
  921. })
  922. }
  923. // UpdateIssueContent change issue's content
  924. func UpdateIssueContent(ctx *context.Context) {
  925. issue := GetActionIssue(ctx)
  926. if ctx.Written() {
  927. return
  928. }
  929. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
  930. ctx.Error(403)
  931. return
  932. }
  933. content := ctx.Query("content")
  934. if err := issue.ChangeContent(ctx.User, content); err != nil {
  935. ctx.ServerError("ChangeContent", err)
  936. return
  937. }
  938. ctx.JSON(200, map[string]interface{}{
  939. "content": string(markdown.Render([]byte(issue.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  940. })
  941. }
  942. // UpdateIssueMilestone change issue's milestone
  943. func UpdateIssueMilestone(ctx *context.Context) {
  944. issues := getActionIssues(ctx)
  945. if ctx.Written() {
  946. return
  947. }
  948. milestoneID := ctx.QueryInt64("id")
  949. for _, issue := range issues {
  950. oldMilestoneID := issue.MilestoneID
  951. if oldMilestoneID == milestoneID {
  952. continue
  953. }
  954. issue.MilestoneID = milestoneID
  955. if err := models.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
  956. ctx.ServerError("ChangeMilestoneAssign", err)
  957. return
  958. }
  959. }
  960. ctx.JSON(200, map[string]interface{}{
  961. "ok": true,
  962. })
  963. }
  964. // UpdateIssueAssignee change issue's assignee
  965. func UpdateIssueAssignee(ctx *context.Context) {
  966. issues := getActionIssues(ctx)
  967. if ctx.Written() {
  968. return
  969. }
  970. assigneeID := ctx.QueryInt64("id")
  971. action := ctx.Query("action")
  972. for _, issue := range issues {
  973. switch action {
  974. case "clear":
  975. if err := models.DeleteNotPassedAssignee(issue, ctx.User, []*models.User{}); err != nil {
  976. ctx.ServerError("ClearAssignees", err)
  977. return
  978. }
  979. default:
  980. if err := issue.ChangeAssignee(ctx.User, assigneeID); err != nil {
  981. ctx.ServerError("ChangeAssignee", err)
  982. return
  983. }
  984. }
  985. }
  986. ctx.JSON(200, map[string]interface{}{
  987. "ok": true,
  988. })
  989. }
  990. // UpdateIssueStatus change issue's status
  991. func UpdateIssueStatus(ctx *context.Context) {
  992. issues := getActionIssues(ctx)
  993. if ctx.Written() {
  994. return
  995. }
  996. var isClosed bool
  997. switch action := ctx.Query("action"); action {
  998. case "open":
  999. isClosed = false
  1000. case "close":
  1001. isClosed = true
  1002. default:
  1003. log.Warn("Unrecognized action: %s", action)
  1004. }
  1005. if _, err := models.IssueList(issues).LoadRepositories(); err != nil {
  1006. ctx.ServerError("LoadRepositories", err)
  1007. return
  1008. }
  1009. for _, issue := range issues {
  1010. if issue.IsClosed != isClosed {
  1011. if err := issue.ChangeStatus(ctx.User, isClosed); err != nil {
  1012. if models.IsErrDependenciesLeft(err) {
  1013. ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{
  1014. "error": "cannot close this issue because it still has open dependencies",
  1015. })
  1016. return
  1017. }
  1018. ctx.ServerError("ChangeStatus", err)
  1019. return
  1020. }
  1021. notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed)
  1022. }
  1023. }
  1024. ctx.JSON(200, map[string]interface{}{
  1025. "ok": true,
  1026. })
  1027. }
  1028. // NewComment create a comment for issue
  1029. func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
  1030. issue := GetActionIssue(ctx)
  1031. if ctx.Written() {
  1032. return
  1033. }
  1034. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
  1035. ctx.Error(403)
  1036. }
  1037. if issue.IsLocked && !ctx.Repo.CanWrite(models.UnitTypeIssues) && !ctx.User.IsAdmin {
  1038. ctx.Flash.Error(ctx.Tr("repo.issues.comment_on_locked"))
  1039. ctx.Redirect(issue.HTMLURL(), http.StatusSeeOther)
  1040. return
  1041. }
  1042. var attachments []string
  1043. if setting.AttachmentEnabled {
  1044. attachments = form.Files
  1045. }
  1046. if ctx.HasError() {
  1047. ctx.Flash.Error(ctx.Data["ErrorMsg"].(string))
  1048. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index))
  1049. return
  1050. }
  1051. var comment *models.Comment
  1052. defer func() {
  1053. // Check if issue admin/poster changes the status of issue.
  1054. if (ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))) &&
  1055. (form.Status == "reopen" || form.Status == "close") &&
  1056. !(issue.IsPull && issue.PullRequest.HasMerged) {
  1057. // Duplication and conflict check should apply to reopen pull request.
  1058. var pr *models.PullRequest
  1059. if form.Status == "reopen" && issue.IsPull {
  1060. pull := issue.PullRequest
  1061. pr, err := models.GetUnmergedPullRequest(pull.HeadRepoID, pull.BaseRepoID, pull.HeadBranch, pull.BaseBranch)
  1062. if err != nil {
  1063. if !models.IsErrPullRequestNotExist(err) {
  1064. ctx.ServerError("GetUnmergedPullRequest", err)
  1065. return
  1066. }
  1067. }
  1068. // Regenerate patch and test conflict.
  1069. if pr == nil {
  1070. if err = issue.PullRequest.UpdatePatch(); err != nil {
  1071. ctx.ServerError("UpdatePatch", err)
  1072. return
  1073. }
  1074. issue.PullRequest.AddToTaskQueue()
  1075. }
  1076. }
  1077. if pr != nil {
  1078. ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
  1079. } else {
  1080. isClosed := form.Status == "close"
  1081. if err := issue.ChangeStatus(ctx.User, isClosed); err != nil {
  1082. log.Error("ChangeStatus: %v", err)
  1083. if models.IsErrDependenciesLeft(err) {
  1084. if issue.IsPull {
  1085. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.pr_close_blocked"))
  1086. ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  1087. } else {
  1088. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.issue_close_blocked"))
  1089. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  1090. }
  1091. return
  1092. }
  1093. } else {
  1094. if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
  1095. ctx.ServerError("CreateOrStopIssueStopwatch", err)
  1096. return
  1097. }
  1098. log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
  1099. notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed)
  1100. }
  1101. }
  1102. }
  1103. // Redirect to comment hashtag if there is any actual content.
  1104. typeName := "issues"
  1105. if issue.IsPull {
  1106. typeName = "pulls"
  1107. }
  1108. if comment != nil {
  1109. ctx.Redirect(fmt.Sprintf("%s/%s/%d#%s", ctx.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
  1110. } else {
  1111. ctx.Redirect(fmt.Sprintf("%s/%s/%d", ctx.Repo.RepoLink, typeName, issue.Index))
  1112. }
  1113. }()
  1114. // Fix #321: Allow empty comments, as long as we have attachments.
  1115. if len(form.Content) == 0 && len(attachments) == 0 {
  1116. return
  1117. }
  1118. comment, err := models.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Content, attachments)
  1119. if err != nil {
  1120. ctx.ServerError("CreateIssueComment", err)
  1121. return
  1122. }
  1123. notification.NotifyCreateIssueComment(ctx.User, ctx.Repo.Repository, issue, comment)
  1124. log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
  1125. }
  1126. // UpdateCommentContent change comment of issue's content
  1127. func UpdateCommentContent(ctx *context.Context) {
  1128. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1129. if err != nil {
  1130. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1131. return
  1132. }
  1133. if err := comment.LoadIssue(); err != nil {
  1134. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1135. return
  1136. }
  1137. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
  1138. ctx.Error(403)
  1139. return
  1140. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1141. ctx.Error(204)
  1142. return
  1143. }
  1144. oldContent := comment.Content
  1145. comment.Content = ctx.Query("content")
  1146. if len(comment.Content) == 0 {
  1147. ctx.JSON(200, map[string]interface{}{
  1148. "content": "",
  1149. })
  1150. return
  1151. }
  1152. if err = models.UpdateComment(ctx.User, comment, oldContent); err != nil {
  1153. ctx.ServerError("UpdateComment", err)
  1154. return
  1155. }
  1156. notification.NotifyUpdateComment(ctx.User, comment, oldContent)
  1157. ctx.JSON(200, map[string]interface{}{
  1158. "content": string(markdown.Render([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  1159. })
  1160. }
  1161. // DeleteComment delete comment of issue
  1162. func DeleteComment(ctx *context.Context) {
  1163. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1164. if err != nil {
  1165. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1166. return
  1167. }
  1168. if err := comment.LoadIssue(); err != nil {
  1169. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1170. return
  1171. }
  1172. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
  1173. ctx.Error(403)
  1174. return
  1175. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1176. ctx.Error(204)
  1177. return
  1178. }
  1179. if err = models.DeleteComment(ctx.User, comment); err != nil {
  1180. ctx.ServerError("DeleteCommentByID", err)
  1181. return
  1182. }
  1183. notification.NotifyDeleteComment(ctx.User, comment)
  1184. ctx.Status(200)
  1185. }
  1186. // ChangeIssueReaction create a reaction for issue
  1187. func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
  1188. issue := GetActionIssue(ctx)
  1189. if ctx.Written() {
  1190. return
  1191. }
  1192. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
  1193. ctx.Error(403)
  1194. return
  1195. }
  1196. if ctx.HasError() {
  1197. ctx.ServerError("ChangeIssueReaction", errors.New(ctx.GetErrMsg()))
  1198. return
  1199. }
  1200. switch ctx.Params(":action") {
  1201. case "react":
  1202. reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
  1203. if err != nil {
  1204. log.Info("CreateIssueReaction: %s", err)
  1205. break
  1206. }
  1207. // Reload new reactions
  1208. issue.Reactions = nil
  1209. if err = issue.LoadAttributes(); err != nil {
  1210. log.Info("issue.LoadAttributes: %s", err)
  1211. break
  1212. }
  1213. log.Trace("Reaction for issue created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, reaction.ID)
  1214. case "unreact":
  1215. if err := models.DeleteIssueReaction(ctx.User, issue, form.Content); err != nil {
  1216. ctx.ServerError("DeleteIssueReaction", err)
  1217. return
  1218. }
  1219. // Reload new reactions
  1220. issue.Reactions = nil
  1221. if err := issue.LoadAttributes(); err != nil {
  1222. log.Info("issue.LoadAttributes: %s", err)
  1223. break
  1224. }
  1225. log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID)
  1226. default:
  1227. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1228. return
  1229. }
  1230. if len(issue.Reactions) == 0 {
  1231. ctx.JSON(200, map[string]interface{}{
  1232. "empty": true,
  1233. "html": "",
  1234. })
  1235. return
  1236. }
  1237. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1238. "ctx": ctx.Data,
  1239. "ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index),
  1240. "Reactions": issue.Reactions.GroupByType(),
  1241. })
  1242. if err != nil {
  1243. ctx.ServerError("ChangeIssueReaction.HTMLString", err)
  1244. return
  1245. }
  1246. ctx.JSON(200, map[string]interface{}{
  1247. "html": html,
  1248. })
  1249. }
  1250. // ChangeCommentReaction create a reaction for comment
  1251. func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
  1252. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1253. if err != nil {
  1254. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1255. return
  1256. }
  1257. if err := comment.LoadIssue(); err != nil {
  1258. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1259. return
  1260. }
  1261. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull)) {
  1262. ctx.Error(403)
  1263. return
  1264. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1265. ctx.Error(204)
  1266. return
  1267. }
  1268. switch ctx.Params(":action") {
  1269. case "react":
  1270. reaction, err := models.CreateCommentReaction(ctx.User, comment.Issue, comment, form.Content)
  1271. if err != nil {
  1272. log.Info("CreateCommentReaction: %s", err)
  1273. break
  1274. }
  1275. // Reload new reactions
  1276. comment.Reactions = nil
  1277. if err = comment.LoadReactions(); err != nil {
  1278. log.Info("comment.LoadReactions: %s", err)
  1279. break
  1280. }
  1281. log.Trace("Reaction for comment created: %d/%d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID, reaction.ID)
  1282. case "unreact":
  1283. if err := models.DeleteCommentReaction(ctx.User, comment.Issue, comment, form.Content); err != nil {
  1284. ctx.ServerError("DeleteCommentReaction", err)
  1285. return
  1286. }
  1287. // Reload new reactions
  1288. comment.Reactions = nil
  1289. if err = comment.LoadReactions(); err != nil {
  1290. log.Info("comment.LoadReactions: %s", err)
  1291. break
  1292. }
  1293. log.Trace("Reaction for comment removed: %d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID)
  1294. default:
  1295. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1296. return
  1297. }
  1298. if len(comment.Reactions) == 0 {
  1299. ctx.JSON(200, map[string]interface{}{
  1300. "empty": true,
  1301. "html": "",
  1302. })
  1303. return
  1304. }
  1305. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1306. "ctx": ctx.Data,
  1307. "ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID),
  1308. "Reactions": comment.Reactions.GroupByType(),
  1309. })
  1310. if err != nil {
  1311. ctx.ServerError("ChangeCommentReaction.HTMLString", err)
  1312. return
  1313. }
  1314. ctx.JSON(200, map[string]interface{}{
  1315. "html": html,
  1316. })
  1317. }