From a932e28ddd43ad344b81b3894503356e9861e050 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 26 Sep 2014 10:55:39 +0300 Subject: Fix worker error when remove branch Signed-off-by: Dmitriy Zaporozhets --- app/services/git_push_service.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index 6a13778d67c..ac7de00593f 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -22,11 +22,8 @@ class GitPushService project.update_repository_size if push_to_branch?(ref) - if push_to_existing_branch?(ref, oldrev) - # Collect data for this git push - @push_commits = project.repository.commits_between(oldrev, newrev) - project.update_merge_requests(oldrev, newrev, ref, @user) - process_commit_messages(ref) + if push_remove_branch_branch?(ref, newrev) + @push_commits = [] elsif push_to_new_branch?(ref, oldrev) # Re-find the pushed commits. if is_default_branch?(ref) @@ -38,11 +35,12 @@ class GitPushService # that shouldn't matter because we check for existing cross-references later. @push_commits = project.repository.commits_between(project.default_branch, newrev) end - process_commit_messages(ref) - - elsif push_remove_branch_branch?(ref, newrev) - @push_commits = [] + elsif push_to_existing_branch?(ref, oldrev) + # Collect data for this git push + @push_commits = project.repository.commits_between(oldrev, newrev) + project.update_merge_requests(oldrev, newrev, ref, @user) + process_commit_messages(ref) end @push_data = post_receive_data(oldrev, newrev, ref) -- cgit v1.2.1 From 8fae6ad75a5e474d17d504056af606f99183a6fb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 26 Sep 2014 12:45:41 +0300 Subject: Fix typo in push service Signed-off-by: Dmitriy Zaporozhets --- app/services/git_push_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index ac7de00593f..fddfddb92ee 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -22,7 +22,7 @@ class GitPushService project.update_repository_size if push_to_branch?(ref) - if push_remove_branch_branch?(ref, newrev) + if push_remove_branch?(ref, newrev) @push_commits = [] elsif push_to_new_branch?(ref, oldrev) # Re-find the pushed commits. -- cgit v1.2.1 From 9ecd3bc6cebf63e5040084032cf99adec18c859f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 26 Sep 2014 12:55:57 +0300 Subject: Improve git_push service specs Signed-off-by: Dmitriy Zaporozhets --- spec/services/git_push_service_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index fa99acabc78..9afa4953d61 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -14,6 +14,32 @@ describe GitPushService do @ref = 'refs/heads/master' end + describe 'Push branches' do + context 'new branch' do + subject do + service.execute(project, user, @blankrev, @newrev, @ref) + end + + it { should be_true } + end + + context 'existing branch' do + subject do + service.execute(project, user, @oldrev, @newrev, @ref) + end + + it { should be_true } + end + + context 'rm branch' do + subject do + service.execute(project, user, @oldrev, @blankrev, @ref) + end + + it { should be_true } + end + end + describe "Git Push Data" do before do service.execute(project, user, @oldrev, @newrev, @ref) -- cgit v1.2.1