diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-12 18:10:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-12 18:10:25 +0300 |
commit | 4a882000a94d1043b536e078a0e3571bdb0077d3 (patch) | |
tree | fe727bab83189a7a0f4ed72d879902e70a9d46a3 /lib | |
parent | 71a67d17b02e7b8dec2f4c257f6734dc7818fb1e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/branches.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml | 4 | ||||
-rw-r--r-- | lib/gitlab/git/branch.rb | 4 |
3 files changed, 27 insertions, 7 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb index 6842e93a4de..9e16b50f2b7 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -47,13 +47,25 @@ module API merged_branch_names = repository.merged_branch_names(branches.map(&:name)) - present( - branches, - with: Entities::Branch, - current_user: current_user, - project: user_project, - merged_branch_names: merged_branch_names - ) + if Feature.enabled?(:api_caching_branches, user_project, type: :development, default_enabled: :yaml) + present_cached( + branches, + with: Entities::Branch, + current_user: current_user, + project: user_project, + merged_branch_names: merged_branch_names, + expires_in: 10.minutes, + cache_context: -> (branch) { [current_user&.cache_key, merged_branch_names.include?(branch.name)] } + ) + else + present( + branches, + with: Entities::Branch, + current_user: current_user, + project: user_project, + merged_branch_names: merged_branch_names + ) + end end resource ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do diff --git a/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml index 1c25d9d583b..9b3a8e30da0 100644 --- a/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml @@ -16,6 +16,8 @@ build: fi - /build/build.sh rules: + - if: '$BUILD_DISABLED' + when: never - if: '$AUTO_DEVOPS_PLATFORM_TARGET == "EC2"' when: never - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' @@ -26,4 +28,6 @@ build_artifact: - printf "To build your project, please create a build_artifact job into your .gitlab-ci.yml file.\nMore information at https://docs.gitlab.com/ee/ci/cloud_deployment\n" - exit 1 rules: + - if: '$BUILD_DISABLED' + when: never - if: '$AUTO_DEVOPS_PLATFORM_TARGET == "EC2"' diff --git a/lib/gitlab/git/branch.rb b/lib/gitlab/git/branch.rb index 9447cfa0fb6..fbe52db9c0b 100644 --- a/lib/gitlab/git/branch.rb +++ b/lib/gitlab/git/branch.rb @@ -28,6 +28,10 @@ module Gitlab def state active? ? :active : :stale end + + def cache_key + "branch:" + Digest::SHA1.hexdigest([name, target, dereferenced_target&.sha].join(':')) + end end end end |