diff options
author | Sabba Petri <sabbap@gmail.com> | 2015-02-24 09:55:25 -0800 |
---|---|---|
committer | Sabba Petri <sabbap@gmail.com> | 2015-02-24 09:55:25 -0800 |
commit | a33e615b471f8c9b49b1a1baf79f7380ce606790 (patch) | |
tree | 13e90fbb81aa60d8a2ee5540742d40d9438b0b99 /lib | |
parent | 846f83177448832bd04ea0167b34541b5d3b71c6 (diff) | |
parent | 428df28cda4b31a70d908e612bbad627b32c3426 (diff) | |
download | gitlab-ce-a33e615b471f8c9b49b1a1baf79f7380ce606790.tar.gz |
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq into small_profile_changes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/files.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/satellite/files/edit_file_action.rb | 28 | ||||
-rw-r--r-- | lib/gitlab/satellite/satellite.rb | 4 |
3 files changed, 28 insertions, 7 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb index e6e71bac367..3176ef0e256 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -117,7 +117,8 @@ module API branch_name: branch_name } else - render_api_error!(result[:message], 400) + http_status = result[:http_status] || 400 + render_api_error!(result[:message], http_status) end end diff --git a/lib/gitlab/satellite/files/edit_file_action.rb b/lib/gitlab/satellite/files/edit_file_action.rb index 2834b722b27..82d71ab9906 100644 --- a/lib/gitlab/satellite/files/edit_file_action.rb +++ b/lib/gitlab/satellite/files/edit_file_action.rb @@ -15,7 +15,11 @@ module Gitlab prepare_satellite!(repo) # create target branch in satellite at the corresponding commit from bare repo - repo.git.checkout({ raise: true, timeout: true, b: true }, ref, "origin/#{ref}") + begin + repo.git.checkout({ raise: true, timeout: true, b: true }, ref, "origin/#{ref}") + rescue Grit::Git::CommandFailed => ex + log_and_raise(CheckoutFailed, ex.message) + end # update the file in the satellite's working dir file_path_in_satellite = File.join(repo.working_dir, file_path) @@ -31,19 +35,31 @@ module Gitlab # commit the changes # will raise CommandFailed when commit fails - repo.git.commit(raise: true, timeout: true, a: true, m: commit_message) + begin + repo.git.commit(raise: true, timeout: true, a: true, m: commit_message) + rescue Grit::Git::CommandFailed => ex + log_and_raise(CommitFailed, ex.message) + end # push commit back to bare repo # will raise CommandFailed when push fails - repo.git.push({ raise: true, timeout: true }, :origin, ref) + begin + repo.git.push({ raise: true, timeout: true }, :origin, ref) + rescue Grit::Git::CommandFailed => ex + log_and_raise(PushFailed, ex.message) + end # everything worked true end - rescue Grit::Git::CommandFailed => ex - Gitlab::GitLogger.error(ex.message) - false + end + + private + + def log_and_raise(errorClass, message) + Gitlab::GitLogger.error(message) + raise(errorClass, message) end end end diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 62d1bb364d3..70125d539da 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -1,5 +1,9 @@ module Gitlab module Satellite + class CheckoutFailed < StandardError; end + class CommitFailed < StandardError; end + class PushFailed < StandardError; end + class Satellite include Gitlab::Popen |