Commit Graph

2494 Commits

Author SHA1 Message Date
http://jneen.net/ 822304b19f fix Gitlab::Highlight#initializer bugs from rebase 2016-07-14 11:40:55 -07:00
http://jneen.net/ f82287e2cc use the local lexer variable to respect plain: ... 2016-07-14 10:08:15 -07:00
http://jneen.net/ 6107933ba3 inline #rouge_formatter 2016-07-14 10:08:15 -07:00
http://jneen.net/ e1824aa101 use the new token_lines interface to format lines 2016-07-14 10:08:15 -07:00
http://jneen.net/ 3bb65815b0 kill the :cssclass option 2016-07-14 10:08:15 -07:00
http://jneen.net/ 7214a221e0 kill the nowrap option
the <pre><code> wrapping is *always* used by the helper, and *never* by
anywhere else, so pull the wrapping into the helper
2016-07-14 10:08:14 -07:00
http://jneen.net/ 7e8a92fbd1 the call site always specifies this option 2016-07-14 10:08:14 -07:00
http://jneen.net/ 681b5af586 do this thing in a clearer way 2016-07-14 10:08:14 -07:00
James Lopez 37e363c9cf fixed similar issue with gitlab.com importer because why not! 2016-07-14 17:06:48 +02:00
James Lopez b1ab079fae fix updated_at not preserved after import - for GitLab projects 2016-07-14 16:03:00 +02:00
Grzegorz Bizon 615c9730e7 Remove job cache configfrom legacy yaml processor 2016-07-14 16:01:18 +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
Robert Speicher 9b0ef1559f Merge branch 'better-parallel-diff' into 'master'
Actually render old and new sections of parallel diff next to each other

See merge request !5173
2016-07-13 18:10:01 +00:00
Douglas Barbosa Alexandre a14ee9bef9 Keeps issue number when importing from Gitlab.com
With these changes we don’t lost the issue references when importing
from `GitLab.com`.
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 097550f08a Fabricate CI entry with value, set attributes later 2016-07-13 13:42:57 +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 ea9e8f4609 Move all "checks" under `GitLab::Checks`.
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4892#note_12892160
- This is more consistent.
2016-07-13 13:24:56 +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
Douwe Maan 545a85dc64 Actually render old and new sections of parallel diff next to each other 2016-07-13 00:04:07 -05:00
Douwe Maan 489e193704 Rename constant to be more descriptive 2016-07-13 00:02:20 -05:00
Douwe Maan e981d6cd0d Extended regexes ignore whitespace, so use \s 2016-07-12 11:25:39 -05:00
Douglas Barbosa Alexandre 78a5de99e9 Memoize response from `has_rate_limit?` to avoid extra API call 2016-07-12 12:14:17 -03:00
Douglas Barbosa Alexandre be9262dd95 Checks if rate limit is enabled instead of stubbing response 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 61f7bede79 Fix using `try` on delegators in CI config entries
See:

af53280a4b
2016-07-12 14:40:51 +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
Grzegorz Bizon 8c9c3eda7a Prevalidate CI entries recursively on processed 2016-07-12 12:56:21 +02:00
Douwe Maan f5cc3f63a8 Render inline diffs for multiple changed lines following eachother 2016-07-11 18:58:15 -05:00
Robert Speicher 734e44ee79 Merge branch 'fix/import-event-error' into 'master'
Fix problems with events under notes importing GitLab projects

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

See merge request !5154
2016-07-11 18:35:08 +00:00
Douwe Maan ef9ba9050e Merge branch 'single-file-diffs' into 'master'
Single file diffs

Closes #14103. Related (not part of this MR): #19553.

This adds a `diff_for_path` action to each place we render diffs (commit, compare, new MR, existing MR) which renders the diff for a single path. The action is always available with the same params as the 'parent' action, to make it simpler to generate the URIs.

If a diff is bigger than 10 KB, it will be collapsed by default and have a data attribute added. You can then click the message or the filename to expand that diff. For expanded files, you can collapse and expand them, but they won't make any AJAX requests.

![Expand_and_collapse_diffs](/uploads/a4072029085082b85c47006f67ac531c/Expand_and_collapse_diffs.gif)

See merge request !4990
2016-07-11 17:51:57 +00:00
Douwe Maan 284ed39e30 Merge branch 'send-entry-via-Gitlab-Workhorse-Send-Data' into 'master'
Use Gitlab-Workhorse-Send-Data to send entry

## What does this MR do?

Use Gitlab-Workhorse-Send-Data to send entry:

Closes #19224, Closes #19128

Also requires this MR to work:
https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/53

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

Do we have a test for this?

## Why was this MR needed?

This way gitlab-workhorse does not have to call any API.

See merge request !5094
2016-07-11 16:18:37 +00: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
Sean McGivern 79a47582e8 Merge branch 'master' into single-file-diffs 2016-07-11 09:38:11 +01: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 a80a01e841 Add comment for deprecated CI config `types` entry 2016-07-09 17:38:03 +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 1b624ba4eb Improve name of CI entry validation context hook 2016-07-08 13:36:01 +02: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
Sean McGivern b6b26692ea Collapse large diffs by default
When rendering a list of diff files, skip those where the diff is over
10 KB and provide an endpoint to render individually instead.
2016-07-08 10:56:55 +01:00
Grzegorz Bizon 159aed1c42 Extract global CI config entry configuration setup 2016-07-08 11:29:03 +02:00
Grzegorz Bizon 8baee987be Extract internal attributes validator for CI entry 2016-07-08 11:27:36 +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
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
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
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
Grzegorz Bizon 3da57c800b Require reference to CI config for some entries 2016-07-07 15:15:44 +02:00
Grzegorz Bizon f067202e9b Improve creating CI config entries for jobs config 2016-07-07 15:10:39 +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 ecdcf04e88 Add undefined CI node strategies to handle defaults 2016-07-07 13:17:50 +02:00
Grzegorz Bizon de8b93bbff Improve validation of CI config entry if composite 2016-07-07 12:56:00 +02:00
Grzegorz Bizon fea7762485 Delegate methods to default CI entry if undefined 2016-07-07 12:55:10 +02: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
Grzegorz Bizon b0ae0d730f Use only node factory to create CI config entries 2016-07-07 10:23:47 +02:00
James Lopez 91a183bc57 fix log statements in import/export 2016-07-07 09:49:46 +02:00
Douwe Maan ac26b23712 Remove duplication, unused methods, and some other style things 2016-07-06 19:29:41 -04:00
Douwe Maan 228d2a4cb1 Add some more code comments. 2016-07-06 19:28:13 -04:00
Douwe Maan ddec2ed0df Add send_git_patch helper 2016-07-06 18:51:01 -04:00
Douwe Maan 29d574868a Display new diff notes and allow creation through the web interface 2016-07-06 18:51:00 -04:00
Douwe Maan 521a0a20f7 Allow reply-by-email with diff notes 2016-07-06 18:51:00 -04:00
Douwe Maan db65954d78 Add Gitlab::Git::PositionTracer 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 9abcc0a98f Add Gitlab::Git::Position 2016-07-06 18:50:59 -04:00
Douwe Maan a27462a5c6 Extract parts of LegacyDiffNote into DiffOnNote concern and move part of responsibility to other classes 2016-07-06 18:50:59 -04:00
Douwe Maan 375193455a Style diff and blob file headers the same way 2016-07-06 18:50:59 -04:00
Douwe Maan 9fc0e11e0d Add DiffFile#blob and #old_blob 2016-07-06 18:50:58 -04:00
Douwe Maan 17ab745e40 Add Timeless helper module to prevent updated_at from being updated 2016-07-06 18:50:58 -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
Douglas Barbosa Alexandre 4e5de3e6ee Doesn't trigger Git hooks when cleaning up restored branches from GitHub 2016-07-06 13:08:12 -03:00
Robert Speicher be018ba8c4 Merge branch 'fix/import-url-validator' into 'master'
Fixing URL validation for import_url on projects

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

This MR fixes problems related to bypassing `import_url` validation on projects. This makes sure the URL is properly validated so we don't enter crap and fail while running workers that handle this URL.

It also adds a migration to fix current invalid `import_url`s

See merge request !4753
2016-07-06 15:06:01 +00:00
Rémy Coutable b73da89591 Merge branch 'fix/project-export-error' into 'master'
Add more debug info to import/export and memory killer

This should help debug https://gitlab.com/gitlab-org/gitlab-ce/issues/19124 further

See merge request !5108
2016-07-06 13:09:02 +00: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
James Lopez 09452715d3 fix typo 2016-07-06 11:09:07 +02:00
James Lopez 95f630daeb even more debug 2016-07-06 10:29:31 +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 d1151f7621 Don't allow empty strings in the `protocol` check. 2016-07-05 16:54:22 -05:00
Patricio Cano 9397ce9137 Correct access control flow for Git HTTP requests. 2016-07-05 16:54:22 -05:00
Patricio Cano da15471bb1 Clarify protocol access check, and make Git HTTP access call more specific. 2016-07-05 16:54:22 -05:00
Patricio Cano ace309d775 Raise an error if no protocol is passed to the GitAccess check. 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
Patricio Cano 7735ef86f0 Only allow Git Access on the allowed protocol 2016-07-05 16:54:22 -05:00
Robert Speicher aefb8a1741 Merge branch 'update-gemoji' into 'master'
Add lib/gitlab/emoji.rb instead of gitlab_emoji gem and upgrade Gemojione

- No reason to split it into a separate gem when the gem barely did anything. We can use gemojione directly, making updating gemojione that much easier. Unless there's a particularly good reason we were using the gem?
- Fixes the Rake task since it broke after all the AwardEmoji changes.
- Update gemojione to 2.6.1.

Spring Update changes! http://emojione.com/releases/#2.2.0

See merge request !4919
2016-07-05 17:08:35 +00:00
Lin Jen-Shin 28e324ae67 Use Gitlab-Workhorse-Send-Data to send entry:
Closes #19224, Closes #19128

Also requires this MR to work:
https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/53
2016-07-05 22:58:38 +08: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 9686a4f2b2 Remove code creating job hash from legacy CI config 2016-07-05 13:19:22 +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
Paco Guzman e9a4d117f2 Instrument cache fetch hit and cache fetch misses 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
Dmitriy Zaporozhets fd2b2dc1de Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq 2016-07-04 21:52:43 +03:00
Valery Sizov 926a8ab476 Handle custom Git hook result in GitLab UI 2016-07-04 20:16:55 +03:00
Grzegorz Bizon bfad4c61f1 Add minor improvements in readability in CI config 2016-07-04 18:36:06 +02:00
Valery Sizov bf218337ed Better message for git hooks and file locks 2016-07-04 15:31:49 +03:00
Grzegorz Bizon eb151e77ff Extract CI configuration entry node factory method 2016-07-04 11:29:59 +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
Douwe Maan 5e6342b7ac Merge branch '19312-confidential-issue' into 'master'
Fix privilege escalation issue with OAuth external users

Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/19312

This MR fixes a 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.

/cc @douwe 

See merge request !1975
2016-06-30 15:42:15 +00:00
James Lopez ef5713546b few more changes from suggestions 2016-06-30 17:22:56 +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
James Lopez 67f59ebd50 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/import-url-validator
# Conflicts:
#	spec/models/project_spec.rb
2016-06-30 14:37:48 +02:00
James Lopez 545b92af06 use class method 2016-06-30 14:30:07 +02:00
Grzegorz Bizon efd70c1878 Enable Style/UnneededCapitalW Rubocop cop 2016-06-30 13:31:52 +02:00
James Lopez 5b893d603d few changes based on feedback 2016-06-30 13:17:37 +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
Connor Shea f31f78cea3
Add emoji.rb in lib/gitlab instead of using the gitlab_emoji gem.
No reason to split it into a separate gem when the gem barely did anything. We can use gemojione directly, making updating gemojione that much easier.

Also fix the Rake task and update gemojione to 2.6.1. This adds the EmojiOne Spring update.

Changelog: https://github.com/jonathanwiesel/gemojione/blob/master/CHANGELOG.md
2016-06-29 14:53:09 -06: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