Commit Graph

5259 Commits

Author SHA1 Message Date
Kamil Trzciński 21b90ef866 Merge branch 'fix/rename-merge-request-head-pipeline' into 'master'
Rename `MergeRequest#pipeline` to `head_pipeline`

## What does this MR do?

This MR renames `MergeRequest#pipeline` to `MergeRequest#head_pipeline`

## Does this MR meet the acceptance criteria?

- [x] All builds are passing

## What are the relevant issue numbers?

Closes #24810

See merge request !7783
2016-11-30 11:09:40 +00:00
Douwe Maan ef3a898d9a Merge branch 'ee-1137-follow-up-protected-branch-users-and-groups' into 'master'
CE-specific changes for gitlab-org/gitlab-ee#1137

## What does this MR do?

- gitlab-org/gitlab-ee#1137 is a `technical debt` issue to clean up the EE protected branch access levels (for users and groups) implementation.
- Some of this cleanup bleeds over to code shared by CE and EE, which is why this MR is required.
- An EE-specific MR has also been created: gitlab-org/gitlab-ee!927

See merge request !7821
2016-11-30 03:18:10 +00:00
Grzegorz Bizon a49e9949c6 Rename `MergeRequest#pipeline` to `head_pipeline` 2016-11-29 14:12:49 +01:00
Timothy Andrew 41bf093662 CE-specific changes gitlab-org/gitlab-ee#1137
- Extract all common {push,merge} access level model code into the
  `ProtectedBranchAccess` module

- Use the HTTP verb to define controller specs
2016-11-29 17:38:45 +05:30
Douwe Maan b0bde100f2 Merge branch 'hoopes/gitlab-ce-21027-add-diff-hunks-to-notification-emails' into 'master'
Add diff hunks to notification emails

Add diff hunks to notification emails. Continued from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5855 - thanks @hoopes!

This also fixes an issue where the + / - prefixes were missing from diffs in emails.

Screenshots (from my browser) of the HTML emails, along with text screenshots 😛

![image](/uploads/cb31400becf5149d40c8bb98a655aa93/image.png)

```
New comment for Merge Request !1 on app/views/admin/builds/index.html.haml:

http://localhost:3000/gitlab-org/gitlab-ce/merge_requests/1#note_1023

>          Finished

This is a comment at the top of a match section.
```

![image](/uploads/704dd3845797530697a27f5c1953c053/image.png)

```
New comment for Merge Request !1 on app/views/admin/builds/index.html.haml:

http://localhost:3000/gitlab-org/gitlab-ce/merge_requests/1#note_1022

>          Finished
>          %span.badge.js-running-count= @all_builds.finished.count(:id)
>  
> -    %li{class: ('active' if @scope == 'all')}
> -      = link_to admin_builds_path(scope: :all) do
> -        All
> -        %span.badge.js-totalbuilds-count= @all_builds.count(:id)
> -
>  .gray-content-block
>    #{(@scope || 'running').capitalize} builds
>  

This is a comment at the bottom of a match section.
```

![image](/uploads/4063f3d9738aea8ebf3c0e690d0eddee/image.png)

```
New comment for Merge Request !1 on app/views/admin/builds/index.html.haml:

http://localhost:3000/gitlab-org/gitlab-ce/merge_requests/1#note_1024

>          = link_to 'Cancel all', cancel_all_admin_builds_path, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post
>  
>    %ul.center-top-menu
> -    %li{class: ('active' if @scope.nil?)}
> +    %li{class: ('active' if @scope == 'all')}
>        = link_to admin_builds_path do
> +        All

This is a comment with some deleted and added lines above it.
```

Closes #21027, closes #24340.

See merge request !7660
2016-11-29 04:11:15 +00:00
Douwe Maan 3bf34face4 Merge branch 'jej-use-issuable-finder-instead-of-access-check' into 'security'
Replace issue access checks with use of IssuableFinder

Split from !2024 to partially solve https://gitlab.com/gitlab-org/gitlab-ce/issues/23867

## Which fixes are in this MR?

⚠️ - Potentially untested  
💣 - No test coverage  
🚥 - Test coverage of some sort exists (a test failed when error raised)  
🚦 - Test coverage of return value (a test failed when nil used)  
 - Permissions check tested

### Issue lookup with access check

Using `visible_to_user` likely makes these security issues too. See [Code smells](#code-smells).

- [x] 🚦 app/finders/notes_finder.rb:15 [`visible_to_user`]
- [x] 🚥 app/views/layouts/nav/_project.html.haml:73 [`visible_to_user`] [`.count`]
- [x]  app/services/merge_requests/build_service.rb:84 [`issue.try(:confidential?)`]
- [x]  lib/api/issues.rb:112 [`visible_to_user`]
  - CHANGELOG: Prevented API returning issues set to 'Only team members' to everyone
- [x]  lib/api/helpers.rb:126 [`can?(current_user, :read_issue, issue)`] Maybe here too?
- [x]  lib/gitlab/search_results.rb:53 [`visible_to_user`]

### Previous discussions
- [ ] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b2ff264eddf9819d7693c14ae213d941494fe2b3_128_126
- [ ] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#7b6375270d22f880bdcb085e47b519b426a5c6c7_87_87

See merge request !2031
2016-11-28 21:26:23 -03:00
Douwe Maan 6d37fe952b Merge branch 'jej-fix-missing-access-check-on-issues' into 'security'
Fix missing access checks on issue lookup using IssuableFinder

Split from !2024 to partially solve https://gitlab.com/gitlab-org/gitlab-ce/issues/23867

⚠️ - Potentially untested
💣 - No test coverage
🚥 - Test coverage of some sort exists (a test failed when error raised)
🚦 - Test coverage of return value (a test failed when nil used)
 - Permissions check tested

- [x]  app/controllers/projects/branches_controller.rb:39
  - `before_action :authorize_push_code!` helpes limit/prevent exploitation. Always checks for reporter access so fine with
    confidential issues, issues only visible to team, etc.
- [x] 🚥 app/models/cycle_analytics/summary.rb:9 [`.count`]
- [x]  app/controllers/projects/todos_controller.rb:19

- [x] Potential double render in app/controllers/projects/todos_controller.rb

- https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#cedccb227af9bfdf88802767cb58d43c2b977439_24_24

See merge request !2030
2016-11-28 21:25:46 -03:00
Sean McGivern 854fbbfb07 Tidy up text emails 2016-11-28 19:40:48 +00:00
Sean McGivern cfb4d65f84 Merge branch '24813-project-members-with-developer-access-can-no-longer-create-tags' into 'master'
Create tag after running pre-hooks and pass updated SHA to post-hooks

Closes #24813

See merge request !7700
2016-11-28 16:02:46 +00:00
Adam Niedzielski cf58271e11 Pass tag SHA to post-receive hook when tag is created via UI
We only know the tag SHA after we create the tag.
This means that we pass a different value to the hooks that happen before
creating the tag, and a different value to the hooks that happen after
creating the tag.

This is not an ideal situation, but it is a trade-off we decided to
make. For discussion of the alternatives please refer to
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7700#note_18982873

"pre-receive" and "update" hooks always get the SHA of the commit
that the tag points to. "post-receive" gets the tag SHA if it is
an annotated tag or the commit SHA if it is an lightweight tag.
Currently we always create annotated tags if UI is used.
2016-11-28 15:04:51 +01:00
Adam Niedzielski 9e6cdc6474 Revert "Pass correct tag target to post-receive hook when creating tag via UI"
This reverts commit ae51774bc4.
2016-11-28 13:00:42 +01:00
Adam Niedzielski d9a2093e7e Prevent error when submitting a merge request and pipeline is not defined 2016-11-28 12:03:59 +01:00
Douwe Maan d281383261 Merge branch 'refresh-authorizations-with-lease' into 'master'
Refresh project authorizations using a Redis lease

This MR changes `User#refresh_authorized_projects` so it uses a Redis lease instead of relying on serializable transactions. See the commit message(s) for more details.

See merge request !7733
2016-11-28 03:35:37 +00:00
Douwe Maan d8f7523368 Merge branch 'events-cache-invalidation' into 'master'
Remove caching of events data

This MR removes the caching of events data as this was deemed unnecessary while increasing load on the database. See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6578#note_18864037 and 5371da341e for more information.

See merge request !6578
2016-11-28 03:34:12 +00:00
hhoopes a761c59a6b Add keyword arguments to truncated_diff method
* Added keyword arguments to truncated_diff_lines method to allow for using highlighting or not (html templates vs. text)
* Tweaked templates for consistency and format appropriateness
2016-11-25 15:23:49 +00:00
hhoopes f928dba99b Change diff highlight/truncate for reusability
Previously the `truncated_diff_lines` method for outputting a discussion diff took in already highlighted lines, which meant it wasn't reuseable for truncating ANY lines. In the way it was used, it also meant that for any email truncation, the whole diff was being highlighted before being truncated, meaning wasted time highlighting lines that wouldn't even be used (granted, they were being memoized, so perhaps this wasn't that great of an issue). I refactored truncation away from highlighting, in order to truncate formatted diffs for text templates in email, using `>`s to designate each line, but otherwise retaining the parsing already done to create `diff_lines`.

Additionally, while notes on merge requests or commits had already been tested, there was no existing test for notes on a diff on an MR or commit. Added mailer tests for such, and a unit test for truncating diff lines.
2016-11-25 15:23:49 +00:00
Yorick Peterse 0ba03d7eb1
Removed data-user-is view code
With events no longer being cached this is no longer needed.
2016-11-25 13:45:34 +01:00
Yorick Peterse 92b2c74ce1
Refresh project authorizations using a Redis lease
When I proposed using serializable transactions I was hoping we would be
able to refresh data of individual users concurrently. Unfortunately
upon closer inspection it was revealed this was not the case. This could
result in a lot of queries failing due to serialization errors,
overloading the database in the process (given enough workers trying to
update the target table).

To work around this we're now using a Redis lease that is cancelled upon
completion. This ensures we can update the data of different users
concurrently without overloading the database.

The code will try to obtain the lease until it succeeds, waiting at
least 1 second between retries. This is necessary as we may otherwise
end up _not_ updating the data which is not an option.
2016-11-25 13:35:01 +01:00
Kamil Trzciński afe90d529c Merge branch 'fix-cancelling-pipelines' into 'master'
Improve how we could cancel pipelines:

Improve how we could cancel pipelines:

* Introduce `HasStatus.cancelable` which we might be able to cancel
* Cancel and check upon `cancelable`
* Also cancel on `CommitStatus` rather than just `Ci::Build`

Fixes #23635

Fixes #17845

See merge request !7508
2016-11-25 09:48:04 +00:00
Douwe Maan b3e1561fde Merge branch 'backport-commands-params' into 'master'
Backport Note#commands_changes from EE

One small thing from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/870 that was missed in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7604.

/cc @rdavila

See merge request !7730
2016-11-24 09:02:01 +00:00
Robert Speicher 3943e63210 Merge branch 'mrchrisw/add-namespace-logging' into 'master'
Log mv_namespace parameters

[ci skip]

See merge request !7729
2016-11-24 07:00:40 +00:00
Douwe Maan ba5e98bb70 Backport Note#commands_changes from EE 2016-11-24 14:32:32 +08:00
Chris Wilson 4123a0ff75 Log mv_namespace parameters 2016-11-24 13:36:15 +08:00
Douwe Maan a7a9db803b Merge branch 'dz-allow-nested-group-routing' into 'master'
Add nested groups support to the routing

## What does this MR do?

It allows routing with `/` in namespace name 

## Why was this MR needed?

For nested groups feature(https://gitlab.com/gitlab-org/gitlab-ce/issues/2772). We need URI like `/group/subgroup/project` be routed correctly


## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) 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 [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [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 it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/2772

See merge request !7459
2016-11-24 04:31:54 +00:00
Sean McGivern 8fcdfeaee2 Merge branch '24863-mrs-without-discussions-are-mergeable' into 'master'
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/24863

See merge request !7698
2016-11-23 14:13:27 +00:00
Sean McGivern 4646d453b3 Merge branch 'milestone_start_date' into 'master'
Add a starting date to milestones

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/23704

See merge request !7484
2016-11-23 13:23:13 +00:00
Yorick Peterse 5371da341e
Remove event caching code
Flushing the events cache worked by updating a recent number of rows in
the "events" table. This has the result that on PostgreSQL a lot of dead
tuples are produced on a regular basis. This in turn means that
PostgreSQL will spend considerable amounts of time vacuuming this table.
This in turn can lead to an increase of database load.

For GitLab.com we measured the impact of not using events caching and
found no measurable increase in response timings. Meanwhile not flushing
the events cache lead to the "events" table having no more dead tuples
as now rows are only inserted into this table.

As a result of this we are hereby removing events caching as it does not
appear to help and only increases database load.

For more information see the following comment:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6578#note_18864037
2016-11-23 14:17:07 +01:00
Dmitriy Zaporozhets 6683fdcfb0
Add nested groups support to the routing
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-11-23 14:08:36 +02:00
Douwe Maan f2a0c6f6bf Correctly determine mergeability of MR with no discussions 2016-11-23 20:02:14 +08:00
Lin Jen-Shin bd3a544ab0 Wrap against 80 chars and rename failed_or_canceled
to better reflect the status. Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7508#note_18858398
2016-11-23 19:43:56 +08:00
Valery Sizov 3789cfe056 Add a starting date to milestones 2016-11-23 13:41:04 +02:00
Ahmad Sherif 2ea5ef0ba4 Update ProjectTeam#fetch_members to use project authorizations 2016-11-23 12:59:13 +02:00
Ahmad Sherif 747959a832 Update ProjectTeam#max_member_access_for_user_ids to use project authorizations 2016-11-23 12:59:13 +02:00
Ahmad Sherif 0f3c3a1c57 Update user's authorized projects if project is allowed to share with group 2016-11-23 12:59:07 +02:00
Ahmad Sherif 916332815e Drop Project#authorized_for_user? in favor of ProjectTeam#member?
Closes #23938
2016-11-23 12:57:58 +02:00
Ahmad Sherif 229b7e9a8e Refresh user's authorized projects when one of his memberships are updated 2016-11-23 12:57:58 +02:00
Ahmad Sherif 74650b280b Change personal projects access level to master in User#project_authorizations_union
So that it matches the same access given in
Projects::CreateService#after_create_actions
2016-11-23 12:57:58 +02:00
Ahmad Sherif 4262687a97 Use the minimum access level of group link and group member when inserting authorized project records 2016-11-23 12:57:54 +02:00
Sean McGivern dfb21e299f Merge branch 'rs-project-team-helpers' into 'master'
Add shortcuts for adding users to a project team with a specific role

Closes #20944

See merge request !7565
2016-11-22 16:43:03 +00:00
Achilleas Pipinellis da0dd7ec96 Merge branch 'revert-a0d5bb0b' into 'master'
Revert "Merge branch 'docs/jira-old' into 'master'"

See merge request !7531
2016-11-22 14:50:37 +00:00
Achilleas Pipinellis c78a0bcc00 Change documentation link in JIRA service 2016-11-22 14:12:09 +01:00
Fatih Acet 2270f988d4 Merge branch 'zj-mattermost-command-help-message' into 'master'
Add help section for MM commands

## What should this MR do

Check @pedroms' design for the Mattermost service screen: https://gitlab.com/gitlab-org/gitlab-ce/issues/22540

Now this has to be implemented, I've created a clean canvas for you, @lbennett, to draw on.

## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) 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 it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !7558
2016-11-22 13:06:31 +00:00
Kamil Trzciński 30c122e224 Merge branch 'fix-failed-email-for-external-jobs' into 'master'
External jobs do not have show page nor traces

Fixes #24677

See merge request !7617
2016-11-22 12:59:32 +00:00
Lin Jen-Shin 17388eb034 Merge remote-tracking branch 'upstream/master' into fix-cancelling-pipelines
* upstream/master: (133 commits)
  Restructure steps for MM slash commands service
  Add Changelog entry for CI linter validation fix
  Fix entry lookup in CI config inheritance rules
  Extend specs for global ci configuration entry
  Remove unnecessary require_relative calls from service classes
  Use single quote for strings
  Ue svg from SVGs object
  Dont trigger CI builds [ci skip]
  Revert "Test only migrations"
  Add custom copy for each empty stage
  Refactor Mattermost slash commands docs
  Fetch only one revision
  Highlight nav item on hover
  Test only migrations
  Fix migration paths tests
  Scroll CA stage panel on mobile
  Fix CSS declaration
  administer to administrator
  Move SVGs to JS objects for easy reuse
  Improve deploy command message
  ...
2016-11-22 18:46:35 +08:00
Lin Jen-Shin da9726170c Move has_trace? to CommitStatus than GenericCommitStatus
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7617#note_18762721
2016-11-22 13:36:19 +08:00
Rémy Coutable 2449d787ad Merge branch 'chatops-deploy-command' into 'master'
Add deploy chat command

This adds a new ChatOps command:
```
/trigger deploy <environment> to <environment>
```

See merge request !7619
2016-11-21 20:27:58 +00:00
Kamil Trzciński 3c8d2148fc Merge branch 'feature/send-registry-address-with-build-payload' into 'master'
Send registry address with build payload

## What does this MR do?

Adds `registry_url` as a part of a build payload, when sending a response to a GitLab Runner which requested a new build.

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

Change in `lib/ci/api/entities.rb`.

## Why was this MR needed?

This is one of the steps needed to add support for private/protected registries hosted with GitLab CE/EE.

## Screenshots (if relevant)

## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [ ] [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
- [ ] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [ ] 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 it does - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

Related to gitlab-org/gitlab-ci-multi-runner#1828, gitlab-org/gitlab-ci-multi-runner!386, gitlab-org/gitlab-ci-multi-runner#1434

See merge request !7474
2016-11-21 20:22:55 +00:00
Sean McGivern 7a5e653fde Merge branch 'hide-empty-merge-request-diffs' into 'master'
Fix errors happening when source branch of merge request is removed and then restored

See merge request !7568
2016-11-21 19:23:22 +00:00
Tomasz Maczukin 461195665b
Add Gitlab::Ci::Build::Credentials module with build credentials abstraction 2016-11-21 19:49:29 +01:00
Sean McGivern 55ca2da768 Merge branch 'smarter-cache-invalidation' into 'master'
Smarter cache invalidation

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

See merge request !7360
2016-11-21 17:08:36 +00:00