summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/creates_commit.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-01-06 04:18:51 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-01-06 04:18:51 +0800
commita30f278bdee399346f199ada0e33f5c2d233d861 (patch)
tree01a584bad9f099e6af8cf784bfca3a616ba27add /app/controllers/concerns/creates_commit.rb
parentae86a1b9d3c9ca4ce592fa89085acd059ffc09a0 (diff)
downloadgitlab-ce-a30f278bdee399346f199ada0e33f5c2d233d861.tar.gz
Fix for initial commit and remove unneeded args
Diffstat (limited to 'app/controllers/concerns/creates_commit.rb')
-rw-r--r--app/controllers/concerns/creates_commit.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb
index eafaed8a3d0..f5f9cdeaec5 100644
--- a/app/controllers/concerns/creates_commit.rb
+++ b/app/controllers/concerns/creates_commit.rb
@@ -4,9 +4,10 @@ module CreatesCommit
def create_commit(service, success_path:, failure_path:, failure_view: nil, success_notice: nil)
set_commit_variables
+ source_branch = @mr_target_branch unless initial_commit?
commit_params = @commit_params.merge(
source_project: @mr_target_project,
- source_branch: @mr_target_branch,
+ source_branch: source_branch,
target_branch: @mr_source_branch
)
@@ -113,7 +114,7 @@ module CreatesCommit
else
# Merge request to this project
@mr_target_project = @project
- @mr_target_branch ||= @ref
+ @mr_target_branch = @ref || @target_branch
end
else
# Edit file in fork
@@ -121,7 +122,12 @@ module CreatesCommit
# Merge request from fork to this project
@mr_source_project = @tree_edit_project
@mr_target_project = @project
- @mr_target_branch ||= @ref
+ @mr_target_branch = @ref || @target_branch
end
end
+
+ def initial_commit?
+ @mr_target_branch.nil? ||
+ !@mr_target_project.repository.branch_exists?(@mr_target_branch)
+ end
end