Commit Graph

1033 Commits

Author SHA1 Message Date
James Lopez 9b86006ca1 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/project-export-filename 2016-07-15 17:05:05 +02:00
Robert Speicher 8b7932c219 Merge branch 'disable-statement-timeout' into 'master'
Disable PostgreSQL statement timeout during migrations

Long-running migrations may take more than the timeout allowed by the database. Disable the session's statement timeout to ensure migrations don't get killed prematurely.

See merge request !5263
2016-07-15 14:51:20 +00:00
Kamil Trzcinski 86f39fece2 Refactor LFS specs to use requests instead of LfsRouter 2016-07-15 14:04:24 +02:00
James Lopez 65549a5866 add project name and namespace to filename on project export
added changelog
2016-07-15 12:55:28 +02:00
Lin Jen-Shin 0f7851b7be Merge remote-tracking branch 'upstream/master' into new-issue-by-email
* upstream/master: (1547 commits)
  Add margin between buttons if both retry and cancel are present
  Add margin between labels; remove underline hover style on status button
  udpated JS based on feedback
  Use default cursor for table header of project files (!5165)
  Fix duplicated entry in changelog [ci skip]
  Improves left static sidebar behaviour
  Include default callback URL (OAuth)
  Cleanup feature proposal template
  Simplify regex for string-based multi-word label surrounded in quotes
  Revert "Merge branch '18193-developers-can-merge' into 'master'
"
  Upgrade Rails from 4.2.6 to 4.2.7.
  some JS magic to fix empty URL bug
  formats my test properly
  Update CHANGELOG
  Doesn't match empty label references surrounded in quotes
  Fix markdown rendering for label references that contains `.`
  Fix markdown rendering for label references that begin with a digit
  Fix markdown rendering for consecutive label references
  Stub omniauth provider for GitLab
  Update CHANGELOG
  ...
2016-07-15 15:30:26 +08:00
Stan Hu 3fd304c1a5 Fix spec Don't attempt to disable statement timeout on a MySQL DB 2016-07-14 20:55:33 -07:00
http://jneen.net/ e9f191907c apparently this gets encoded now? 2016-07-14 10:08:15 -07:00
http://jneen.net/ ff7e679bca we no longer encode double-quotes 2016-07-14 10:08:15 -07:00
James Lopez b1ab079fae fix updated_at not preserved after import - for GitLab projects 2016-07-14 16:03:00 +02:00
Grzegorz Bizon 5923741fe6 Remove references to global entry in new CI config 2016-07-14 15:45:29 +02:00
Grzegorz Bizon 3e16b015b9 Revert logical validation in CI job stage entry 2016-07-14 15:45:07 +02:00
Grzegorz Bizon f7c80e9f31 Revert references to global node in CI job entry 2016-07-14 15:07:38 +02:00
Grzegorz Bizon 56ae9f6ba9 Improve CI job entry validations in new config 2016-07-14 13:14:09 +02:00
James Lopez 097706b458 fix EE => CE project import, and updated JSON spec 2016-07-14 12:07:54 +02:00
Robert Speicher 530f5158e2 Revert "Merge branch '18193-developers-can-merge' into 'master' "
This reverts commit 9ca633eb4c, reversing
changes made to fb229bbf79.
2016-07-13 13:57:30 -05:00
Douglas Barbosa Alexandre 6d5fd7d9b7 Stub omniauth provider for GitLab 2016-07-13 11:35:38 -03:00
Douglas Barbosa Alexandre d9564ed733 Add spec for GitLab.com importer 2016-07-13 11:35:38 -03:00
Grzegorz Bizon 036e297ca3 Expose CI job commands and use in legacy processor 2016-07-13 15:04:12 +02:00
Grzegorz Bizon 6920390aad Add before script and commands to CI job entry 2016-07-13 14:38:10 +02:00
Grzegorz Bizon de4c9a2738 Improve CI stage configuration entry validations 2016-07-13 12:22:33 +02:00
Timothy Andrew bb81f2afc1 Implement last round of review comments from !4892.
1. Fix typos, minor styling errors.

2. Use single quotes rather than double quotes in `user_access_spec`.

3. Test formatting.
2016-07-13 14:18:05 +05:30
Timothy Andrew 4d00ed21eb Appease rubocop. 2016-07-13 13:24:56 +05:30
Timothy Andrew 60245bbe22 Refactor `Gitlab::GitAccess`
1. Don't use case statements for dispatch anymore. This leads to a lot
   of duplication, and makes the logic harder to follow.

2. Remove duplicated logic.

    - For example, the `can_push_to_branch?` exists, but we also have a
      different way of checking the same condition within `change_access_check`.

    - This kind of duplication is removed, and the `can_push_to_branch?`
      method is used in both places.

3. Move checks returning true/false to `UserAccess`.

    - All public methods in `GitAccess` now return an instance of
      `GitAccessStatus`. Previously, some methods would return
      true/false as well, which was confusing.

    - It makes sense for these kinds of checks to be at the level of a
      user, so the `UserAccess` class was repurposed for this. The prior
      `UserAccess.allowed?` classmethod is converted into an instance
      method.

    - All external uses of these checks have been migrated to use the
      `UserAccess` class

4. Move the "change_access_check" into a separate class.

    - Create the `GitAccess::ChangeAccessCheck` class to run these
      checks, which are quite substantial.

    - `ChangeAccessCheck` returns an instance of `GitAccessStatus` as
      well.

5. Break out the boolean logic in `ChangeAccessCheck` into `if/else`
   chains - this seems more readable.

6. I can understand that this might look like overkill for !4892, but I
   think this is a good opportunity to clean it up.

    - http://martinfowler.com/bliki/OpportunisticRefactoring.html
2016-07-13 13:24:56 +05:30
Timothy Andrew 495db09653 Enforce "developers can merge" during `pre-receive`.
1. When a merge request is being merged, save the merge commit SHA in
   the `in_progress_merge_commit_sha` database column.

2. The `pre-receive` hook looks for any locked (in progress) merge
   request with `in_progress_merge_commit_sha` matching the `newrev` it
   is passed.

3. If it finds a matching MR, the merge is legitimate.

4. Update `git_access_spec` to test the behaviour we added here. Also
   refactored this spec a bit to make it easier to add more contexts / conditions.
2016-07-13 13:24:56 +05:30
Mathias Vestergaard f0577d8385 Added "developers can merge" setting to protected branches
- Cherry-picked from `mvestergaard:branch-protection-dev-merge`
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4220
2016-07-13 13:24:26 +05:30
Douwe Maan 5fea640e90 Merge branch 'multi-line-inline-diff' into 'master'
Render inline diffs for multiple changed lines following eachother

Before:

![Screen_Shot_2016-07-11_at_00.08.27](/uploads/b14664211e0f5cef6e77a78eadfcbcdf/Screen_Shot_2016-07-11_at_00.08.27.png)

After:

![Screen_Shot_2016-07-11_at_00.07.34](/uploads/567be631869a4867a2edf6ff7eda6369/Screen_Shot_2016-07-11_at_00.07.34.png)

See merge request !5174
2016-07-13 05:29:49 +00:00
Robert Speicher 1d958b035d Merge branch 'rs-describe-symbols' into 'master'
Avoid `describe`-ing symbols in specs

See merge request !5195
2016-07-12 20:01:29 +00:00
Robert Speicher adc6ec4a9c Avoid `describe`-ing symbols in specs 2016-07-12 10:27:58 -05:00
Douglas Barbosa Alexandre 3ddcd0d699 Remove unnecessary context from GitHub client spec 2016-07-12 12:14:17 -03:00
Douglas Barbosa Alexandre 38a58978aa Fix GItHub client requests when rate limit is disabled 2016-07-12 12:14:17 -03:00
Grzegorz Bizon b228787f5a Do not raise when getting value of invalid CI node 2016-07-12 14:58:48 +02:00
Grzegorz Bizon 06641a3fee Simplify undefined node definition in CI config 2016-07-12 14:28:50 +02:00
Grzegorz Bizon d41d330147 Add CI config node that is unspecified null entry 2016-07-12 13:03:19 +02:00
Douwe Maan f5cc3f63a8 Render inline diffs for multiple changed lines following eachother 2016-07-11 18:58:15 -05:00
James Lopez feecb4afde Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/import-event-error 2016-07-11 18:00:19 +02:00
James Lopez 0e5f0276ea squashed - refactor to cope with sub sub N relations probably using the sub_relations method recursively. 2016-07-11 17:21:22 +02:00
Rémy Coutable 11ba19e3d2 Merge branch 'fix/remove-import-url-migration' into 'master'
Remove slow migration and add fix to sanitize errors

Getting rid of the slow migration and preventing the Error to occur

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

See merge request !5176
2016-07-11 07:53:13 +00:00
James Lopez 99f7b6d246 spec and fix for sanitize method 2016-07-11 09:01:09 +02:00
Grzegorz Bizon 80587064eb Require parent when using node factory in CI config 2016-07-10 20:59:18 +02:00
Grzegorz Bizon 8f7c98ee2a Rename CI config job script entry node to commands 2016-07-10 20:26:37 +02:00
Grzegorz Bizon 500b61e14f Move after script CI job confg to new processor 2016-07-10 14:41:14 +02:00
Grzegorz Bizon 489e9be4e8 Add CI job script node in new config processor 2016-07-10 14:35:53 +02:00
Grzegorz Bizon 3c5b1da2a1 Add before_script node to CI job entry config 2016-07-10 13:54:39 +02:00
Grzegorz Bizon 2480701436 Extend CI job entries fabrication and validation 2016-07-09 18:43:26 +02:00
Grzegorz Bizon 9edced40dd Use node factory to assemble global CI config entry 2016-07-09 16:51:26 +02:00
Grzegorz Bizon ccbdb4022a Integrate CI job stage entry into CI configuration 2016-07-09 14:56:41 +02:00
Rémy Coutable 8bdb5b6aec Merge branch '1548-average-commits-per-day' into 'master'
Fix: Infinity Bug in Commit Statistics

## What does this MR do?

It fixes a logic bug in the commits statistics: The code assumed that the amount of days involved in a commit range is equal to the difference between the first and last date. This is not true, though, as (from a human standpoint), a commit yesterday and a commit today involve two days, not one. Similarly, a fresh project with only commits made today already 'used' one day.

Since the number of involved days used to be zero for new projects, the result for commits per day quite often amounted to `Infinity`…

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

The test file. I hope it is up to the standards of GitLab.

## Why was this MR needed?

The bug occurres especially for new users with their first project while exploring GitLab.

## What are the relevant issue numbers?

This bug was reported as #1548.

## Screenshots (if relevant)

See merge request !4231
2016-07-08 15:20:22 +00:00
Grzegorz Bizon d9142f2c97 Add CI config known stage validation for job stage 2016-07-08 13:31:41 +02:00
Grzegorz Bizon 1ac62de2c1 Extract CI entry node validator and improve naming 2016-07-08 12:51:47 +02:00
Grzegorz Bizon 8baee987be Extract internal attributes validator for CI entry 2016-07-08 11:27:36 +02: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
Grzegorz Bizon 3da57c800b Require reference to CI config for some entries 2016-07-07 15:15:44 +02:00
Grzegorz Bizon a7ac2f7494 Simplify CI config entry node factory, use attribs 2016-07-07 15:00:35 +02:00
Grzegorz Bizon 9410aecca8 Add scaffold of CI config for the job stage entry 2016-07-07 13:40:01 +02:00
Grzegorz Bizon fea7762485 Delegate methods to default CI entry if undefined 2016-07-07 12:55:10 +02:00
Grzegorz Bizon b0ae0d730f Use only node factory to create CI config entries 2016-07-07 10:23:47 +02:00
Douwe Maan e0ecfe5bd1 Add tests for Position 2016-07-06 18:51:01 -04:00
Douwe Maan ebb5f591e3 Add tests for PositionTracer 2016-07-06 18:51:00 -04:00
Douwe Maan 2f30d00432 Add DiffNote model 2016-07-06 18:50:59 -04:00
Douwe Maan e9e06ca627 Add Gitlab::Diff::LineMapper 2016-07-06 18:50:59 -04:00
Douwe Maan a9fa45f09e Represent DiffRefs as proper class instead of tuple array 2016-07-06 18:50:58 -04:00
Douwe Maan 6ce25e7b4c Rename MergeRequest methods that return commits or shas to be more clear and consistent 2016-07-06 18:50:58 -04:00
Douglas Barbosa Alexandre 5f86a084f2 Consider that a GH exists only if both `ref`, and `sha` exist 2016-07-06 13:08:12 -03:00
Grzegorz Bizon 4491bf28e1 Move CI job config validations to new classes 2016-07-06 14:08:19 +02:00
Grzegorz Bizon b1b0c18b8c Add hidden job in new CI config that is irrelevant 2016-07-06 12:58:43 +02:00
Patricio Cano be221a30ac Revert back to not defining a default Git access protocol. 2016-07-05 16:54:22 -05:00
Patricio Cano 29c50c5315 Default Git access protocol to `web` 2016-07-05 16:54:22 -05:00
Patricio Cano fbaabb3911 Rename `enabled_git_access_protocols` to singular. 2016-07-05 16:54:22 -05:00
Patricio Cano 42fb2516d9 Add more tests to the allowed protocols feature 2016-07-05 16:54:22 -05:00
Patricio Cano 8b14d1d2c2 Rename ENV['PROTOCOL'] to ENV['GL_PROTOCOL'] to conform to what GitLab Shell expects and make the `protocol` param in `GitAccess` mandatory. 2016-07-05 16:54:22 -05:00
Grzegorz Bizon dbab56a951 Create composite job entries in new CI config 2016-07-05 14:48:17 +02:00
Grzegorz Bizon 6ae80732bb Add ability to define nodes in new CI config entry 2016-07-05 14:17:09 +02:00
Grzegorz Bizon e00ae9a877 Add new CI config entry for single job in pipeline 2016-07-05 14:05:07 +02:00
Grzegorz Bizon 5b7f211cbb Add new CI config entry that holds jobs definition 2016-07-05 13:35:50 +02:00
Grzegorz Bizon cf53d79873 Extract jobs config to separate key in config hash 2016-07-05 13:07:03 +02:00
Paco Guzman 330de255b7 RailsCache metrics now includes fetch_hit/fetch_miss and read_hit/read_miss info. 2016-07-05 12:28:06 +02:00
Rémy Coutable 06c7d6f3a8 Merge branch 'refactor/ci-config-move-global-entries' into 'master'
Move global ci entries handling from legacy to new config

## What does this MR do?

This MR moves responsibility of handling global CI config entries (like `image`, `services`), from legacy `GitlabCiYamlProcessor` to new CI Config

## Why was this MR needed?

This is the next iteration of CI configuration refactoring

## What are the relevant issue numbers?

#15060

## Does this MR meet the acceptance criteria?

- 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)

See merge request !4820
2016-07-05 08:37:16 +00:00
Timothy Andrew eb16e1e3c2 Improve the error message displayed when branch creation fails.
Note: This feature was developed independently on master while this was
in review. I've removed the conflicting bits and left the relevant
additions, mainly a test for `Gitlab::Git::Hook`. The original commit
message follows:

1. `gitlab-shell` outputs errors to `stderr`, but we weren't using this
   information, prior to this commit. Now we capture the `stderr`, and
   display it in the flash message when branch creation fails.

2. This can be used to display better errors for other git operation
   failures with small tweaks.

3. The return value of `Gitlab::Git::Hook#trigger` is changed from a
   simple `true`/`false` to a tuple of `[status, errors]`. All usages
   and tests have been updated to reflect this change.

4. This is only relevant to branch creation _from the Web UI_, since SSH
   and HTTP pushes access `gitlab-shell` either directly or through
   `gitlab-workhorse`.

5. A few minor changes need to be made on the `gitlab-shell` end. Right
   now, the `stderr` message it outputs is prefixed by "GitLab: ", which
   shows up in our flash message. This is better removed.
2016-07-05 11:05:16 +05:30
Grzegorz Bizon bfad4c61f1 Add minor improvements in readability in CI config 2016-07-04 18:36:06 +02:00
Tomasz Maczukin f1a85747ca
Merge branch 'master' into dev-master
* master: (98 commits)
  Enable Style/EmptyLines cop, remove redundant ones
  Update CHANGELOG
  Cache results from jQuery selectors to retrieve namespace name
  Fix import button when import fail due the namespace already been taken
  Fix snippets comments not displayed
  Fix emoji paths in relative root configurations
  Exclude requesters from Project#members, Group#members and User#members
  Upgrade Thin from 1.6.1 to 1.7.0.
  Many squashed commits
  Cache autocomplete results
  Upgrade Sidekiq from 4.1.2 to 4.1.4.
  Upgrade seed-fu from 2.3.5 to 2.3.6
  use has_many relationship with events
  Support creating a todo on issuables via API
  Expose target, filter by state as string
  Add todos API documentation and changelog
  Improve the request / withdraw access button
  Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab
  Groundwork for Kerberos SPNEGO (EE feature)
  Update CHANGELOG 8.9.5 for runners related fixes
  ...
2016-07-02 22:58:21 +02:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Stan Hu 88dbc4d110 Merge branch 'fix-relative-root-emoji-support' into 'master'
Fix emoji paths in relative root configurations

## What does this MR do?

If a site specifies a relative URL root, emoji files would omit the path from the URL, leading to lots of 404s.

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

At first, I tried to use `ActionView::Helpers::AssetUrlHelper.asset_url` since this is what it's intended to do. But this helper function is extremely slow, and it took minutes to generate the URLs for the hundreds of links needed for each emoji.

## Why was this MR needed?

Because emojis were broken in relative URL installations

## What are the relevant issue numbers?

#15642

## Does this MR meet the acceptance criteria?

- [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 !5027
2016-07-01 16:51:03 +00:00
Stan Hu 4bfe10d5f9 Fix emoji paths in relative root configurations
If a site specifies a relative URL root, emoji files would omit the path from
the URL, leading to lots of 404s.

Closes #15642
2016-07-01 09:10:12 -07:00
James Lopez f29c30475e use has_many relationship with events 2016-07-01 15:34:10 +02:00
James Lopez d6d0a35598 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/import-export-events 2016-07-01 14:52:38 +02:00
Eric K Idema 12aa1f898d Import from Github using Personal Access Tokens.
This stands as an alternative to using OAuth to access a user's Github
repositories.  This is setup in such a way that it can be used without OAuth
configuration.

From a UI perspective, the how to import modal has been replaced by a full
page, which includes a form for posting a personal access token back to the
Import::GithubController.

If the user has logged in via GitHub, skip the Personal Access Token and go
directly to Github for an access token via OAuth.
2016-06-30 18:48:17 +02:00
Robert Speicher 443d584253 Merge branch 'rubocop/enable-unneeded-capital-w-cop' into 'master'
Enable Style/UnneededCapitalW Rubocop cop

## What does this MR do?

This MR enables Rubocop cop that checks if `%W[]`, which supports interpolation, is needed.

## What are the relevant issue numbers?

#17478 

See merge request !5010
2016-06-30 15:21:53 +00:00
Grzegorz Bizon efd70c1878 Enable Style/UnneededCapitalW Rubocop cop 2016-06-30 13:31:52 +02:00
Grzegorz Bizon b4f03e8b1e Improve description of CI types node and in specs 2016-06-30 12:59:17 +02:00
Alejandro Rodríguez 20b9bb2029 Create (if necessary) and link the gitlab-shell secret file on the rake install task 2016-06-29 22:30:33 -04:00
Alejandro Rodríguez 86359ec854 Refactor repository paths handling to allow multiple git mount points 2016-06-29 22:30:31 -04:00
Stan Hu d10642a4b8 Handle case when Redis cache returns an empty setting 2016-06-29 14:28:41 -07:00
Stan Hu c600cf8348 Fix database migrations when Redis is not running
If Redis were not running or USE_DB were set to false, the
application settings retrieval would fail completely. This
change only attempts to use the cache if the system actually
wants to connect to the DB and rescues any failures in talking to
Redis.

Closes #17557
2016-06-29 14:04:59 -07:00
Patricio Cano 10444f61f8 Fixed privilege escalation issue where manually set external users would be reverted back to internal users if they logged in via OAuth and that provider was not in the `external_providers` list. 2016-06-29 10:37:54 -05:00
Grzegorz Bizon 28bafd5354 Enable Style/SpaceAfterComma Rubocop cop 2016-06-29 15:23:44 +02:00
Grzegorz Bizon 9798ac77ed Enable Style/SpaceAfterColon Rubocop cops 2016-06-29 15:16:04 +02:00
James Lopez a65cf77ed9 fixes and refactored JSON spec 2016-06-29 13:11:26 +02:00
James Lopez 3d2a736679 fixing events for import/export 2016-06-29 10:35:26 +02:00
Grzegorz Bizon f4421817de Add global cache config entry to new CI config 2016-06-29 09:48:52 +02:00
Grzegorz Bizon 92312786f1 Add CI config entry location info to error message
This CI config entry location in configuration Hash.
2016-06-29 09:17:42 +02:00
Grzegorz Bizon 7c511c2f55 Make it possible to set parent in CI config node 2016-06-29 09:05:14 +02:00
Yorick Peterse d7b4f36a3c
Use clock_gettime for all performance timestamps
Process.clock_gettime allows getting the real time in nanoseconds as
well as allowing one to get a monotonic timestamp. This offers greater
accuracy without the overhead of having to allocate a Time instance. In
general using Time.now/Time.new is about 2x slower than using
Process.clock_gettime(). For example:

    require 'benchmark/ips'

    Benchmark.ips do |bench|
      bench.report 'Time.now' do
        Time.now.to_f
      end

      bench.report 'clock_gettime' do
        Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
      end

      bench.compare!
    end

Running this benchmark gives:

    Calculating -------------------------------------
                Time.now   108.052k i/100ms
           clock_gettime   125.984k i/100ms
    -------------------------------------------------
                Time.now      2.343M (± 7.1%) i/s -     11.670M
           clock_gettime      4.979M (± 0.8%) i/s -     24.945M

    Comparison:
           clock_gettime:  4979393.8 i/s
                Time.now:  2342986.8 i/s - 2.13x slower

Another benefit of using Process.clock_gettime() is that we can simplify
the code a bit since it can give timestamps in nanoseconds out of the
box.
2016-06-28 17:51:25 +02:00
Grzegorz Bizon 2846f95d2a Merge branch 'master' into refactor/ci-config-move-global-entries
* master: (352 commits)
  Display last commit of deleted branch in push events (!4699)
  add changelog
  add missing attribute to attr_encrypted so it is fully backwards-compatible
  Add "GitLab team members only" to diagram link
  doc: note that .gitattributes uses default branch
  use the conf lexer so we have highlighted comments
  first draft of docs
  support cgi style options, such as erb?parent=json
  move the path alias to a more appropriate location
  make #custom_language private
  appease rubocop
  add an alias for Snippet#path
  appease rubocop
  check the tag so that an instance will pass too
  fix the spec, using project.change_head
  Revert "bump the master sha for gitlab-test!9"
  bump the master sha for gitlab-test!9
  add custom highlighting via .gitattributes
  Rename Licenses API to License Templates API
  Check for conflict with wiki projects when creating a new project.
  ...
2016-06-28 14:38:05 +02:00
http://jneen.net/ 66b37149eb support cgi style options, such as erb?parent=json 2016-06-27 14:17:49 -07:00
http://jneen.net/ 9fc53864dd appease rubocop 2016-06-27 14:17:49 -07:00
http://jneen.net/ 5415c67424 check the tag so that an instance will pass too 2016-06-27 14:17:49 -07:00
http://jneen.net/ cd9bea770b fix the spec, using project.change_head 2016-06-27 14:17:49 -07:00
http://jneen.net/ f8b80f7fae add custom highlighting via .gitattributes
paired with @stanhu
2016-06-27 14:17:49 -07:00
Grzegorz Bizon c019585cb8 Validate interface only with CI node validator 2016-06-27 14:16:57 +02:00
Grzegorz Bizon 56e88b8c28 Add new ci config entry that handles cache config 2016-06-27 14:01:12 +02:00
Rémy Coutable a9dbd394a6 Merge branch 'refactor/ci-config-add-entry-error' into 'master'
Improve validations and error handling in new CI config entries

## What does this MR do?

This MR improves validation in new CI config.

## Why was this MR needed?

With that it will be easier to handle errors during validation and post-processing.

## What are the relevant issue numbers?

This is a continuation of #15060

See merge request !4560
2016-06-27 08:24:17 +00:00
Grzegorz Bizon ce4478ed86 Add ci config entry that represents array of paths 2016-06-24 09:54:52 +02:00
Grzegorz Bizon e017e1b629 Add ci config class that represents a boolean value 2016-06-24 09:49:54 +02:00
Grzegorz Bizon 04ece6664a Add ci config class that represents a key value 2016-06-24 08:58:09 +02:00
Rémy Coutable 6f6dcc366b Merge branch 'fix/import-export-gitlab-errors' into 'master'
Fix errors found on importing GitLab CE repo

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

See merge request !4855
2016-06-23 14:13:17 +00:00
Grzegorz Bizon 1f320edb77 Minor refactorings in new CI configuration classes 2016-06-23 13:51:34 +02:00
Grzegorz Bizon 29b96d92c1 Move CI stages configuration to new CI config 2016-06-23 13:51:07 +02:00
Paco Guzman 9101915cb7 Add Sidekiq queue duration to transaction metrics. 2016-06-23 13:09:52 +02:00
James Lopez f854f6cd02 fixed pipeline notes issue 2016-06-23 12:29:11 +02:00
Grzegorz Bizon 2240807c1a Assume that unspecified CI config is undefined
We assume that when someone adds a key for the configuration entry, but
does not provide a valid value, which causes entry to be `nil`, then
entry should be considered as the undefined one. We also assume this is
semantically correct, this is also backwards compatible with legacy CI
config processor.

See issue #18775 for more details.
2016-06-23 10:22:41 +02:00
Robert Speicher cef021917f Merge branch 'fix_saml_signin' into 'master'
Fix subsequent SAML sign ins

Fixes a bug when `auto_link_ldap_user` is `true` that causes SAML users to be unable to sign in a second time.

Fix the problem for https://gitlab.zendesk.com/agent/tickets/22546

See merge request !4718
2016-06-22 22:12:09 +00:00
Drew Blessing 938f2b9979 Fix subsequent SAML sign ins 2016-06-22 16:10:55 -05:00
Grzegorz Bizon bc2348f2e4 Return default config value when entry is undefined 2016-06-22 14:26:33 +02:00
Grzegorz Bizon 05ce8a1187 Handle CI environment variables in a new CI config 2016-06-22 11:22:53 +02:00
Grzegorz Bizon 04ecfca386 Rename CI config null node entry to undefined node 2016-06-22 10:44:33 +02:00
Rémy Coutable ed519c161b Merge branch 'ci-lfs-fetch' into 'master'
Allow to fetch LFS from CI

## What does this MR do?

This adds support for fetching LFS object from CI jobs (mostly it's made for supporting GitLab CI).

## What is left?

- [x] Write tests covering a new authorization mechanism

cc @grzesiek @marin

See merge request !4465
2016-06-21 13:05:35 +00:00
Grzegorz Bizon d399128955 Handle after script CI config in new classes
This also makes Script to return an array of commands instead of
concatented command, which is our current direction.
2016-06-21 13:02:14 +02:00
Grzegorz Bizon fc00c545b2 Handle CI services config in new CI config classes 2016-06-21 12:40:52 +02:00
Grzegorz Bizon cd6a2afbbb Move CI image configuration entry to new CI config 2016-06-21 12:10:13 +02:00
Grzegorz Bizon 8b550db33e Add image configuration entry to new ci config 2016-06-21 11:47:05 +02:00
Grzegorz Bizon c91298d554 Use generic type validator in new ci configuration 2016-06-21 11:43:32 +02:00
Kamil Trzcinski 6bc22d95b8 Add test coverage to LFS fetching 2016-06-21 11:26:44 +02:00
Kamil Trzcinski 2f545a15c0 Merge remote-tracking branch 'origin/master' into ci-lfs-fetch 2016-06-21 10:11:14 +02:00
ZJ van de Weg 27bf7ae59e Refactor Gitlab::Gitignores 2016-06-20 14:48:28 -05:00
Lin Jen-Shin 176fa21cb7 raise UnknownIncomingEmail when there's no mail_key:
So that we don't have to pretend that CreateNoteHandler
could handle a nil mail_key. Also, since NilClass#=~ would
just return nil for any regular expression, we could just
match it without checking nilness.

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3363#note_12566407
2016-06-20 19:15:54 +08:00
Grzegorz Bizon 9510d31b4d Merge branch 'master' into refactor/ci-config-add-entry-error
* master: (345 commits)
  use rails root join
  fixed a couple of errors spotted in production
  Fix RangeError exceptions when referring to issues or merge requests outside of max database values
  Fix bug in `WikiLinkFilter`.
  Small frontend code fixes and restore 8a2d88f commit
  Warn about admin privilege to disable GitHub Webhooks
  Listing GH Webhooks doesn't stop import process for non GH admin users
  fixup! updated docs for api endpoint award emoji
  Update CHANGELOG
  Ensure Todos counters doesn't count Todos for projects pending delete
  Add endpoints for award emoji on notes
  Sort API endpoints and implement feedback
  Add endpoints for Award Emoji
  Fixed issue with assignee dropdown not selecting correctly
  Removed update method Re-structured controller spec Renamed issuable param to issuable_id
  Fix clibpoard buttons on "Check out branch" modal.
  Track method call times/counts as a single metric
  Cache todo counters (pending/done)
  Fix a 'wrong number of arguments' error
  Added missing mount point for Sidekiq Metrics API, after it got lost on rebase.
  ...
2016-06-20 10:38:46 +02:00
Yorick Peterse be3b878443 Track method call times/counts as a single metric
Previously we'd create a separate Metric instance for every method call
that would exceed the method call threshold. This is problematic because
it doesn't provide us with information to accurately get the _total_
execution time of a particular method. For example, if the method
"Foo#bar" was called 4 times with a runtime of ~10 milliseconds we'd end
up with 4 different Metric instances. If we were to then get the
average/95th percentile/etc of the timings this would be roughly 10
milliseconds. However, the _actual_ total time spent in this method
would be around 40 milliseconds.

To solve this problem we now create a single Metric instance per method.
This Metric instance contains the _total_ real/CPU time and the call
count for every instrumented method.
2016-06-17 13:09:55 -04:00
Yorick Peterse ed5f17cc73 Merge branch 'secure-request-uris' into 'master'
Filter out sensitive parameters of metrics data

See merge request !4748
2016-06-17 16:43:14 +00:00
Robert Speicher 8dccfb4a9c Merge branch 'update-column-in-batches-where' into 'master'
Allow customising of queries used for `update_column_in_batches`

This MR makes two changes to `add_column_with_default` and `update_column_in_batches`:

1. `add_column_with_default` no longer wraps the entire set of updates in a single transaction, preventing any locks from sticking around for the duration of the entire transaction
2. `update_column_in_batches` now takes a block which can be used to customise the queries. This uses Arel as messing with raw SQL strings is a total pain

In !4381 there's a need for updating existing rows/columns in a table in batches using a custom `WHERE` condition. Without the changes in this MR this would not be possible.

See merge request !4680
2016-06-17 16:36:22 +00:00
Paco Guzman 2e552c6bf0 Filter out sensitive parameters of metrics data 2016-06-17 18:14:25 +02:00
Douwe Maan 9b7fd74805 Merge branch 'feature/project-export' into 'master'
Export project functionality

This is a MR for the export functionality of https://gitlab.com/gitlab-org/gitlab-ce/issues/3050, which adds the ability to export single projects.

- [x] members
- DB data
  - [x] issues
  - [x] issue comments
  - [x] merge requests
  - [x] merge request diff
  - [x] merge request comments
  - [x] labels
  - [x] milestones
  - [x] snippets
  - [x] releases
  - [x] events
  - [x] commit statuses
  - [x] CI builds
- File system data
  - [x] Git repository
  - [x] wiki
  - [x] uploads
  - [ ] ~~CI build traces~~
  - [ ] ~~CI build artifacts~~
  - [ ] ~~LFS objects~~
- DB configuration
  - [x] services
  - [x] web hooks
  - [x] protected branches
  - [x] deploy keys
  - [x] CI variables
  - [x] CI triggers

See merge request !3114
2016-06-17 15:35:27 +00:00
Grzegorz Bizon 44b00a1ebb Extract CI entry config hash validation to validator 2016-06-17 15:02:39 +02:00
Grzegorz Bizon 2a87a55f87 Merge branch 'master' into refactor/ci-config-add-entry-error
* master: (189 commits)
  Update CHANGELOG for !4659
  Center the header logo for all Devise emails
  Add previews for all customized Devise emails
  Customize the Devise `unlock_instructions` email
  Customize the Devise `reset_password_instructions` email
  Customize the Devise `password_change` emails
  Use gitlab-git 10.2.0
  Use Git cached counters on project show page
  Fix indentation scss-lint errors
  Added title attribute to enties in tree view Closes #18353
  Banzai::Filter::ExternalLinkFilter use XPath
  Reduce queries in IssueReferenceFilter
  Use gitlab_git 10.1.4
  Fixed ordering in Project.find_with_namespace
  Fix images in emails
  Banzai::Filter::UploadLinkFilter use XPath
  Turn Group#owners into a has_many association
  Make project_id nullable
  ...
2016-06-17 12:25:43 +02:00
Grzegorz Bizon d9ca84015c Add first custom validator for new ci config
This follows a standard `ActiveModel` pattern of creating a custom
validators. We use `ActiveModel::EachValidator` here that reuses methods
provided by `LegacyValidationHelpers`.

We will remove `LegacyValidationHelpers` on some point in the future, at
the later stages of CI configuration refactoring. It may be possible
to rewrite custom validators to use format like:

`validates :config, array_of: String`
2016-06-17 12:06:48 +02:00
Grzegorz Bizon 002e6ed1f0 Improve CI config entries validations prototype 2016-06-17 11:23:16 +02:00
Grzegorz Bizon 95520dfc72 Add prototype of CI config node validator
This makes use of `ActiveModel::Validations` encapsulated in a separate
class that is accessible from a node object.
2016-06-16 15:46:03 +02:00
James Lopez b3a0a1c315 fixed merge conflicts on UI branch 2016-06-16 15:01:27 +02:00
James Lopez 2a747d386d fixed merge conflicts 2016-06-16 14:07:49 +02:00
James Lopez 778d72664f Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export
# Conflicts:
#	app/models/ci/pipeline.rb
2016-06-16 13:04:00 +02:00
James Lopez 452c076a34 Revert "squashed merge and fixed conflicts"
This reverts commit 13e37a3ee5.
2016-06-16 12:59:07 +02:00