Skip to content
Snippets Groups Projects
Commit 823868f8 authored by Robert Speicher's avatar Robert Speicher
Browse files

Add `Client.protect_branch`

parent 2ef7ed1b
No related branches found
No related tags found
1 merge request!12WIP: Protect stable branches after push
Pipeline #
Loading
Loading
@@ -12,8 +12,9 @@ class GitlabClient
end
end
 
# Hard-code the CE project ID to save a request
# Hard-code the project IDs to save a request
CE_PROJECT_ID = 13_083
EE_PROJECT_ID = 278_964
 
def self.current_user
@current_user ||= Gitlab.user
Loading
Loading
@@ -70,4 +71,10 @@ class GitlabClient
def self.issue_url(issue)
"https://gitlab.com/gitlab-org/gitlab-ce/issues/#{issue.iid}"
end
def self.protect_branch(branch_name)
project_id = branch_name.end_with?('-ee') ? EE_PROJECT_ID : CE_PROJECT_ID
Gitlab.protect_branch(project_id, branch_name)
end
end
Loading
Loading
@@ -40,4 +40,20 @@ describe GitlabClient do
to eq "https://gitlab.com/gitlab-org/gitlab-ce/issues/1234"
end
end
describe '.protect_branch' do
it 'uses EE ID when given an EE branch' do
expect(Gitlab).to receive(:protect_branch).
with(described_class::EE_PROJECT_ID, '8-4-stable-ee')
described_class.protect_branch('8-4-stable-ee')
end
it 'uses CE ID when given a CE branch' do
expect(Gitlab).to receive(:protect_branch).
with(described_class::CE_PROJECT_ID, '8-4-stable')
described_class.protect_branch('8-4-stable')
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment