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 49 kB

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