Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-14 06:06:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-14 06:06:25 +0300
commit29c01c6c91558358c37ba45b03f240632bfb918d (patch)
treec6475afaf98ce740e8ba5fe227e7bd4a95b692cd /app/services/commits
parenteed996ac33a60d5fd8315a62fec8beaa8e907e69 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/commits')
-rw-r--r--app/services/commits/change_service.rb5
-rw-r--r--app/services/commits/create_service.rb13
2 files changed, 14 insertions, 4 deletions
diff --git a/app/services/commits/change_service.rb b/app/services/commits/change_service.rb
index fbf71f02837..661e654406e 100644
--- a/app/services/commits/change_service.rb
+++ b/app/services/commits/change_service.rb
@@ -23,14 +23,15 @@ module Commits
message,
start_project: @start_project,
start_branch_name: @start_branch)
- rescue Gitlab::Git::Repository::CreateTreeError
+ rescue Gitlab::Git::Repository::CreateTreeError => ex
act = action.to_s.dasherize
type = @commit.change_type_title(current_user)
error_msg = "Sorry, we cannot #{act} this #{type} automatically. " \
"This #{type} may already have been #{act}ed, or a more recent " \
"commit may have updated some of its content."
- raise ChangeError, error_msg
+
+ raise ChangeError.new(error_msg, ex.error_code)
end
end
end
diff --git a/app/services/commits/create_service.rb b/app/services/commits/create_service.rb
index b5401a8ea37..b42494563b2 100644
--- a/app/services/commits/create_service.rb
+++ b/app/services/commits/create_service.rb
@@ -3,7 +3,15 @@
module Commits
class CreateService < ::BaseService
ValidationError = Class.new(StandardError)
- ChangeError = Class.new(StandardError)
+ class ChangeError < StandardError
+ attr_reader :error_code
+
+ def initialize(message, error_code = nil)
+ super(message)
+
+ @error_code = error_code
+ end
+ end
def initialize(*args)
super
@@ -21,8 +29,9 @@ module Commits
new_commit = create_commit!
success(result: new_commit)
+ rescue ChangeError => ex
+ error(ex.message, pass_back: { error_code: ex.error_code })
rescue ValidationError,
- ChangeError,
Gitlab::Git::Index::IndexError,
Gitlab::Git::CommitError,
Gitlab::Git::PreReceiveError,