Commit Graph

124 Commits

Author SHA1 Message Date
Z.J. van de Weg 03ea019465 CI build status not per environment 2016-08-11 21:29:58 +02:00
Z.J. van de Weg b497b0ce3f Incorporate feedback 2016-08-11 21:29:57 +02:00
tiagonbotelho 1d268a89de adds second batch of tests changed to active tense 2016-08-09 15:11:39 +01: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 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 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
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
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 5ffb848ee6 Add tests for MergeRequest#reload_diff 2016-07-06 18:51:01 -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
Douwe Maan 3286dd7a1d Don't garbage collect commits that have related DB records like comments 2016-07-04 00:11:33 -04: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
Kamil Trzcinski 20c7144ed2 Rename all `[ci_]commit` to `[ci_]pipeline` in specs and features 2016-06-03 16:22:26 +02:00
Kamil Trzcinski 4d5f7aa008 Fix more places where we should rename ci_commit to pipeline 2016-06-03 14:46:17 +02:00
Kamil Trzcinski 0a51c95464 Merge remote-tracking branch 'origin/master' into rename-ci-commit 2016-06-03 13:10:01 +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
Josh Frye 0f3df62e1a Update specs. Add CHANGELOG entry 2016-06-02 09:25:40 -04:00
Douwe Maan 2d084dd848 Merge branch 'separate-banzai-references' into 'master'
Separate reference gathering from rendering

This is a required step to allow batch processing when gathering references. This in turn would allow grabbing (for example) all mentioned users of an issue/merge request using a single query.

cc @rspeicher @DouweM 

See merge request !3969
2016-06-01 15:51:59 +00:00
Yorick Peterse 580d250166
Refactor Participable
There are several changes to this module:

1. The use of an explicit stack in Participable#participants
2. Proc behaviour has been changed
3. Batch permissions checking

== Explicit Stack

Participable#participants no longer uses recursion to process "self" and
all child objects, instead it uses an Array and processes objects in
breadth-first order. This allows us to for example create a single
Gitlab::ReferenceExtractor instance and pass this to any Procs. Re-using
a ReferenceExtractor removes the need for running potentially many SQL
queries every time a Proc is called on a new object.

== Proc Behaviour Changed

Previously a Proc in Participable was expected to return an Array of
User instances. This has been changed and instead it's now expected that
a Proc modifies the Gitlab::ReferenceExtractor passed to it. The return
value of the Proc is ignored.

== Permissions Checking

The method Participable#participants uses
Ability.users_that_can_read_project to check if the returned users have
access to the project of "self" _without_ running multiple SQL queries
for every user.
2016-06-01 16:22:35 +02:00
Grzegorz Bizon fc57d36018 Minor changes in note validation specs 2016-05-29 15:03:00 -04:00
Grzegorz Bizon e558edd1ce Update specs to carry out changes in note factory 2016-05-29 15:03:00 -04: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
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
Kamil Trzcinski af7214d0f0 Fix specs 2016-04-11 23:32:55 +02:00
Abhi Rao 762d6ab4fd Ensuring Merge Request API returns boolean values for work_in_progress
Fixes #14692
2016-03-28 22:11:44 -05:00
Zeger-Jan van de Weg 212e83bab3 Soft delete issuables 2016-03-19 21:23:03 +01:00
Rémy Coutable cafa408b25 Merge remote-tracking branch 'origin/master' into remove-wip 2016-03-18 23:29:18 +01:00
Rémy Coutable 0b942541da Improve the "easy WIP & un-WIP from link" feature 2016-03-18 23:27:35 +01:00
Rémy Coutable bc92de8f03 Add a safeguard in MergeRequest#compute_diverged_commits_count
We have to ensure source_sha and target_sha are not nil before calling
Gitlab::Git::Commit.between.
2016-03-18 19:01:20 +01:00
Douwe Maan dadd28e317 Merge branch 'fix-mr-source-sha' into 'master'
Fix MergeRequest#source_sha when there is no diff

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

### Overview

This MR fixes an unhandled Exception when visiting the page of an open Merge Request  without diff.

### Description

`MergeRequest#source_sha` is expected to return the sha of the source branch last commit. But when an open Merge Request has no diff (e.g. all commits have already been merged to the target branch), `merge_request.source_sha` incorrectly returns `nil`.

This was without consequences before – but since !2217 was merged (a few days ago), it makes `Gitlab::Git::Commit.between` raise an "Unexpected nil argument" exception. This can be reproduced when visiting the http://localhost:3000/gitlab-org/gitlab-test/merge_requests/2 page on a fresh local Gitlab setup.

This MR fixes the crash, by making sure that `source_sha` returns a
correct result even when there is no diff available. I also added tests.

@DouweM I believe you wrote most of this code in the first place ; does this looks correct to you, or is there a better way to resolve this issue maybe?

See merge request !3135
2016-03-18 12:28:43 +00:00
Douglas Barbosa Alexandre 43d8bdb4f0 Restrict access to references for confidential issues 2016-03-17 20:55:59 -03:00
Pierre de La Morinerie 18295585d9 Fix MergeRequest#source_sha when there is no diff
`MergeRequest#source_sha` is expected to return the sha of the source
branch last commit.

But when a open Merge Request has no diff (e.g. all commits have already
been merged to the target branch), `merge_request.source_sha`
incorrectly returns `nil`.

This was un-noticed before – but now that !2217 has been merged,
it makes `Gitlab::Git::Commit.between` raise an
"Unexpected nil argument" exception.

This fixes the crash, by making sure that `source_sha` returns a
correct result even when there is no diff available.
2016-03-16 14:02:04 +01:00
Pierre de La Morinerie 7cbf8fd0d0 Add tests for MergeRequest#source_sha 2016-03-16 13:56:47 +01:00
Yorick Peterse 4f3fa519c6 Use a UNION in MergeRequest.in_projects
The OR condition for source_project_id/target_project_id leads to a
query plan that performs rather poorly on PostgreSQL due to the use of
sub-queries. Because Rails offers no easy alternative for this
particular problem we're forced to using a UNION for both conditions.
The resulting query performs much faster than just using an OR.
2016-03-11 15:26:32 -05:00
Pierre de La Morinerie 543845f7ef Indicate how much an MR branch diverges from the target branch 2016-03-03 15:11:44 +01:00
Rubén Dávila f56ee9d3b9 Save merge commit id when MR is merged 2016-02-19 13:14:49 -05:00
Kirill Zaitsev b123171d3d Add new data to project in push, issue, merge-request and note webhooks data
- Add `avatar_url`, `description`, `git_ssh_url`, `git_http_url`,
  `path_with_namespace` and `default_branch` in `project` in push, issue,
  merge-request and note webhooks data
- Deprecate the `ssh_url` in favor of `git_ssh_url` and `http_url` in
  favor of `git_http_url` in `project` for push, issue, merge-request and
  note webhooks data
- Deprecate the `repository` key in push, issue, merge-request and
  note webhooks data, use `project` instead
2016-02-11 17:22:11 +01:00
Douwe Maan b5befc734b Merge branch 'disable-remove-source-branch' into 'master'
Hide remove source branch button when new commit is added to branch

Fixes #3339

This MR hides the 'Remove source branch' button when a new commit is added to the source branch

/cc @DouweM

See merge request !2701
2016-02-04 11:56:58 +00:00
Zeger-Jan van de Weg c6e0228ca9 Hide remove source branch button when new commit is added to branch
Fixes #3339

This MR hides the 'Remove source branch' button when a new commit is added to the source branch
2016-02-04 11:56:23 +01:00
Douwe Maan a1fa973123 Merge branch 'wipMergeSpacing' into 'master'
No space required after WIP identifier

Fixes #2426 

Currently, the WIP: (or any other variation) prefix of a merge request title must include a trailing space for it to be recognized as a work in progress and prevent merging. 
To resolve this, I added an or pattern to the regexp to look for any one of the three possible delimiters ':', ']', or ' '. This way the trailing space isn't required but it still won't mark any titles beginning with wip as work in progress (e.g. "Wipwap").

See merge request !1876
2016-02-04 09:49:54 +00:00
Yorick Peterse 99492d6b8d Optimize fetching issues closed by a merge request
Instead of running ClosingIssueExtractor for every commit in a merge
request we can gather all the commit messages (and the merge request
description), concatenate all this together and then run
ClosingIssueExtractor only once.

The result of this is that MergeRequest#closes_issues is now between
3.5x and 4x faster than the old setup. Using a merge request with 10
commits (each referencing a number of issues to close) this reduced the
call duration from around 200 milliseconds to around 50 milliseconds.

As a result of these changes the Jira related tests for
MergeRequest#closes_issues have been removed. These tests stubbed
Commit#closes_issues meaning that the only code that was really tested
was the call to Array#uniq to filter out duplicate issues. As this code
is no longer used (nor present) the corresponding tests were removed.

Related: gitlab-org/gitlab-ce#12419
2016-02-01 11:04:05 +01:00
Ted Hogan f0c2f7481f Removed redundent and incorrect tests on WIP 2016-01-06 10:48:08 -07:00
Stan Hu 79c0e7212a Annotate models 2016-01-06 13:09:55 +00:00
Ted Hogan 9fc6df512b Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into wipMergeSpacing 2015-12-29 11:25:46 -07:00