diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2018-09-08 10:55:17 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2018-09-08 10:55:17 +0200 |
commit | a14e9cfde83c708791ba6a66b45addbe719c9a1d (patch) | |
tree | 75bf894365c44e400479cd939cecad92e2c6b38d /lib/api/helpers.rb | |
parent | ec54fd36e991b2c19b4e4d07342a6f3a1de2d8b1 (diff) | |
download | gitlab-ce-a14e9cfde83c708791ba6a66b45addbe719c9a1d.tar.gz |
API: Use find_branch! in all places
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index be17653dbb2..3469fffc1c8 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -156,6 +156,14 @@ module API end end + def find_branch!(branch_name) + begin + user_project.repository.find_branch(branch_name) || not_found!('Branch') + rescue Gitlab::Git::CommandError + render_api_error!('The branch refname is invalid', 400) + end + end + def find_project_label(id) labels = available_labels_for(user_project) label = labels.find_by_id(id) || labels.find_by_title(id) |