Commit Graph

31799 Commits

Author SHA1 Message Date
Grzegorz Bizon 4c388fb865 Remove legacy conditional from irker service code 2016-07-08 11:06:54 +02:00
Grzegorz Bizon c6f9a1c273 Enable Style/IdenticalConditionalBranches Rubocop cop 2016-07-08 11:04:04 +02:00
Rémy Coutable 2c650b6f30 Merge branch 'feature/option-set-new-users-external' into 'master'
Added setting to set new users by default as external

## What does this MR do?
This implements the feature request #14508. It adds an option in the application settings to set new users by default as external.

## Are there points in the code the reviewer needs to double check?
Everything. Like I mentioned in the discussion of the issue my knowledge of Ruby basically doesn't exists. I tested it on my machine and it seems to work, but as I am very unexperienced in Ruby I highly recommend to  take a close look at the code.

## Why was this MR needed?
It was requested by @DouweM to work on the issue with the proposed changes by me.

## What are the relevant issue numbers?
This MR is for the issue #14508 that followed up after the implementation of #4009.

See merge request !4545
2016-07-08 08:29:18 +00:00
Robert Speicher 5d0b06a038 Merge branch '9127-link-report-to-profile' into 'master'
Link to the user's profile in the abuse reports

Link to the user's profile in the abuse reports and add a link to the
admin area view if the user viewing the profile is an admin

Fixes #9127

See merge request !5118
2016-07-08 04:59:40 +00:00
Robert Speicher 0de617772d Revert "Revert "Merge branch 'issue_3946' into 'master' ""
This reverts commit bf2a86b73c.
2016-07-07 23:48:02 -04:00
Robert Speicher cfb5a76bb2 Merge branch 'upgrade-oauth2' into 'master'
Upgrade oauth2 from 1.0.0 to 1.2.0.

Changelog: https://github.com/intridea/oauth2/compare/v1.0.0...v1.2.0

Follow-up on !3434 since 1.2.0 doesn't limit the JWT version we can use.

Adds support for Rails 5. Working toward #14286.

See merge request !5041
2016-07-07 23:53:57 +00:00
Patricio Cano be6c4fef40 Removed unnecessary `id` from links and corrected tests to use the proper matcher. 2016-07-07 18:39:45 -05:00
Douwe Maan 068b1aeef9 Merge branch 'prefer-scope' into 'master'
Use scope rather than class method

## What does this MR do?

Use scope rather than class method

## Why was this MR needed?

I assume this would be useful and more clear.

See merge request !5133
2016-07-07 22:47:48 +00:00
Douwe Maan 5d3a0d38cb Merge branch 'prefer-ref' into 'master'
Prefer ref rather than id because id is shadowing database id

## What does this MR do?

Just a local variable renaming.

## Why was this MR needed?

Prefer ref rather than id because id is shadowing database id.

See merge request !5134
2016-07-07 22:47:38 +00:00
Robert Speicher dad406da23 Merge remote-tracking branch 'origin/master' 2016-07-07 18:40:29 -04:00
Douwe Maan bf89e06a45 Merge branch '18627-wildcard-branch-protection' into 'master'
Allow specifying protected branches using wildcards

Closes #18627 

# Tasks

- [ ]  #18627 !4665 Allow specifying protected branches using wildcards
    - [x]  Find existing usages of protected branches
        - Protecting branches
            - `ProtectedBranchesController` is used to mark a branch protected/unprotected
            - `API::Branches` can be used to mark a branch protected/unprotected
        - Enforcing branch protection
            - `Gitlab::GitAccess` has helpers (`can_push_to_branch?`, `check`) that are used to deny pushes if a branch is protected
            - Over SSH: `gitlab-shell` receives a push, and calls `/allowed` on the GitLab API, which calls `GitAccess.check`
            - Over HTTP: 
                - `gitlab-workhorse` receives the request, and forwards it to rails
                - Rails (in the `GitHttpController#git-recieve-pack`) runs basic checks (is the user logged in, not protected branch checks) and returns ok with `GL_ID` and `RepoPath`
                - `gitlab-workhorse` looks at the response, and calls the relevant `gitlab-shell` action from `git-http/handlePostRPC`
                - Rest of this flow is the same as the SSH flow above
    - [x]  Implementation
        - [x]  Backend
            - [x]  Change `project#protected_branch?` to look at wildcard protected branches
            - [x]  Change `project#developers_can_push_to_protected_branch?`
            - [x]  Change `project#open_branches`
            - [x]  Better error message when creating a disallowed branch from the Web UI
        - [x]  Frontend
            - [x]  Protected branches page should allow typing out a wildcard pattern
            - [x]  Add help text explaining the use of wildcards
            - [x]  Show matching branches for each protected branch
                - [x]  ~~On the index page~~
                - [x]  On a show page
                - [x]  Index?
            - [x]  Can't have the "last commit" column for wildcard protected branches
    - [x]  Fix / write tests
    - [x]  What happens if a hook is missing in dev?
    - [x]  Refactor
    - [x]  Test workflows
        - Create a branch matching a wildcard pattern
        - Push to a branch matching a wildcard pattern
        - Force push to a branch matching a wildcard pattern
        - Delete a branch matching a wildcard pattern
        - [x]  Test using Web UI
        - [x]  Test over SSH
        - [x]  Test over HTTP
        - [x]  Test as developer and master
    - [x]  Investigate performance
        - [x]  Test with a large number of protected branches / branches
        - [x]  Paginate list of protected branches
        - [x]  ~~Possibly rewrite `open_branches`~~
    - [x]  Add `iid`s to existing `ProtectedBranch`es
    - [x]  Add documentation
    - [x]  Add CHANGELOG entry
    - [x]  Add screenshots
    - [x]  Make sure [build](2f753e3ed2/builds) passes
    - [x]  Assign to endboss for review
    - [x]  Address @DouweM's comments
        - [x]  `protected_branch_params`
        - [x]  `exact_match` instead of `explicit_match`
        - [x]  When would self.name be blank?
        - [x]  Move `protected_branches.each` to a partial
        - [x]  Move `matching_branches.each` to a partial
        - [x]  If the branch is in @matching_branches, it's not been removed
        - [x]  move this regex to a method and memoize it
        - [x]  `commit_sha` directly for exact matches
        - [x]  Number of matches for wildcard matches, with a link
    - [x]  Wait for [build](43f9ce0e88/builds) to pass
    - [x]  Respond to @DouweM's comments
        - [x]  Don't use iid
        - [x]  Controller should use `@project.protected_branches.new`
        - [x]  move the memoization to `def wildcard_regex`
        - [x]  render with `collection: @protected_branches`
    - [x]  Wait for [build](f7beedf122/builds) to pass
    - [x]  Wait for @DouweM's review
    - [x]  Wait for @jschatz1's review
    - [x]  Respond to @jschatz1's comments
        - [x]  Use the new dropdown style
        - [x]  description should be moved to the description section without the styling
        - [x]  Protect button should be disabled when no branch is selected
    - [x]  Update screenshots
    - [x]  Merge conflicts
    - [x]  Make sure [build](20f3cfe8d5/builds) passes
    - [ ]  Revisit performance, possibly with staging/production data
        - [ ]  Get a dump of staging / run against staging live
            - [ ]  Get SSH access to staging
    - [ ]  Wait for review/merge






# Screenshots

## Creating wildcard protected branches

![1](/uploads/9446afccfdf6fa381e00c800dd2cc82e/1.png)
![2](/uploads/0b154503b297a818d3577488c575d845/2.png)
![3](/uploads/36217f79df9e41cc1550601f02627fe8/3.png)
![4](/uploads/041ca9bd529bcfa5373fca67e917cbcb/4.png)

### Using the `GLDropdown` component

![2016-06-30_14-16-15](/uploads/508afc2a5e2463c2954641409a560d88/2016-06-30_14-16-15.gif)

## Enforcing wildcard protected branches

### From the Web UI

![Screen_Shot_2016-06-20_at_1.21.18_PM](/uploads/8b5d4b1911e9152698a0488daf1880bc/Screen_Shot_2016-06-20_at_1.21.18_PM.png)

### Over SSH

![SSH](/uploads/7365989d7e4c406ef37b6ae5106442c9/SSH.gif)

### Over HTTPS

![HTTPS](/uploads/a7c0f56ae58efcffc75e6700fa2f4ac0/HTTPS.gif)

## Listing matching branches

![Screen_Shot_2016-06-20_at_1.33.44_PM](/uploads/d054113022f5d7ec64c0e57e501ac104/Screen_Shot_2016-06-20_at_1.33.44_PM.png)

See merge request !4665
2016-07-07 22:37:30 +00:00
Robert Speicher bf2a86b73c Revert "Merge branch 'issue_3946' into 'master' "
This reverts commit 68155ee73b, reversing
changes made to 7ebd011ed1.
2016-07-07 18:25:05 -04:00
Robert Speicher 39fbec9419 Merge branch '18181-pipeline-duration' into 'master'
Update time format of pipeline duration

Closes #18181

Part of #18920 

See merge request !5121
2016-07-07 22:17:55 +00:00
Annabel Dunstone 4498bb7833 Change 3600 to 1.hour 2016-07-07 16:48:10 -05:00
Jacob Schatz 5541e55c49 Merge branch 'issues-blank-state' into 'master'
Added blank state to issues

## What does this MR do?

Adds new blank state to issues when no issues exist.

Part of #18519 

## Screenshots (if relevant)

![Screen_Shot_2016-06-24_at_16.37.12](/uploads/0c3f385615b29216ef1137bd6fac06af/Screen_Shot_2016-06-24_at_16.37.12.png)

See merge request !4908
2016-07-07 21:17:23 +00:00
Douwe Maan 86d238e4bd Merge branch 'new-diff-notes' into 'master'
New diff notes

Fixes #12732, #14731, #19375, #14783 

Builds on https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4110

To do:
- [x] Get it mostly working
- [x] Validate position validity
- [x] Fix: Don’t link to `#`
- [x] Fix: Base ref can be `nil`, potentially, when the MR has an oprhan source branch => Yep, doesn’t work. We need to store a `start_id`
- [x] Optimize: Fewer duplicate `git diff` compares
- [x] Optimize: Pass paths to `PositionTracer#diff` for faster diffs
- [x] Refactor: Use `head_id` in `MergeRequest`/`MergeRequestDiff` instead of `source_sha`
- [x] Refactor: Convert existing array-based diff refs to the DiffRefs model
- [x] Tweak: Use `note_type` in `Autosave` key
- [x] Tweak: Remove `line_code: note.line_code` from `link_to_reply_discussion`
- [x] Update: `SentNotifications` and reply-by-email receiver
- [x] Update: MR diff notification email
- [x] Update: API (MR, Commit note creation and entity)
- [x] Update: GitHub importer
- [x] Address any other TODO comments
- [x] Fix: Suppress "edited 4 minutes ago"
- [x] Write tests
  - [x] `LineMapper`
  - [x] `PositionTracer`
  - [x] `Position`
  - [x] `DiffPositionUpdateService`
  - [x] `DiffNote`
  - [x] `MergeRequests::RefreshService` / `MergeRequest#update_diff_notes_positions`
- [x] Make sure commits with diff notes don't get cleaned up, since this would prevent the diff notes from being rendered (https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5062)

Future improvements:
- Display unresolved comments on files outside the diff, if the comment was added when that file _was_ part of the diff
- Allow commenting on sections between hunks, when expanding the diff using `...`
  - (We'd need to generate line code based on Position if we have it, even if it falls outside bounds of diff)
- `diff_hunk` on diff note API entity
- Show diff hunk in notification email
- Resolved line notes would have a boolean, and be inactive through `notes.any? { !active? || resolved? }`
- Multi line notes would store a number of positions, and do the right thing (™) in grouping and then rendering if the first item is multiline? => true
- Image diff notes could store x,y,width,height instead of old_line,new_line for similar grouping. Does it need a reference to say if it's on old or new? These can't have line_codes, clearly. Rendering would be interesting.
- Show commit line comments in the MR diff
- Comment on specific selected words
- Comment on file header
- Unfold top of discussion diff note
- New diff notes API for commits and MRs

/cc @rspeicher

See merge request !4101
2016-07-07 20:45:03 +00:00
Robert Speicher 91cf0387dd Merge branch 'pending-delete-project-notifications' into 'master'
Exclude projects pending delete from notifications

Make `NotificationSetting.for_projects` exclude projects that are excluded by the default scope on `Project`. (At the moment, that's projects with `pending_delete: true`.)

See https://gitlab.com/gitlab-com/support-forum/issues/819

See merge request !5138
2016-07-07 20:17:24 +00:00
Douwe Maan c66bcf34dd Add comment with diff to DiffPositionUpdateService spec 2016-07-07 16:14:57 -04:00
Douwe Maan 14c2b9683a Use HAML class syntax in diff line partials 2016-07-07 16:14:18 -04:00
Douwe Maan 6dd71888b3 Make `DiffNote#update_position` private 2016-07-07 16:13:55 -04:00
Robert Speicher 68155ee73b Merge branch 'issue_3946' into 'master'
Improve UI consistency for admin area

Closes #3946

See merge request !4424
2016-07-07 20:11:00 +00:00
Jacob Schatz 7ebd011ed1 Merge branch 'dz-remove-icons' into 'master'
Remove icons from file edit tabs

We don't need this icons and it also inconsistent with current UI 

See merge request !5072
2016-07-07 20:05:45 +00:00
Douwe Maan 70a64f6a57 Update test with new factory name 2016-07-07 15:57:38 -04:00
Sean McGivern ea25e0918b Exclude projects pending delete from notifications
If the Sidekiq job fails for some reason, a project can be 'stuck'
pending deletion. The project can't be viewed, so it shouldn't be
available through the notification settings association as this will
throw an exception when we try to show the link.
2016-07-07 20:49:17 +01:00
Alfredo Sumaran 140b0952a8 Namespaces should filter remotely 2016-07-07 13:25:58 -05:00
Alfredo Sumaran 22191fcdd1 Rephrase deletion alert message 2016-07-07 13:25:58 -05:00
Alfredo Sumaran 35224dbf5e Do not show Any Namespace option when needed 2016-07-07 13:25:58 -05:00
Alfredo Sumaran 338072cc4b Layout for Users Groups and Projects on admin area 2016-07-07 13:25:58 -05:00
Douwe Maan 6eb65651a7 We can't call private methods with `self.` 2016-07-07 14:14:13 -04:00
Robert Speicher 86d83a3a85 Merge branch 'escape-file-extension' into 'master'
Escape file extension when parsing search results

When a file extension contains characters which have a meaning in regular expressions, the search may crash.

Fixes #18553 

See merge request !5141
2016-07-07 17:47:03 +00:00
Dravere a0a9494e4e Added setting to set new users by default as external
As requested by the issue #14508 this adds an option in the application
settings to set newly registered users by default as external. The
default setting is set to false to stay backward compatible.
2016-07-07 19:21:18 +02:00
Robert Speicher 062c7a3074 Merge branch 'fix/import-controller-error' into 'master'
Fixes 404 redirect after validation fails importing a project

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19558

See merge request !5143
2016-07-07 15:50:03 +00:00
James Lopez f67984626b added test 2016-07-07 16:12:28 +02:00
James Lopez cf46a88b8d added changelog 2016-07-07 15:49:16 +02:00
James Lopez dad8fc242c fix 404 error, redirect back with flash message 2016-07-07 15:34:45 +02:00
winniehell cd63d0a538 Escape file extension when parsing search results (!5141) 2016-07-07 14:49:04 +02:00
Lin Jen-Shin 93dd8b0a08 Also use ref in Repository#commit 2016-07-07 19:33:54 +08:00
Lin Jen-Shin 011e281604 Prefer ref rather than id because id is shadowing database id
Some context:
http://doc.gitlab.com/ce/api/repository_files.html#get-file-from-repository
http://doc.gitlab.com/ce/api/repositories.html#list-repository-tree

Slack:
https://gitlab.slack.com/archives/questions/p1467890450002077
2016-07-07 19:28:30 +08:00
Lin Jen-Shin b988644ad8 Use scope rather than class method 2016-07-07 18:56:02 +08:00
Rémy Coutable 3c89a788c7 Merge branch 'fix/import-export-log' into 'master'
Fix log statements in import/export

Fixes - as seen in the logs:
```
Import/Export error raised on /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/import_export/file_importer.rb:19:in `rescue in import': undefined method `message' for #<String:0x007fc45e977e10>
```

See merge request !5129
2016-07-07 08:56:05 +00:00
James Lopez 91a183bc57 fix log statements in import/export 2016-07-07 09:49:46 +02:00
Dmitriy Zaporozhets ecfbb96384 Merge branch 'member_timeago' into 'master'
Add information when member joined a team

## What does this MR do?
It adds timeago label by every member on team page
## Are there points in the code the reviewer needs to double check?

Yes, maybe design is not OK, please check.

## Why was this MR needed?

It's useful information

## What are the relevant issue numbers?

## Screenshots (if relevant)

![joxi_screenshot_1467820915126](/uploads/9e5657443a10a9fe204367d7b6749b1f/joxi_screenshot_1467820915126.png)



See merge request !5116
2016-07-07 06:42:44 +00:00
Dmitriy Zaporozhets b37b7deedf Fix invite user feature test and improve request member UI row
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-07-07 09:15:49 +03:00
Dmitriy Zaporozhets 197b9793db Improve UI for member row on project/group members pages
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-07-07 09:15:49 +03:00
Valery Sizov 7950fa48e8 Add data when member joined a team 2016-07-07 09:15:49 +03:00
Dmitriy Zaporozhets de073cf5ac Merge branch 'services_refactoring1' into 'master'
Services: code style fixes, minor refactoring

## What does this MR do?

It contains code style fixes, minor refactoring and also it removes some unnecessary comments. Every comment require a support just like a regular code line and this is why we should avoid using comments everywhere unless it's really helpful. Martin Fowler said "Find comment and refactor the code around it" :) our code is not that bad so let's not spoil it with comments.

## Why was this MR needed?

Because GitLab is a live example of awesome code. Let's keep up a good job :) 


See merge request !5112
2016-07-07 06:08:12 +00:00
Rémy Coutable 52a583c120 Merge branch 'show_push_widget_in_upstream' into 'master'
Show last push widget in upstream after push to fork

## What does this MR do?

Show the last push widget in the upstream project when you push to a fork. 

## Are there points in the code the reviewer needs to double check?

In the view, I'm checking if `@project` in the first part of the conditional. I felt it was necessary in case `@project` wasn't an object in all cases. Will it ever not be there? Is this check necessary?

Should there be tests? I don't see existing ones for this. 

## Why was this MR needed?

I use the fork workflow everywhere and it has annoyed me for some time that the last push widget doesn't show up when viewing the upstream project. I'm almost never viewing the fork in GitLab so I want to be able to easily create a MR in any case. 

## Screenshots (if relevant)

**Widget in upstream repo:**

![Screen_Shot_2016-06-23_at_10.05.29_AM](/uploads/f823642e40cf059c3793db6cf00bba50/Screen_Shot_2016-06-23_at_10.05.29_AM.png)

**Widget in fork**:

![Screen_Shot_2016-06-23_at_10.05.25_AM](/uploads/1a976241186ec42cdc43c80bea0c856b/Screen_Shot_2016-06-23_at_10.05.25_AM.png)

**Widget on dashboard**:

![Screen_Shot_2016-06-23_at_10.06.07_AM](/uploads/084ac35f67735aec8042d9bc904255fe/Screen_Shot_2016-06-23_at_10.06.07_AM.png)


See merge request !4880
2016-07-07 05:22:35 +00:00
Rémy Coutable 9b75da8025 Merge branch 'patch-3' into 'master'
Allow everyone to order tags, not only those who has access

## What does this MR do?
Allows everyone to view tags by different order (by name, date, etc), not only those who has access

## Are there points in the code the reviewer needs to double check?
Just check how it's rendered.

## Why was this MR needed?
Because now I can't order other's project tags.

## What are the relevant issue numbers?
#15438

## Screenshots (if relevant)
Exist in related issue. Look [one comment](https://gitlab.com/gitlab-org/gitlab-ce/issues/15438#note_12888763) and [just below there is another one](https://gitlab.com/gitlab-org/gitlab-ce/issues/15438#note_12888819).

## Does this MR meet the acceptance criteria?
Probably, no need

See merge request !5105
2016-07-07 05:11:26 +00:00
Timothy Andrew b1c81f849e Have `Project#open_branches` return branches that are matched by a wildcard protected branch.
1. The `open_branches` method is used to provide a list of branches
   while creating a protected branch.

2. It makes sense to include branches which are matched by one or more
   wildcard protected branches, since the user might want to make exact
   protected branches from these as well.

3. This also provides a large performance improvement. On my machine, in
   a project with 5000 branches and 2000 protected branches, the
   `ProtectedBranches#index` page went from a 40 seconds load time to 4
   seconds (10x speedup).
2016-07-07 10:07:31 +05:30
Timothy Andrew d8d5424d25 Use the `GLDropdown` component to select protected branches.
1. Modify the component to support a callback for every key press in the
   filter. We need this so we can update the "Create: <branch_name"
   label.

2. Modify the component to use `$(<selector>).first().click()` instead
   of `$(selector)[0].click()`, because the latter is non-standard, and
   doesn't work in PhantomJS.
2016-07-07 10:07:05 +05:30