Commit Graph

617 Commits

Author SHA1 Message Date
Oswaldo Ferreira 0e14a2f21d Add commment to Issue, Project and MergeRequest #to_reference 2017-01-27 20:20:18 -02:00
Oswaldo Ferreira 660a755cad Change argument name assuming its always a Project 2017-01-27 20:20:18 -02:00
Sean McGivern 448321a46e Merge branch 'fix_broken_diff_discussions' into 'master'
Make diff discussions more reliable

Closes #23646

See merge request !8378
2017-01-25 09:54:34 +00:00
Sean McGivern d3f26be6f0 Merge branch '23524-notify-automerge-user-of-failed-build' into 'master'
Notify the user who set auto-merge when merge is not possible

Closes #23524

See merge request !8056
2017-01-19 11:05:38 +00:00
Dongqing Hu d0db72983e use the current_user parameter in MergeRequest#issues_mentioned_but_not_closing 2017-01-18 17:06:19 +08:00
twonegatives 85e0b99471 Notify the user who set auto-merge when merge conflict occurs 2017-01-14 12:22:30 +03:00
Jarka Kadlecova 7ab3dd4b30 support `/merge` slash comand for MRs 2017-01-11 08:48:07 -05:00
Mike Greiling ba5ba96f2b prevent 500 error when selecting changes tab for non-existent branch 2017-01-03 13:08:52 -06:00
James Lopez 112f470572 Fix cross-project references copy to include the project reference
Also added relevant specs and refactored to_references in a bunch of places to be more consistent.
2017-01-03 13:01:46 +01:00
Valery Sizov 95047f1dc7 Make diff discussion more reliable 2016-12-30 17:42:27 +02:00
Gabriel Gizotti 38dd9b545c use MergeRequest#closes_issues instead of rewriting code to retrieve closing issues on MergeRequest#issues_mentioned_but_not_closing 2016-12-28 23:22:31 +10:00
Sean McGivern ed6900caf1 Use raw_diffs to calculate MR files changed
We don't need to create the intermediate FileCollection object with its
associated highlighting in order to count how many files changed. Both
the compare object and the MR diff object have a raw_diffs method that
is perfectly fine for this case.
2016-12-26 14:27:20 +00:00
Rémy Coutable 8c8c4f8c5a Merge branch 'fix/import-export-mr-error' into 'master'
Fix import/export merge requests error

When MWBS is set and the MR exported/imported an error gets thrown. We should ignore this so it can succeed as the merge user may no longer exist in the target instance.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/24009 and https://gitlab.com/gitlab-com/support-forum/issues/1345

See merge request !8134
2016-12-19 18:03:06 +00:00
James Lopez 0631c7bcdc Fix MR issue to do with merge user 2016-12-19 16:52:38 +01:00
Gabriel Gizotti 3e3d6b53dc Change closes issues reference text on MergeRequest#merge_commit_message to match existing text generated by the system 2016-12-16 19:15:07 +10:00
Gabriel Gizotti 7d7ae494d4 add guard clause to MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 603ef5d49e Show either description or closes issues references on MergeRequest#merge_commit_message so closes issues references are not duplicated 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 4181528569 Better `Closes issues` text for MergeRequest#merge_commit_message 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 58609f842e backend completely drives creation of merge commit message 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 512c870ed4 Remove unnecessary code from MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti b4764a8dd2 shorter lines on MergeRequest#merge_commit_message 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 0e76daf3da only look for issues mentioned on description on MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 1a8f43ff3e introduce MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti e52e3ab508 Remove whole description from #merge_commit_message and add add closed issues 2016-12-16 19:13:17 +10:00
Douwe Maan 12db4cc0e7 Merge branch 'jej-note-search-uses-finder' into 'security'
Fix missing Note access checks in by moving Note#search to updated NoteFinder

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

### Note lookup without access check

- [x]  app/finders/notes_finder.rb:13 :download_code check
- [x]  app/finders/notes_finder.rb:19 `SnippetsFinder`
- [x]  app/models/note.rb:121 [`Issue#visible_to_user`]
- [x]  lib/gitlab/project_search_results.rb:113
  - This is the only use of `app/models/note.rb:121` above, but importantly has no access checks at all. This means it leaks MR comments and snippets when those features are `team-only` in addition to the issue comments which would be fixed by `app/models/note.rb:121`.
  - It is only called from SearchController where `can?(current_user, :download_code, @project)` is checked, so commit comments are not leaked.

### Previous discussions
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b915c5267a63628b0bafd23d37792ae73ceae272_13_13 `: download_code` check on commit
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b915c5267a63628b0bafd23d37792ae73ceae272_19_19 `SnippetsFinder` should be used
  - `SnippetsFinder` should check if the snippets feature is enabled -> https://gitlab.com/gitlab-org/gitlab-ce/issues/25223

###  Acceptance criteria met?
- [x] Tests added for new code
- [x] TODO comments removed
- [x] Squashed and removed skipped tests
- [x] Changelog entry
- [ ] State Gitlab versions affected and issue severity in description
- [ ] Create technical debt issue for NotesFinder.
  - Either split into `NotesFinder::ForTarget` and `NotesFinder::Search` or consider object per notable type such as `NotesFinder::OnIssue`. For the first option could create `NotesFinder::Base` which is either inherited from or which can be included in the other two.
  - Avoid case statement anti-pattern in this finder with use of `NotesFinder::OnCommit` etc. Consider something on the finder for this? `Model.finder(user, project)`
  - Move `inc_author` to the controller, and implement `related_notes` to replace `non_diff_notes`/`mr_and_commit_notes`

See merge request !2035
2016-12-15 11:40:12 -03:00
Adam Niedzielski 9190cea215 Do not reload diff for merge request made from fork when target branch in fork is updated
The target branch of a merge request has to be a branch in the project
for which the merge request is submitted. When a branch changes in a fork,
it does not make sense to reload diffs of merge requests in the upstream
project that use the same branch name as the target branch.
Please note that it does make sense to reload diffs when the source branch
changes.
2016-12-09 12:10:26 +01:00
Douwe Maan f23b1cb453 Merge branch 'jej-23867-use-mr-finder-instead-of-access-check' into 'security'
Replace MR access checks with use of MergeRequestsFinder

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/finders/notes_finder.rb:17
- [x] ⚠️  app/views/layouts/nav/_project.html.haml:80 [`.count`]
- [x] 💣  app/controllers/concerns/creates_commit.rb:84
- [x] 🚥  app/controllers/projects/commits_controller.rb:24
- [x] 🚥  app/controllers/projects/compare_controller.rb:56
- [x] 🚦  app/controllers/projects/discussions_controller.rb:29
- [x]   app/controllers/projects/todos_controller.rb:27
- [x] 🚦  app/models/commit.rb:268
- [x]  lib/gitlab/search_results.rb:71

- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#d1c10892daedb4d4dd3d4b12b6d071091eea83df_267_266 Memoize ` merged_merge_request(current_user)`
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#d1c10892daedb4d4dd3d4b12b6d071091eea83df_248_247 Expected side effect for `merged_merge_request!`, consider `skip_authorization: true`.
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#d1c10892daedb4d4dd3d4b12b6d071091eea83df_269_269 Scary use  of unchecked `merged_merge_request?`

See merge request !2033
2016-12-08 21:42:07 -03:00
Sean McGivern d9ef41cf4d Merge branch '23589-open-issue-for-mr' into 'master'
Create an issue for all unresolved discussions in an MR

See merge request !7180
2016-12-06 14:04:14 +00:00
Bob Van Landuyt 1123057ab7 Feature: delegate all open discussions to Issue
When a merge request can only be merged when all discussions are
resolved. This feature allows to easily delegate those discussions to a
new issue, while marking them as resolved in the merge request.

The user is presented with a new issue, prepared with mentions of all
unresolved discussions, including the first unresolved note of the
discussion, time and link to the note.

When the issue is created, the discussions in the merge request will get
a system note directing the user to the newly created issue.
2016-12-05 20:55:45 +01:00
Oswaldo Ferreira f272ee6eba Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
Adam Niedzielski cb6f8cdfc2 Replace references to MergeRequestDiff#commits with st_commits
when we care only about the number of commits

We do not have to instantiate all objects in this case.
2016-12-01 12:17:30 +01:00
Grzegorz Bizon a49e9949c6 Rename `MergeRequest#pipeline` to `head_pipeline` 2016-11-29 14:12:49 +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 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
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
Douwe Maan f2a0c6f6bf Correctly determine mergeability of MR with no discussions 2016-11-23 20:02:14 +08:00
Rémy Coutable 1a5eedf3fe
Fix a wrong "The build for this merge request failed" message
Also allow merge request to be merged with skipped pipeline and the
"only allow merge when pipeline is green" feature enabled

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-21 14:22:28 +01:00
Grzegorz Bizon 5328e3b127 Make commit an optional arg for environments search 2016-11-09 14:46:36 +01:00
Rodolfo Santos 1db9f826c1 Add setting to only allow merge requests to be merged when all discussions are resolved
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-04 14:58:40 +01:00
Rémy Coutable 46689162a3 Ensure merge request's "remove branch" accessors return booleans
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-03 18:29:00 +01:00
Guilherme Salazar 32913b74b8 add "x of y tasks completed" on issuable
fix issues pointed out in !6527

add task completion status feature to CHANGELOG
2016-10-28 14:01:36 -02:00
David Wagner 03b6108f6f Remove redundant class_name and foreign_key overrides
They were Rails' default and are unnecessarily overridden.

Signed-off-by: David Wagner <david@marvid.fr>
2016-10-24 22:29:48 +02:00
Nick Thomas 61536ed2cf Rename forked_source_project_missing? to source_project_missing? 2016-10-20 12:24:27 +01:00
Nick Thomas 374071321d Fix the merge request view when source projects or branches are removed 2016-10-20 12:24:27 +01:00
Nick Thomas e6f515ecbe Revert "Add #closed_without_source_project?"
This reverts commit 31c37c6c38.

See #23341
2016-10-20 01:31:54 +01:00
Douglas Barbosa Alexandre fc2c64fcdf Add self.project_foreign_key on both Issue and MergeRequest 2016-10-19 14:58:28 -02:00
Grzegorz Bizon 72d84e4851 Improve code that creates a list of commits for MR 2016-10-18 08:32:17 -05:00
Grzegorz Bizon ab8ef17fb2 Extend merge request tests for all commits method 2016-10-18 08:32:17 -05:00
Grzegorz Bizon d5b1d0ea50 Use temporary compare commits when MR not persisted 2016-10-18 08:32:17 -05:00
Sean McGivern 86dcb79be3 Merge branch 'master' into merge-conflicts-editor-2 2016-10-17 10:56:55 +01:00
Z.J. van de Weg fa58068b28 Refactor ci_status on MergeRequestController 2016-10-14 11:07:01 +02:00
Z.J. van de Weg 8a1064d762 Fix indenting error in HAML 2016-10-14 11:07:00 +02:00
Z.J. van de Weg 6a4f710083 Show what time ago a MR was deployed 2016-10-14 11:07:00 +02:00
Sean McGivern 3f71c43e88 Allow setting content for resolutions
When reading conflicts:

1. Add a `type` field. `text` works as before, and has `sections`;
   `text-editor` is a file with ambiguous conflict markers that can only
   be resolved in an editor.
2. Add a `content_path` field pointing to a JSON representation of the
   file's content for a single file.
3. Hitting `content_path` returns a similar datastructure to the `file`,
   but without the `content_path` and `sections` fields, and with a
   `content` field containing the full contents of the file (with
   conflict markers).

When writing conflicts:

1. Instead of `sections` being at the top level, they are now in a
   `files` array. This matches the read format better.
2. The `files` array contains file hashes, each of which must contain:
   a. `new_path`
   b. `old_path`
   c. EITHER `sections` (which works as before) or `content` (with the
      full content of the resolved file).
2016-10-13 14:16:34 -05:00
Paco Guzman ca3c0c6cd9 MergeRequest new form load diff asynchronously 2016-10-06 11:19:14 +02:00
Felipe Artur 45bfadbcbf Fix bug when trying to cache closed issues from external issue trackers 2016-10-03 19:58:49 -03:00
Thomas Balthazar ddbe676dc3 Add a /wip slash command
It toggles the 'WIP' prefix in the MR title.
2016-10-03 09:36:21 +02:00
Robert Speicher b007bd8101 Improve how MergeCommit#merge_commit_message builds the message
Now a merge request with a blank description will no longer produce a
merge commit message like this:

```
Merge branch 'foo' into 'master'

Bring the wonders of foo into the world

See merge request !7283
```

What an improvement! 🎉
2016-09-27 14:04:41 +02:00
Rémy Coutable 529b17d11c Merge branch 'show-all-pipelines-from-all-diffs' into 'master'
Show all pipelines from all merge_request_diffs

This way we could also show pipelines from commits which
were discarded due to a force push.

Closes #21889

See merge request !6414
2016-09-21 13:15:41 +00:00
Kamil Trzcinski 955b9347a4 Add tests to verify the correctness of returned environments 2016-09-21 12:08:11 +02:00
Kamil Trzcinski d891051cd2 Limit number of shown environments for Merge Requests
- For target project show only environments for target branch or with tags
- For source project show only environments for source branch
2016-09-21 10:23:16 +02:00
Timothy Andrew 68e1b5bbc0 Use the `IssuableBaseService` lifecycle hooks to cache `MergeRequestsClosingIssues`
- Instead of overriding `create` and `update` in `MergeRequests::BaseService`
- Get all merge request service specs passing
2016-09-21 01:22:20 +05:30
Timothy Andrew 918e589c2b Implement a second round of review comments from @DouweM.
- Don't use `TableReferences` - using `.arel_table` is shorter!
- Move some database-related code to `Gitlab::Database`
- Remove the `MergeRequest#issues_closed` and
  `Issue#closed_by_merge_requests`  associations. They were either
  shadowing or were too similar to existing methods. They are not being
  used anywhere, so it's better to remove them to reduce confusion.
- Use Rails 3-style validations
- Index for `MergeRequest::Metrics#first_deployed_to_production_at`
- Only include `CycleAnalyticsHelpers::TestGeneration` for specs that
  need it.
- Other minor refactorings.
2016-09-21 00:47:37 +05:30
Timothy Andrew 71d4bf721b Implement (some) comments from @DouweM's review.
- Move things common to `Issue` and `MergeRequest` into `Issuable`
- Move more database-specific functions into `Gitlab::Database`
- Indentation changes and other minor refactorings.
2016-09-20 18:13:11 +05:30
Lin Jen-Shin 3ae99b2c9f If merge request wasn't persisted yet, we show only 1 pipeline:
However, if MergeRequest#all_commits_sha would want to handle
non-persisted merge request, by judging its name, it should not
just give 1 SHA, but all of them.

But we don't really care all_commits_sha for non-persisted merge
request anyway. So I think we should just ignore that case.

Better to not implementing something than implementing it in a
wrong and confusing way.
2016-09-20 20:29:07 +08:00
Timothy Andrew e109166db2 Fix spec failures. 2016-09-20 16:53:12 +05:30
Lin Jen-Shin f2eb10c9bc slightly tweak about the comment, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6414#note_15750250
2016-09-20 19:18:48 +08:00
Timothy Andrew 8957293d9b Implement review comments from @yorickpeterse
1. Change multiple updates to a single `update_all`

2. Use cascading deletes

3. Extract an average function for the database median.

4. Move database median to `lib/gitlab/database`

5. Use `delete_all` instead of `destroy_all`

6. Minor refactoring
2016-09-20 16:05:25 +05:30
Lin Jen-Shin 307be4b521 Introduce MergeRequest#all_commits_sha, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6414#note_15746083
2016-09-20 17:36:21 +08:00
Timothy Andrew fa890604aa Merge remote-tracking branch 'origin/master' into 21170-cycle-analytics 2016-09-20 14:48:13 +05:30
Lin Jen-Shin e0f596c99d Show all pipelines from all merge_request_diffs:
This way we could also show pipelines from commits which
were discarded due to a force push.
2016-09-19 23:51:27 +08:00
Timothy Andrew 8f6208513a Test all cycle analytics pre-calculation code.
All the code that pre-calculates metrics for use in the cycle analytics
page.

- Ci::Pipeline -> build start/finish
- Ci::Pipeline#merge_requests
- Issue -> record default metrics after save
- MergeRequest -> record default metrics after save
- Deployment -> Update "first_deployed_to_production_at" for MR metrics
- Git Push -> Update "first commit mention" for issue metrics
- Merge request create/update/refresh -> Update "merge requests closing issues"
2016-09-19 13:12:06 +05:30
Rémy Coutable 73269b587c
MergeRequest#environments now returns an empty array when diff_head_commit is nil
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-09-16 10:16:21 +02:00
Timothy Andrew ba25e2f1ac Improve performance of the cycle analytics page.
1. These changes bring down page load time for 100 issues from more than
   a minute to about 1.5 seconds.

2. This entire commit is composed of these types of performance
   enhancements:

     - Cache relevant data in `IssueMetrics` wherever possible.
     - Cache relevant data in `MergeRequestMetrics` wherever possible.
     - Preload metrics

3. Given these improvements, we now only need to make 4 SQL calls:

    - Load all issues
    - Load all merge requests
    - Load all metrics for the issues
    - Load all metrics for the merge requests

4. A list of all the data points that are now being pre-calculated:

    a. The first time an issue is mentioned in a commit

      - In `GitPushService`, find all issues mentioned by the given commit
        using `ReferenceExtractor`. Set the `first_mentioned_in_commit_at`
        flag for each of them.

      - There seems to be a (pre-existing) bug here - files (and
        therefore commits) created using the Web CI don't have
        cross-references created, and issues are not closed even when
        the commit title is "Fixes #xx".

    b. The first time a merge request is deployed to production

      When a `Deployment` is created, find all merge requests that
      were merged in before the deployment, and set the
      `first_deployed_to_production_at` flag for each of them.

    c. The start / end time for a merge request pipeline

      Hook into the `Pipeline` state machine. When the `status` moves to
      `running`, find the merge requests whose tip commit matches the
      pipeline, and record the `latest_build_started_at` time for each
      of them. When the `status` moves to `success`, record the
      `latest_build_finished_at` time.

    d. The merge requests that close an issue

      - This was a big cause of the performance problems we were having
        with Cycle Analytics. We need to use `ReferenceExtractor` to make
        this calculation, which is slow when we have to run it on a large
        number of merge requests.

      - When a merge request is created, updated, or refreshed, find the
        issues it closes, and create an instance of
        `MergeRequestsClosingIssues`, which acts as a join model between
        merge requests and issues.

      - If a `MergeRequestsClosingIssues` instance links a merge request
        and an issue, that issue closes that merge request.

5. The `Queries` module was changed into a class, so we can cache the
   results of `issues` and `merge_requests_closing_issues` across
   various cycle analytics stages.

6. The code added in this commit is untested. Tests will be added in the
   next commit.
2016-09-15 14:53:02 +05:30
Katarzyna Kobierska 66e92895e3 Change method name to #reopenable? 2016-09-13 14:40:05 +02:00
Katarzyna Kobierska 34c146a17d Add #can_reopen? and tests 2016-09-13 14:40:05 +02:00
Katarzyna Kobierska 554baec9e8 Add method 2016-09-13 14:40:05 +02:00
Katarzyna Kobierska 31c37c6c38 Add #closed_without_source_project? 2016-09-13 14:40:05 +02:00
Katarzyna Kobierska 09cded29d8 Checks if deleting forked project closed all open merge requests 2016-09-13 14:40:05 +02:00
Timothy Andrew f5b9837c19 Merge remote-tracking branch 'origin/master' into 21170-cycle-analytics 2016-09-07 14:58:01 +05:30
Robert Speicher e71cd7a300 Merge branch 'refactor/add-policies' into 'master'
Refactor ability.rb into Policies

## What does this MR do?
Factors out `ability.rb` into a new abstraction - the "policy" (stored in `app/policies`). A policy is a class named `#{class_name}Policy` (looked up automatically as needed) that implements `rules` as follows:

``` ruby
class ThingPolicy < BasePolicy
  def rules
    @user # this is a user to determine abilities for, optionally nil in the anonymous case
    @subject # this is the subject of the ability, guaranteed to be an instance of `Thing`
    can! :some_ability # grant the :some_ability permission
    cannot! :some_ability # ensure that :some_ability is not allowed. this overrides any `can!` that is called before or after
    delegate! @subject.other_thing # merge the abilities (can!) and prohibitions (cannot!) from `@subject.other_thing`
    can? :some_ability # test whether, so far, :some_ability is allowed
  end

  def anonymous_rules
    # optional. if not implemented `rules` is called where `@user` is nil. otherwise this method is called when `@user` is nil.
  end
end
```

See merge request !5796
2016-08-31 20:53:40 +00:00
Douwe Maan a181d67554 Merge branch 'remove-fishy-smell' into 'master'
Allow setting branch refs for MR

@dbalexandre can you take a look please?

See merge request !6025
2016-08-31 14:43:46 +00:00
http://jneen.net/ 5853c96b49 remove Ability.abilities 2016-08-30 11:35:06 -07:00
Douwe Maan 51087cfa1a Merge branch 'artifacts-from-ref-and-build-name' into 'master'
Add a download buttons for Build Artifacts

## What does this MR do?
This MR adds a download buttons for build artifacts of latest succesful pipeline in:
- dashboard of project,
- branches and tags views,
- and tree viewer

Implement #4255

## What are the relevant issue numbers?

Closes #4255, Closes #14419

## Screenshots

### Project main

![](/uploads/29ee2154a214416059a875f2715d4fa3/Screen_Shot_2016-08-24_at_8.00.31_PM.png)

### Branches

![](/uploads/9220c593288370986fbc1d42a1425ef7/Screen_Shot_2016-08-24_at_8.02.01_PM.png)

### Tags

![](/uploads/a843e8103221fea475a0cf9d62a1999d/Screen_Shot_2016-08-24_at_8.03.32_PM.png)

### Source Tree

![](/uploads/63cd3c8c91b6f427c166dc90d8e3c059/Screen_Shot_2016-08-24_at_8.04.56_PM.png)

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] Download buttons
- [x] Models
- [x] Routes
- [x] Projects::ArtifactsController
- [x] API
- Tests
  - Rails
      - [x] Project#builds_for
      - [x] branch name with slashes
      - [x] only success builds
      - [x] only latest builds
      - [x] feature tests for download buttons
  - API
      - [x] branch name with slashes
      - [x] only success builds
      - [x] only latest builds
  - [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 !5142
2016-08-30 18:03:16 +00:00
Katarzyna Kobierska 2d8d94a788 Change method name 2016-08-30 13:31:39 +02:00
Katarzyna Kobierska 7226631102 Improve grammar and fix CHANGELOG 2016-08-30 13:05:40 +02:00
Katarzyna Kobierska c9c2503c51 User can edit closed MR with deleted fork
Add test for closed MR without fork

Add view test visibility of Reopen and Close buttons

Fix controller tests and validation method

Fix missing space

Remove unused variables from test

closed_without_fork? method refactoring

Add information about missing fork

When closed MR without fork can't edit target branch

Tests for closed MR edit view

Fix indentation and rebase, refactoring
2016-08-30 13:05:40 +02:00
Timothy Andrew 487906b386 Add the "Code" Cycle Analytics section.
1. Record the `wip_flag_first_removed_at` and
   `first_assigned_to_user_other_than_author` metrics for a merge
   request. Use a `merge_request_metrics` table, similar to the one for
   `issues`. Metrics are recorded `after_save`.

2. Move larger queries to a `CycleAnalytics::Queries` module.
2016-08-26 16:28:20 +05:30
Lin Jen-Shin de80cbfe3f Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name
* upstream/master: (107 commits)
  Fix external issue tracker "Issues" link leading to 404s
  Fix CHANGELOG entries related to 8.11 release.
  Fix changelog
  Reduce contributions calendar data payload
  Add lock_version to merge_requests table
  Add hover color to emoji icon
  Fix wrong Koding link
  Capitalize mentioned issue timeline notes
  Fix groups sort dropdown alignment
  Use icon helper
  Fix inline emoji text alignment
  Adds response mime type to transaction metric action when it's not HTML
  Moved two 8.11 changelog entries to 8.12
  Fix markdown link in doc_styleguide.md
  Display project icon from default branch
  Reduce number of database queries on builds tab
  Update CHANGELOG
  Update Issue board documentation
  Label list shows all issues (opened or closed) with that label
  Update CHANGELOG
  ...
2016-08-26 17:31:12 +08:00
Douwe Maan 2933f3f597 Merge branch '21275-getting-500-error-when-viewing-a-merge-request' 2016-08-25 14:05:05 -05:00
Sean McGivern 79fd779530 Allow setting branch refs for MR 2016-08-25 13:46:59 +01:00
Sean McGivern 67beaf6fb9 Don't show conflicts when there are none 2016-08-25 12:47:12 +01:00
Sean McGivern 4a3d1a5838 Handle case where conflicts aren't on disk yet 2016-08-25 12:34:54 +01:00
Dmitriy Zaporozhets eb355dec87
Restore diff_sha_refs method
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-22 14:18:58 +03:00
Dmitriy Zaporozhets 6db65143db
Merge branch 'master' into dz-merge-request-version
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-19 13:01:58 +03:00
Lin Jen-Shin 9c9259cc6a Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name
* upstream/master: (195 commits)
  Fix expansion of discussions in diff
  Improve performance of MR show page
  Fix jumping between discussions on changes tab
  Update doorkeeper to 4.2.0
  Fix MR note discussion ID
  Handle legacy sort order values
  Refactor `find_for_git_client` and its related methods.
  Remove right margin on Jump button icon
  Fix bug causing “Jump to discussion” button not to show
  Small refactor and syntax fixes.
  Removed unnecessary service for user retrieval and improved API error message.
  Added documentation and CHANGELOG item
  Added checks for 2FA to the API `/sessions` endpoint and the Resource Owner Password Credentials flow.
  Fix behavior around commands with optional arguments
  Fix behavior of label_ids and add/remove_label_ids
  Remove unneeded aliases
  Do not expose projects on deployments
  Incorporate feedback
  Docs for API endpoints
  Expose project for environments
  ...
2016-08-19 17:41:53 +08:00
Douwe Maan 6a355d451e Improve performance of MR show page 2016-08-18 19:08:59 -05:00
Lin Jen-Shin 62127dc95a Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name
* upstream/master: (359 commits)
  Add new image to show the 'Reset template' button
  Refactor description templates documentation
  Remove index from pipeline toggles
  Hide `Create new list button` on Issues and MRs pages
  Remove params from build; general refactor
  Style build container box; add check mark to active build
  Display jobs as scrolling list in sidebar
  Move stages and jobs to build sidebar
  Removed vue assets
  Move skipped tests to end of array
  Remove unused data attributes
  Update changelog
  Style build dropdowns
  Populate dropdowns with current build on pageload
  Selecting stage updates builds dropdown
  Add data attributes to builds
  Change active state of list items; style dropdown items
  Hide dropdown if all tests fit on one line; add counter to dropdown
  Add overflow tests to dropdown
  Order by build status
  ...
2016-08-18 19:34:10 +08:00
Connor Shea d8654744cd
Merge branch 'master' into diff-line-comment-vuejs 2016-08-17 12:10:09 -06:00
Douwe Maan 095fcfc447 Merge branch 'mc-ui'
# Conflicts:
#	app/controllers/projects/merge_requests_controller.rb
2016-08-17 12:21:30 -05:00
Douwe Maan 4a13aa9f34 Store discussion_id on Note for faster discussion lookup. 2016-08-17 12:16:46 -05:00
Connor Shea 1d3aa59f99
Merge branch 'master' into diff-line-comment-vuejs 2016-08-16 16:59:19 -06:00
Kamil Trzcinski a2bf638e40 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into 18681-pipelines-merge-request 2016-08-16 15:51:41 +02:00
Lin Jen-Shin 11f840bfa5 An empty line after guard, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_13904931
2016-08-16 21:04:06 +08:00
Douwe Maan 1ba2ef4fda Merge branch 'master' into mc-ui 2016-08-15 17:20:56 -05:00
Lin Jen-Shin 567ef6c175 Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name
* upstream/master: (123 commits)
  Limit the size of SVGs when viewing them as blobs
  Add a spec for ProjectsFinder project_ids_relation option
  Fix ProjectsFinder spec
  Pass project IDs relation to ProjectsFinder instead of using a block
  Speed up todos queries by limiting the projects set we join with
  Used phantomjs variable
  Ability to specify branches for pivotal tracker integration
  Fix a memory leak caused by Banzai::Filter::SanitizationFilter
  Update phantomjs link
  Remove sleeping and replace escaped text.
  Filters test fix
  Fixed filtering tests
  Removed screenshot command 💩
  Updated failing tests
  Used mirrored version on GitLab
  Updated tests
  Fix `U2fSpec` for PhantomJS versions > 2.
  Fix file downloading
  Install latest stable phantomjs
  Use new PhantomJS version
  ...
2016-08-16 00:14:26 +08:00
Douwe Maan 06e3bb9f23 Merge branch 'zj-deployment-status-on-mr' into 'master'
Show deployment status on a MR view

## What are the relevant issue numbers?

Resolves #19571, one in the list of #19992

## Screenshots (if relevant)

external_url = nil
![Screen_Shot_2016-08-02_at_13.57.03](/uploads/20ea1587eea556c7a1acd0ff726a5bfb/Screen_Shot_2016-08-02_at_13.57.03.png)

external_url != nil
![Screen_Shot_2016-08-02_at_13.59.59](/uploads/0094b9ddece3f4bf76c83988840c096d/Screen_Shot_2016-08-02_at_13.59.59.png)

Note, the timings are weird between merging and deploying, that is because I did it in the wrong order.

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

See merge request !5622
2016-08-15 15:29:26 +00:00
Dmitriy Zaporozhets 49d63dc131
Fix and refactor merge request diff_refs method
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-15 18:11:18 +03:00
Dmitriy Zaporozhets 643a368fa4
Make merge request diff works with new FileCollection logic
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-15 17:57:19 +03:00
Dmitriy Zaporozhets 5e95c0b8d2
Merge branch 'master' into dz-merge-request-version
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-15 17:27:22 +03:00
Dmitriy Zaporozhets 29ac60d7fb
Change the way old merge request diff handled
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-15 15:20:36 +03:00
Douwe Maan c770201061 Merge branch 'master' into diff-line-comment-vuejs 2016-08-12 17:23:19 -05:00
Douwe Maan e257200459 Add specs for NotesController and DiscussionsController 2016-08-12 16:24:09 -05:00
Douwe Maan 9eca67c950 Verify user is signed in and can actually resolve conflicts 2016-08-12 23:24:50 +03:00
Douwe Maan cf4cbb018e Rename `can_resolve_conflicts_in_ui?` to `conflicts_can_be_resolved_in_ui?` 2016-08-12 23:24:50 +03:00
Sean McGivern 427e724698 Don't allow resolving invalid conflicts
An MR can only be resolved in the UI if:
- It has conflicts.
- It has valid diff_refs (in other words, it supports new diff notes).
- It has no conflicts with one side missing.
- It has no conflicts in binary files.
- It has no conflicts in files too large to display.
- It has no conflicts containing invalid conflict markers.
2016-08-12 23:24:48 +03:00
Sean McGivern 28ef06c52b Fix merge conflict reading for new diffs 2016-08-12 23:24:43 +03:00
Kamil Trzcinski cae0fa7cba Properly select a list of Pipelines for a Merge Requests 2016-08-12 16:22:48 +02:00
Z.J. van de Weg 07fc2f852a Method names changed to #includes_commit? 2016-08-12 10:43:04 +02:00
Z.J. van de Weg b497b0ce3f Incorporate feedback 2016-08-11 21:29:57 +02:00
Z.J. van de Weg 49f72e705f Show deployment status on a MR view 2016-08-11 21:29:57 +02:00
Scott Le 6109daf480 api for generating new merge request
DRY code + fix rubocop

Add more test cases

Append to changelog

DRY changes list

find_url service for merge_requests

use GET for getting merge request links

remove files

rename to get_url_service

reduce loop

add test case for cross project

refactor tiny thing

update changelog
2016-08-11 23:37:00 +07:00
Lin Jen-Shin 4b559c9afb Reverse ref and sha in args and rename pipeline to pipeline_for 2016-08-11 17:26:04 +08:00
Dmitriy Zaporozhets d99d5198c2
Add MergeRequest#branch_merge_base_commit method
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-08 23:00:11 +03:00
Douwe Maan 538e66d71c Merge branch 'master' into diff-line-comment-vuejs
# Conflicts:
#	app/models/discussion.rb
#	db/schema.rb
2016-08-03 15:32:00 -07:00
Paco Guzman 631f59d4e7 change the API on the merge_request_diff model from diffs -> raw_diffs 2016-08-03 23:32:12 +02:00
Douwe Maan c008a1a967 Make Compare#diffs diff_options a regular argument 2016-08-03 09:32:01 -07:00
Paco Guzman c86c1905b5 switch from diff_file_collection to diffs
So we have raw_diffs too
2016-08-03 07:00:20 +02:00
Paco Guzman 1d0c7b7492 Introduce Compare model in the codebase.
This object will manage Gitlab::Git::Compare instances
2016-08-03 07:00:20 +02:00
Paco Guzman 8f359ea917 Move to Gitlab::Diff::FileCollection
Instead calling diff_collection.count use diff_collection.size which is cache on the diff_collection
2016-08-03 07:00:20 +02:00
Paco Guzman cd7c2cb6dd Cache highlighted diff lines for merge requests
Introducing the concept of SafeDiffs which relates 
diffs with UI highlighting.
2016-08-03 07:00:19 +02:00
Dmitriy Zaporozhets fc8d2fbc94
Build diff_refs for merge request if merge request diff does not exist
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 17:52:20 +03:00
Paco Guzman 8716ff7f63 Speedup DiffNote#active? on discussions, preloading noteables and avoid touching git repository to return diff_refs when possible
- Preloading noteable we share the same noteable instance when more than one 
discussion refers to the same noteable.
- Any other call to that object that is cached in that object will be for any 
discussion.
- In those cases where merge_request_diff has all the sha stored to build a diff_refs get that 
diff_refs using directly those sha instead accessing to the git repository to first get the 
commits and later the sha.
2016-08-02 16:04:15 +02:00
Dmitriy Zaporozhets 7cb8ceb5b9
Fix creation and reload of the merge request diff
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 16:28:37 +03:00
Dmitriy Zaporozhets 6515ec09bb
Chnage the way how merge request diff is initialized and saved
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 15:38:03 +03:00
Dmitriy Zaporozhets f8aeb8cdac Change merge request diff creation from callback to part of the service
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 13:31:19 +03:00
Dmitriy Zaporozhets 3c1dca0301 Add more tests to merge_request_diff and improve initialize
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 13:31:19 +03:00
Dmitriy Zaporozhets b0a023842d Reload merge request association reload when update code
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 13:31:19 +03:00
Dmitriy Zaporozhets 964742f600 Ensure merge request is created with valid diff object
* Add merge_request_diff validation to merge_request model
* Improve initialize of merge_request_diff object
* Rename some merge_request_diff methods for clarity

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 13:31:19 +03:00
Dmitriy Zaporozhets 94ca25c9b8 Improve merge request diff creation and update tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 13:31:19 +03:00
Dmitriy Zaporozhets ceff810643 Create merge request diff on merge request creation
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 13:31:19 +03:00
Dmitriy Zaporozhets 2afcc9e910 Create new version of merge request diff on push instead of updating existing one
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-08-02 13:31:19 +03:00
Douglas Barbosa Alexandre 285ba1b20f fixup! Fix attr reader to force the intended values for source and target shas 2016-07-31 19:45:30 -03:00
Douglas Barbosa Alexandre 5b4ceeed63 Fix attr reader to force the intended values for source and target shas
When importing a pull request from GitHub, the old and new branches may
no longer actually exist by those names, but we need to recreate the
merge request diff with the right source and target shas.

We use these `target_branch_sha` and `source_branch_sha` attributes to
force these to the intended values. But the reader methods were always
looking up to the target/source branch head instead of check if these
values was previously set.
2016-07-31 19:45:30 -03:00
Douwe Maan d9a949c17c Use correct user for 'Discussion resolved by...' 2016-07-28 21:14:45 -06:00
Douwe Maan fa4a613517 Add 'Resolved all discussions' system note 2016-07-28 20:39:35 -06:00
Douwe Maan eeb41c759e Add endpoints to resolve diff notes and discussions 2016-07-25 22:45:23 -06:00
Rémy Coutable 2cf7f09b1e
Revert "Revert "Merge branch '18193-developers-can-merge' into 'master' ""
This reverts commit 530f5158e2.

See !4892.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-07-18 10:16:56 +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
Timothy Andrew af7e75162e Don't ask the user to "merge this request manually".
1. If they are a developer with "Developers can Merge" switched on.
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
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
Sean McGivern 79a47582e8 Merge branch 'master' into single-file-diffs 2016-07-11 09:38:11 +01:00
Paco Guzman 52a89f2022 Memoize MR merged/closed events retrieval 2016-07-08 12:35:42 +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
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 710c488691 Automatically update diff note positions when MR is pushed to 2016-07-06 18:51:00 -04:00
Douwe Maan 8d7dc26d39 Support new diff notes on MRs with diff_refs 2016-07-06 18:51:00 -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
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 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
Douwe Maan 3286dd7a1d Don't garbage collect commits that have related DB records like comments 2016-07-04 00:11:33 -04:00
James Lopez f29c30475e use has_many relationship with events 2016-07-01 15:34:10 +02:00
James Lopez 3d2a736679 fixing events for import/export 2016-06-29 10:35:26 +02:00
Z.J. van de Weg c31f876a27 Workhorse to serve email diffs
Depends on the changes in Workhorse (gitlab-org/gitlab-workhorse!48).
2016-06-28 14:26:38 +02:00
Rémy Coutable e3d464d82a
Fix a wrong MR status when merge_when_build_succeeds & project.only_allow_merge_if_build_succeeds are true
The issue was that `MergeRequest#mergeable?` returns false when the CI
state is not success and project.only_allow_merge_if_build_succeeds is
true. In this case `Projects::MergeRequestsController#merge` would
return the `:failed` status when enabling `merge_when_build_succeeds`,
thus leading to a weird state and the MR never automatically merged.

The fix is to disable the CI state check in the controller safeguard
that early return the `:failed` status.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-24 18:33:02 +02:00
Stan Hu 7c9eba8919 Fix RangeError exceptions when referring to issues or merge requests outside of max database values
When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we
get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method
that will throw out out-of-bounds values.

Closes #18777
2016-06-18 13:07:38 -07:00
James Lopez ad68bc63b5 Merge branches 'feature/project-export' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import
# Conflicts:
#	app/models/project.rb
#	db/schema.rb
#	lib/gitlab/import_export/import_export_reader.rb
2016-06-13 12:43:25 +02:00
Rémy Coutable a1db70770e Remove unused MergeRequest#gitlab_merge_status method
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-10 18:42:03 +02:00
Rémy Coutable 3579edba1f
Rename ci_commit -> pipeline
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-10 14:41:38 +02:00
Rémy Coutable 5324c93643 Rename MergeRequest#cannot_be_merged_because_build_is_not_success? to #mergeable_ci_state?
The logic of the method was obviously inverted.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-10 14:37:32 +02:00
Rémy Coutable 6dff7c1771 Improve initial implementation of the 'only_allow_merge_if_build_succeeds.rb' feature
Based on the feedback from reviewers.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-10 14:36:57 +02:00
Rui Anderson 07dbd6b388 Allow or not merge MR with failed build
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-10 14:36:54 +02:00
Jacob Vosmaer (GitLab) afa21054fa Merge branch 'zj-workhorse-to-serve-diffs' into 'master'
Workhorse to serve raw diffs

Fixes (partially) #13999

Dependent on: gitlab-org/gitlab-workhorse!45

See merge request !4130
2016-06-07 12:50:29 +00:00
Zeger-Jan van de Weg 01e1139f68 Workhorse to serve raw diffs 2016-06-03 18:43:22 +02:00
Kamil Trzcinski 021d3810c3 Rename Ci::Commit to Ci::Pipeline and rename some of the ci_commit to pipeline 2016-06-02 16:59:04 +02:00
James Lopez 7c8359b744 started refactoring some stuff based on MR feedback 2016-06-01 18:03:51 +02:00
Jeroen Jacobs 7880a300dc Allows MR authors to have the source branch removed when merging the MR 2016-05-20 11:30:03 +02:00
Douglas Barbosa Alexandre 7e1f14e215 Preserve commits/diff/comments for PRs that were merged on GitHub 2016-05-13 17:55:42 -05:00
Robert Speicher 4735a75340 Merge branch 'deprecated-class-methods-cop' into 'master'
Enable the Rubocop DeprecatedClassMethods cop

This reports uses of `File.exists?` and `Dir.exists?`, which were both
deprecated in Ruby and will eventually be removed in favor of `.exist?`.
Also fixes all existing uses of the deprecated methods.

See merge request !4087
2016-05-12 22:41:01 +00:00
James Lopez 47cd14b560 Merge branch 'feature/project-export' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import 2016-05-09 18:01:06 +02:00
Jeroen van Baarsen f1479b56b7
Remove the annotate gem and delete old annotations
In 8278b763d9 the default behaviour of annotation
has changes, which was causing a lot of noise in diffs. We decided in #17382
that it is better to get rid of the whole annotate gem, and instead let people
look at schema.rb for the columns in a table.

Fixes: #17382
2016-05-09 18:00:28 +02:00
Connor Shea 9cc0937b3a Enable the Rubocop DeprecatedClassMethods cop
This reports uses of `File.exists?` and `Dir.exists?`, which were both
deprecated in Ruby and will eventually be removed in favor of
`.exist?`. Also fixes all existing uses of the deprecated methods.
2016-05-08 15:33:34 -06:00
Zeger-Jan van de Weg 47da013cf8 Annotate the models 2016-05-06 08:27:46 +02:00
James Lopez 7614d230a2 fix conflicts 2016-04-21 17:28:56 +02:00
Kamil Trzciński d240666800 Merge branch 'ci-commit-as-pipeline' into 'master'
Ci::Commit becomes a Pipeline object

1. Ci::Commit receives context: ref, :tag.
1. One Ci::Commit describes a one Pipeline
1. Pipeline is created from `.gitlab-ci.yml`
1. Pipeline is a ordered group of builds
1. We test MR against Pipeline
1. Pipelines have a separate view (https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3703)
1. Pipeline can be triggered from UI (https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3703)
1. Later we change `Trigger -> TriggerRequest -> Build` to `Trigger -> Pipeline` (future)
1. We add a Pipeline Hook that will be triggered on Pipeline status change  (future)
1. We extend notifications to use `Pipeline Hook` to send summary on pipeline changes (future)

After merging that I'll prepare a separate MR that will unify naming, database columns, table names:
```
Ci::Commit -> Pipeline
Ci::Build -> Build
CommitStatus -> Job
GenericCommitStatus -> ExternalJob

ci_commits -> pipelines
ci_builds -> jobs
```

This MR implements first 5 points.

This is made to solve this issue https://gitlab.com/gitlab-org/gitlab-ce/issues/14149.

See merge request !3653
2016-04-21 08:10:37 +00:00
Douwe Maan d00e5455ee Verify the MR being displayed question has a merge commit set and can be cherry-picked 2016-04-20 14:28:19 +02:00
Rémy Coutable 6970612bcc
Get rid of more requires, which causes warnings when code is reloaded
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-04-19 11:48:10 +02:00
Kamil Trzcinski 4af0968c43 Merge remote-tracking branch 'origin/master' into ci-commit-as-pipeline 2016-04-13 15:47:18 +02:00
Felipe Artur a64f1c7636 Add changelog entry, improve specs and model code 2016-04-12 15:52:03 -03:00
Felipe Artur 476cf23fc3 Allow to close invalid merge request 2016-04-11 19:00:59 -03:00
Kamil Trzcinski 5d69f5b46d Use Ci::Commit as Pipeline 2016-04-11 23:32:54 +02:00
James Lopez d29c816dfe Merge branch 'feature/project-export' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import 2016-04-08 16:04:59 +02:00
Douwe Maan f505c753b0 Merge branch 'fix_remove_fork_link' into 'master'
Remove fork link closes all merge requests opened on source project

Currently, if you:

- create a fork
- open a merge request on the source project
- remove the fork link

The created MR cannot be closed.

With this MR, all pending MR is closed when the fork link is removed.

See merge request !3189
2016-04-04 15:37:08 +00:00
Yorick Peterse e7849b0b25 Memoize reference_pattern/link_reference_pattern
These methods are called quite often in loops so by memoizing their
output we can reduce timings a bit.
2016-04-01 11:13:30 +02:00
Gabriel Mazetto 11865ee267 We need `sha` reference from `diff_base_commit` to generate the diff 2016-03-29 23:59:51 -03:00