summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-08-09 17:51:31 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-08-09 17:51:31 +0000
commite09ef2fc38adf76a8986ab3078fe92831bf56836 (patch)
tree10435d41c8dbc8798cb0e18b96372b063b75bebc /lib
parentc0e1312567dc09aea0aecd72a3fa777c31b85b50 (diff)
parenta0755d2f051c5a9cd31721333adee22cb40b1008 (diff)
downloadgitlab-ce-e09ef2fc38adf76a8986ab3078fe92831bf56836.tar.gz
Merge branch 'improve-test-env' into 'master'
Improve test env * Replace big gitlabhq repo with small one (https://gitlab.com/gitlab-org/gitlab-test) * dont stub gitlab-shell calls Advantages: * test gitlab-shell install during tests * test integration with gitlab-shell features (fork, change default branch etc) * don't store archive with test repo inside gitlab * less stubs - easier to write/read tests During this refactoring __next issues are be fixed__: * satellite error if gitlab_shell path is relative * project rename repo -> 500 error * fixed wrong diff for MR `download plain diff` * fixed bug when gfm ignores `@ref` variable during link parsing Fixes #1451 See merge request !1005
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/satellite/merge_action.rb15
-rw-r--r--lib/tasks/gitlab/shell.rake3
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/gitlab/satellite/merge_action.rb b/lib/gitlab/satellite/merge_action.rb
index 6c32dfb3ad9..7c9b2294647 100644
--- a/lib/gitlab/satellite/merge_action.rb
+++ b/lib/gitlab/satellite/merge_action.rb
@@ -45,27 +45,30 @@ module Gitlab
handle_exception(ex)
end
- # Get a raw diff of the source to the target
def diff_in_satellite
in_locked_and_timed_satellite do |merge_repo|
prepare_satellite!(merge_repo)
update_satellite_source_and_target!(merge_repo)
- diff = merge_repo.git.native(:diff, default_options, "origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}")
+
+ # Only show what is new in the source branch compared to the target branch, not the other way around.
+ # The line below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
+ # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
+ common_commit = merge_repo.git.native(:merge_base, default_options, ["origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}"]).strip
+ merge_repo.git.native(:diff, default_options, common_commit, "source/#{merge_request.source_branch}")
end
rescue Grit::Git::CommandFailed => ex
handle_exception(ex)
end
- # Only show what is new in the source branch compared to the target branch, not the other way around.
- # The line below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
- # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
def diffs_between_satellite
in_locked_and_timed_satellite do |merge_repo|
prepare_satellite!(merge_repo)
update_satellite_source_and_target!(merge_repo)
if merge_request.for_fork?
+ # Only show what is new in the source branch compared to the target branch, not the other way around.
+ # The line below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
+ # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
common_commit = merge_repo.git.native(:merge_base, default_options, ["origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}"]).strip
- #this method doesn't take default options
diffs = merge_repo.diff(common_commit, "source/#{merge_request.source_branch}")
else
raise "Attempt to determine diffs between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]"
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
index dfc90bb3339..ff27e6a3066 100644
--- a/lib/tasks/gitlab/shell.rake
+++ b/lib/tasks/gitlab/shell.rake
@@ -4,7 +4,8 @@ namespace :gitlab do
task :install, [:tag, :repo] => :environment do |t, args|
warn_user_is_not_gitlab
- args.with_defaults(tag: "v1.9.3", repo: "https://gitlab.com/gitlab-org/gitlab-shell.git")
+ default_version = File.read(File.join(Rails.root, "GITLAB_SHELL_VERSION")).strip
+ args.with_defaults(tag: 'v' + default_version, repo: "https://gitlab.com/gitlab-org/gitlab-shell.git")
user = Settings.gitlab.user
home_dir = Settings.gitlab.user_home