summaryrefslogtreecommitdiff
path: root/app/models
Commit message (Collapse)AuthorAgeFilesLines
* Added concern for a faster "cache_key" methodfaster-cache-keysYorick Peterse2016-08-083-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | This concern provides an optimized/simplified version of the "cache_key" method. This method is about 9 times faster than the default "cache_key" method. The produced cache keys _are_ different from the previous ones but this is worth the performance improvement. To showcase this I set up a benchmark (using benchmark-ips) that compares FasterCacheKeys#cache_key with the regular cache_key. The output of this benchmark was: Calculating ------------------------------------- cache_key 4.825k i/100ms cache_key_fast 21.723k i/100ms ------------------------------------------------- cache_key 59.422k (± 7.2%) i/s - 299.150k cache_key_fast 543.243k (± 9.2%) i/s - 2.694M Comparison: cache_key_fast: 543243.4 i/s cache_key: 59422.0 i/s - 9.14x slower To see the impact on real code I applied these changes and benchmarked Issue#referenced_merge_requests. For an issue referencing 10 merge requests these changes shaved off between 40 and 60 milliseconds.
* Move abilities by subject class to a dedicated method20621-avoid-lame-conflicts-in-ability-allowedRémy Coutable2016-08-041-0/+4
| | | | | | This will avoid lame conflicts when merging CE to EE Signed-off-by: Rémy Coutable <remy@rymai.me>
* Merge branch ↵Rémy Coutable2016-08-042-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | '20512-fix-rename-add-users-into-project-to-add-users-to-project-and-projects-ids-to-project-ids' into 'master' Fix Rename `add_users_into_project` and `projects_ids` ## What does this MR do? Only modifies the name of a method that leaves more semantic and expressive and the name of the keywords arguments to the rails convention. ## Are there points in the code the reviewer needs to double check? Only if it has been changed at every point that is calling this method and that passing arguments. ## Why was this MR needed? To make the code more expressive. ## What are the relevant issue numbers? Closes #20512. - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5659
| * Fix Rename `add_users_into_project` and `projects_ids`Herminio Torres2016-08-042-4/+4
| | | | | | | | | | | | We never add things `into` projects, we just add them `to` projects. So how about we rename this to `add_users_to_project`. Rename `projects_ids` to `project_ids` by following the convention of rails.
* | Merge branch 'fix/ha-mode-import-issue' into 'master' Rémy Coutable2016-08-041-5/+0
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix Import/Export not working in HA mode Use a shared path instead of `Tempfile` default `/tmp` so the import file is accessible by any GitLab instance. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/20506 - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5618
| * using shared path for project import uploads and refactored gitlab remove ↵James Lopez2016-08-041-5/+0
| | | | | | | | export worker
* | change the API on the merge_request_diff model from diffs -> raw_diffsuse-raw-diffs-for-merge-request-diffsPaco Guzman2016-08-032-6/+6
| |
* | Use only deltas in diffs when scanning the last commit for changes in the ↵Stan Hu2016-08-031-1/+1
| | | | | | | | avatar to save memory
* | Speed up Commit#repo_changesAhmad Sherif2016-08-031-1/+1
| |
* | Make Compare#diffs diff_options a regular argumentDouwe Maan2016-08-032-2/+2
| |
* | switch from diff_file_collection to diffs20034-safe-diffsPaco Guzman2016-08-035-28/+32
| | | | | | | | So we have raw_diffs too
* | Introduce Compare model in the codebase.Paco Guzman2016-08-033-5/+52
| | | | | | This object will manage Gitlab::Git::Compare instances
* | Move to Gitlab::Diff::FileCollectionPaco Guzman2016-08-038-132/+31
| | | | | | Instead calling diff_collection.count use diff_collection.size which is cache on the diff_collection
* | Cache highlighted diff lines for merge requestsPaco Guzman2016-08-036-0/+134
| | | | | | | | Introducing the concept of SafeDiffs which relates diffs with UI highlighting.
* | Merge branch '18866-add-simple-identifier-to-public-ssh-keys' into 'master' Douwe Maan2016-08-021-2/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add simple identifier to public SSH keys ## What does this MR do? Adds a simple identifier of user_name + hostname to public SSH keys ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? To help people identify keys when they export them ## What are the relevant issue numbers? #18866 ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [ x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ -] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ -] API support added - Tests - [ x] Added for this feature/bug - [ x] All builds are passing - [ x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) Closes #18866 See merge request !5614
| * | Add simple identifier to public SSH keysKeith Pope2016-08-021-2/+3
| | |
* | | Expand commit message width in repo viewClement Ho2016-08-021-6/+8
| | |
* | | Speedup DiffNote#active? on discussions, preloading noteables and avoid ↵Paco Guzman2016-08-024-3/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | touching git repository to return diff_refs when possible - Preloading noteable we share the same noteable instance when more than one discussion refers to the same noteable. - Any other call to that object that is cached in that object will be for any discussion. - In those cases where merge_request_diff has all the sha stored to build a diff_refs get that diff_refs using directly those sha instead accessing to the git repository to first get the commits and later the sha.
* | | Merge branch 'handle-disabled-request-store' into 'master' Yorick Peterse2016-08-021-2/+7
|\ \ \ | |_|/ |/| | | | | | | | Only use RequestStore in ProjectTeam#max_member_access_for_users if it is active See merge request !5604
| * | Only use RequestStore in ProjectTeam#max_member_access_for_user if it is activeStan Hu2016-08-011-2/+7
| |/
* | Merge branch 'fix-gh-pull-requests' into 'master' Rémy Coutable2016-08-011-2/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix attr reader to force the intended values for source and target shas ## What does this MR do? When importing a pull request from GitHub, the old and new branches may no longer actually exist by those names, but we need to recreate the merge request diff with the right source and target shas. We use these `target_branch_sha` and `source_branch_sha` attributes to force these to the intended values. But the reader methods were always looking up to the target/source branch head instead of check if these values was previously set, this MR applies a memoization pattern to both of them. ## Are there points in the code the reviewer needs to double check? This [commit](https://gitlab.com/gitlab-org/gitlab-ce/commit/6ce25e7b4caa9e94de74378729178c7060d640b2) introduced this bug in the importer. ## What are the relevant issue numbers? gitlab-org/gitlab-ce#20385 ## Does this MR meet the acceptance criteria? - [X] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [X] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~ - [X] ~~API support added~~ - Tests - [X] Added for this feature/bug - [ ] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) /cc @akitaonrails @DouweM See merge request !5573
| * | fixup! Fix attr reader to force the intended values for source and target shasfix-gh-pull-requestsDouglas Barbosa Alexandre2016-07-311-6/+2
| | |
| * | Fix attr reader to force the intended values for source and target shasDouglas Barbosa Alexandre2016-07-311-0/+4
| |/ | | | | | | | | | | | | | | | | | | | | When importing a pull request from GitHub, the old and new branches may no longer actually exist by those names, but we need to recreate the merge request diff with the right source and target shas. We use these `target_branch_sha` and `source_branch_sha` attributes to force these to the intended values. But the reader methods were always looking up to the target/source branch head instead of check if these values was previously set.
* | Merge branch 'fix/labels-milestones-import' into 'master' Rémy Coutable2016-08-012-2/+14
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix Importing labels and milestones associations - Import/Export Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19510 and https://gitlab.com/gitlab-org/gitlab-ce/issues/19447 - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5426
| * | squashed - fixed label and milestone association problems, updated specs and ↵fix/labels-milestones-importJames Lopez2016-08-012-2/+14
| |/ | | | | | | refactored reader class a bit
* | Merge branch 'zj-env-external-url' into 'master' Rémy Coutable2016-08-011-0/+12
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an URL field to Enviroments ## What does this MR do? Adds a field to the `enviroments` table to expose later in other features. Now I see the task list below, I noticed I forgot some minor things, but Ill adress those after the first review. ## Are there points in the code the reviewer needs to double check? The field is a string on the database, thus limited to 255 chars, which seems more than enough. ## What are the relevant issue numbers? Closes #19527 ## Screenshots (if relevant) ![Screen_Shot_2016-07-25_at_15.22.16](/uploads/5c3f39466f8e2114195270006aed20c0/Screen_Shot_2016-07-25_at_15.22.16.png)![Screen_Shot_2016-07-25_at_15.22.53](/uploads/408cf86610137dd4a861d15dcd677a2c/Screen_Shot_2016-07-25_at_15.22.53.png)![Screen_Shot_2016-07-25_at_15.23.10](/uploads/927c506931f4e0338cdbbc58678bd308/Screen_Shot_2016-07-25_at_15.23.10.png) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [x] API support added - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5469
| * Incorporate feedbackZ.J. van de Weg2016-07-291-1/+9
| |
| * Add an URL field to EnvironmentsZ.J. van de Weg2016-07-291-0/+4
| | | | | | | | | | This MR adds a string (thus max 255 chars) field to the enviroments table to expose it later in other features.
* | Merge branch 'ability-batch-issue-checking' into 'master' Robert Speicher2016-07-292-0/+38
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimize checking if a user can read multiple issues ## What does this MR do? This optimizes various parts of the code so it can more efficiently check if a user can read a list of issues. ## Are there points in the code the reviewer needs to double check? Yes, in particular `Ability.issues_readable_by_user` should be checked to make sure it correctly allows/restricts access to issues. ## Why was this MR needed? Currently the general approach to checking if one can read an issue is to iterate over the issues to check and call `can?(user, :read_issue, issue)` for every issue. This is not efficient as the same work has to be done for every issue. ## What are the relevant issue numbers? * #15607 * #17463 See merge request !5370
| * | Method for returning issues readable by a userability-batch-issue-checkingYorick Peterse2016-07-292-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The method Ability.issues_readable_by_user takes a list of users and an optional user and returns an Array of issues readable by said user. This method in turn is used by Banzai::ReferenceParser::IssueParser#nodes_visible_to_user so this method no longer needs to get all the available abilities just to check if a user has the "read_issue" ability. To test this I benchmarked an issue with 222 comments on my development environment. Using these changes the time spent in nodes_visible_to_user was reduced from around 120 ms to around 40 ms.
* | | Merge branch 'rubocop/enable-access-modifiers-cops' into 'master' Robert Speicher2016-07-291-15/+15
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable Rubocop cops that check access modifiers ## What does this MR do? This MR enables Rubocop cops that detect methods that should be restricted but are the part of public API because of access modifiers used improperly. This also fixes existing offenses. ## Why was this MR needed? Some method in our codebase are public instead of being private because it is sometimes difficult to get it right without static analysis. ## What are the relevant issue numbers? See #17478 Closes #17372 See merge request !5014
| * | | Enable Rubocop cops for invalid access modifiersrubocop/enable-access-modifiers-copsGrzegorz Bizon2016-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables following cops: Check for useless access modifiers Lint/UselessAccessModifier Checks for attempts to use `private` or `protected` to set the visibility of a class method, which does not work. Lint/IneffectiveAccessModifier This also disables two false possitives in concerns.
| * | | Fix some useless access modifiers in the codeGrzegorz Bizon2016-07-191-14/+14
| | | |
* | | | Check for Ci::Build artifacts at database levelPaco Guzman2016-07-291-0/+1
| |_|/ |/| |
* | | Implement final review comments from @rymai.Timothy Andrew2016-07-292-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Instantiate `ProtectedBranchesAccessSelect` from `dispatcher` 2. Use `can?(user, ...)` instead of `user.can?(...)` 3. Add `DOWNTIME` notes to all migrations added in !5081. 4. Add an explicit `down` method for migrations removing the `developers_can_push` and `developers_can_merge` columns, ensuring that the columns created (on rollback) have the appropriate defaults. 5. Remove duplicate CHANGELOG entries. 6. Blank lines after guard clauses.
* | | Use `Gitlab::Access` to protected branch access levels.Timothy Andrew2016-07-293-32/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. It makes sense to reuse these constants since we had them duplicated in the previous enum implementation. This also simplifies our `check_access` implementation, because we can use `project.team.max_member_access` directly. 2. Use `accepts_nested_attributes_for` to create push/merge access levels. This was a bit fiddly to set up, but this simplifies our code by quite a large amount. We can even get rid of `ProtectedBranches::BaseService`. 3. Move API handling back into the API (previously in `ProtectedBranches::BaseService#translate_api_params`. 4. The protected branch services now return a `ProtectedBranch` rather than `true/false`. 5. Run `load_protected_branches` on-demand in the `create` action, to prevent it being called unneccessarily. 6. "Masters" is pre-selected as the default option for "Allowed to Push" and "Allowed to Merge". 7. These changes were based on a review from @rymai in !5081.
* | | Implement review comments from @dbalexandre.Timothy Andrew2016-07-293-20/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Remove `master_or_greater?` and `developer_or_greater?` in favor of `max_member_access`, which is a lot nicer. 2. Remove a number of instances of `include Gitlab::Database::MigrationHelpers` in migrations that don't need this module. Also remove comments where not necessary. 3. Remove duplicate entry in CHANGELOG. 4. Move `ProtectedBranchAccessSelect` from Coffeescript to ES6. 5. Split the `set_access_levels!` method in two - one each for `merge` and `push` access levels.
* | | Admins count as masters too.Timothy Andrew2016-07-293-4/+12
| | | | | | | | | | | | | | | | | | 1. In the context of protected branches. 2. Test this behaviour.
* | | Humanize protected branches' access levels at one location.Timothy Andrew2016-07-292-0/+23
| | | | | | | | | | | | | | | | | | | | | 1. The model now contains this humanization data, which is the once source of truth. 2. Previously, this was being listed out in the dropdown component as well.
* | | Fix all specs related to changes in !5081.Timothy Andrew2016-07-293-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | 1. Remove `Project#developers_can_push_to_protected_branch?` since it isn't used anymore. 2. Remove `Project#developers_can_merge_to_protected_branch?` since it isn't used anymore.
* | | Allow setting "Allowed To Push/Merge" while creating a protected branch.Timothy Andrew2016-07-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Reuse the same dropdown component that we used for updating these settings (`ProtectedBranchesAccessSelect`). Have it accept options for the parent container (so we can control the elements it sees) and whether or not to save changes via AJAX (we need this for update, but not create). 2. Change the "Developers" option to "Developers + Masters", which is clearer. 3. Remove `developers_can_push` and `developers_can_merge` from the model, since they're not needed anymore.
* | | Enforce "No One Can Push" during git operations.Timothy Andrew2016-07-292-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. The crux of this change is in `UserAccess`, which looks through all the access levels, asking each if the user has access to push/merge for the current project. 2. Update the `protected_branches` factory to create access levels as necessary. 3. Fix and augment `user_access` and `git_access` specs.
* | | Add "No One Can Push" to the protected branches UI.Timothy Andrew2016-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Move to dropdowns instead of checkboxes. One each for "Allowed to Push" and "Allowed to Merge" 2. Refactor the `ProtectedBranches` coffeescript class into `ProtectedBranchesAccessSelect`. 3. Modify the backend to accept the new parameters.
* | | Use the `{Push,Merge}AccessLevel` models in the UI.Timothy Andrew2016-07-293-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Improve error handling while creating protected branches. 2. Modify coffeescript code so that the "Developers can *" checkboxes send a '1' or '0' even when using AJAX. This lets us keep the backend code simpler. 3. Use services for both creating and updating protected branches. Destruction is taken care of with `dependent: :destroy`
* | | Add models for the protected branch access levels.Timothy Andrew2016-07-293-0/+9
| |/ |/| | | | | - And hook up their associations.
* | Merge branch 'cache-commit-author-lookup' into 'master' Yorick Peterse2016-07-291-1/+16
|\ \ | | | | | | | | | | | | Cache the commit author in RequestStore to avoid extra lookups in PostReceive See merge request !5537
| * | Add specs for caching commit authorStan Hu2016-07-271-7/+15
| | |
| * | Cache the commit author in RequestStore to avoid extra lookups in PostReceiveStan Hu2016-07-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | In a PostReceive task with 697 commits (8.9 RC1 -> RC8), looking up the commit author takes about 10% of the time. Caching this information in RequestStore saves a few seconds from the overall processing time. Improves #18663
* | | Merge branch ↵Yorick Peterse2016-07-291-14/+17
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | '17073-tagscontroller-index-is-terrible-response-time-goes-up-to-5-seconds' into 'master' Update to gitlab_git 10.4.1 and take advantage of preserved Ref objects See merge request !5536
| * | | Update to gitlab_git 10.4.1 and take advantage of preserved Ref objectsAlejandro Rodríguez2016-07-281-14/+17
| | | |