diff options
| author | Robert Schilling <rschilling@student.tugraz.at> | 2017-10-24 13:28:06 +0300 |
|---|---|---|
| committer | Robert Schilling <rschilling@student.tugraz.at> | 2017-10-24 13:28:06 +0300 |
| commit | 58617553e66b4492eee84d320fdc3d65f93d069e (patch) | |
| tree | 0c84d50d034f26811c1a9bbcce4d45bdb915fcce /lib/api/commits.rb | |
| parent | 82446a2bd009e7d7481c35a142063a3973be77ce (diff) | |
| download | gitlab-ce-api-refs-for-commit.tar.gz | |
Basic ref fetching for commitsapi-refs-for-commit
Diffstat (limited to 'lib/api/commits.rb')
| -rw-r--r-- | lib/api/commits.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index 2685dc27252..14d9a3ee985 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -155,6 +155,31 @@ module API end end + desc 'Get all reference a commit is pushed to' do + detail 'This feature was introduced in GitLab 10.2' + success Entities::Ref + end + params do + requires :sha, type: String, desc: 'A commit sha' + optional :type, type: String, values: %w(branches tags all), default: 'all', desc: 'Scope' + end + get ':id/repository/commits/:sha/refs', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do + commit = user_project.commit(params[:sha]) + not_found!('Commit') unless commit + + case params[:type] + when 'branches' + refs = user_project.repository.branch_names_contains(commit.id) + when 'tags' + refs = user_project.repository.tag_names_contains(commit.id) + else + refs = user_project.repository.branch_names_contains(commit.id) + refs << user_project.repository.branch_names_contains(commit.id) + end + + present refs, with: Entities::BasicRef + end + desc 'Post comment to commit' do success Entities::CommitNote end |
